Skip to content

Commit ef67305

Browse files
committed
prov/efa: Allocate cq err_buf on demand
efa_cq->err_buf is only needed by efa-direct cq which can store the err data on the util cq bypass path. Make it allocated on demand during the efa-direct cq open to save memory. Signed-off-by: Shi Jin <[email protected]>
1 parent fa9aee2 commit ef67305

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

prov/efa/src/efa_cq.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ int efa_cq_close(fid_t fid)
860860
}
861861
#endif
862862

863+
if (cq->err_buf)
864+
free(cq->err_buf);
865+
863866
free(cq);
864867

865868
return 0;
@@ -988,6 +991,14 @@ int efa_cq_open(struct fid_domain *domain_fid, struct fi_cq_attr *attr,
988991

989992
cq->wait_cond = attr->wait_cond;
990993

994+
/* This buffer is only used by efa-direct cq on the util cq bypass path */
995+
cq->err_buf = malloc(EFA_ERROR_MSG_BUFFER_LENGTH);
996+
if (!cq->err_buf) {
997+
EFA_WARN(FI_LOG_CQ, "Failed to allocate memory for err_data buf in CQ\n");
998+
err = -FI_ENOMEM;
999+
goto err_free_util_cq;
1000+
}
1001+
9911002
err = efa_cq_open_ibv_cq(attr, efa_domain->device->ibv_ctx,
9921003
&cq->ibv_cq,
9931004
&efa_cq_init_attr);

prov/efa/src/efa_cq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ struct efa_cq {
3939
ofi_atomic32_t nevents;
4040
enum fi_wait_obj wait_obj;
4141
enum fi_cq_wait_cond wait_cond;
42+
/* Only used by efa-direct cq on util cq bypass path */
4243
void (*read_entry)(struct efa_ibv_cq *ibv_cq, void *buf, int opcode);
43-
char err_buf[EFA_ERROR_MSG_BUFFER_LENGTH];
44+
char *err_buf;
4445
};
4546

4647
extern struct fi_ops_cq efa_cq_ops;

0 commit comments

Comments
 (0)