From 5eff15c1e062e86b100198c2806a1b5c0b7be3df Mon Sep 17 00:00:00 2001 From: Alexia Ingerson Date: Mon, 9 Dec 2024 11:38:22 -0800 Subject: [PATCH] prov/shm: fix shm multi recv setopt segfault 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 --- prov/shm/src/smr.h | 1 + prov/shm/src/smr_ep.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/prov/shm/src/smr.h b/prov/shm/src/smr.h index 52c534097e1..d4287fdba88 100644 --- a/prov/shm/src/smr.h +++ b/prov/shm/src/smr.h @@ -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; diff --git a/prov/shm/src/smr_ep.c b/prov/shm/src/smr_ep.c index dd3d7f53f07..82bc95200b1 100644 --- a/prov/shm/src/smr_ep.c +++ b/prov/shm/src/smr_ep.c @@ -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; } @@ -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; @@ -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;