Skip to content

Commit

Permalink
prov/shm: fix shm multi recv setopt segfault
Browse files Browse the repository at this point in the history
shm uses the util srx and sets the minimum multi receive size through
the srx. However, the srx code doesn't get initialized until the endpoint
gets enabled. So if the application calls setopt (before FI_ENABLE), this
will segfault because the srx has not been initialized. Instead, we need
to save the multi recv size in the shm endpoint to be valid during setopt
and then pass that into the util_srx creation to set the multi recv size

Signed-off-by: Alexia Ingerson <[email protected]>
  • Loading branch information
aingerson authored and shijin-aws committed Dec 10, 2024
1 parent 6b8f5db commit 5eff15c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions prov/shm/src/smr.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct smr_ep {
struct smr_tx_fs *tx_fs;
struct dlist_entry sar_list;
struct dlist_entry ipc_cpy_pend_list;
size_t min_multi_recv_size;

int ep_idx;
enum ofi_shm_p2p_type p2p_type;
Expand Down
8 changes: 4 additions & 4 deletions prov/shm/src/smr_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,12 @@ int smr_ep_setopt(fid_t fid, int level, int optname, const void *optval,
{
struct smr_ep *smr_ep =
container_of(fid, struct smr_ep, util_ep.ep_fid);
struct util_srx_ctx *srx;

if (level != FI_OPT_ENDPOINT)
return -FI_ENOPROTOOPT;

if (optname == FI_OPT_MIN_MULTI_RECV) {
srx = smr_ep->srx->ep_fid.fid.context;
srx->min_multi_recv_size = *(size_t *)optval;
smr_ep->min_multi_recv_size = *(size_t *)optval;
return FI_SUCCESS;
}

Expand Down Expand Up @@ -1146,7 +1144,7 @@ static int smr_ep_ctrl(struct fid *fid, int command, void *arg)
util_domain.domain_fid);
ret = util_ep_srx_context(&domain->util_domain,
ep->rx_size, SMR_IOV_LIMIT,
SMR_INJECT_SIZE, &smr_update,
ep->min_multi_recv_size, &smr_update,
&ep->util_ep.lock, &srx);
if (ret)
return ret;
Expand Down Expand Up @@ -1308,6 +1306,8 @@ int smr_endpoint(struct fid_domain *domain, struct fi_info *info,
dlist_init(&ep->sar_list);
dlist_init(&ep->ipc_cpy_pend_list);

ep->min_multi_recv_size = SMR_INJECT_SIZE;

ep->util_ep.ep_fid.fid.ops = &smr_ep_fi_ops;
ep->util_ep.ep_fid.ops = &smr_ep_ops;
ep->util_ep.ep_fid.cm = &smr_cm_ops;
Expand Down

0 comments on commit 5eff15c

Please sign in to comment.