From c767dcc97adc5ce73bd7a0bf04c92059136ee686 Mon Sep 17 00:00:00 2001 From: Dariusz Sciebura Date: Thu, 28 Nov 2024 07:02:54 +0000 Subject: [PATCH] core/logging: Fix race in writing to vrb_ep_ops 'vrb_ep_ops' is a static object which field 'ops_open' gets overriden in 'vrb_open_ep'. If the operation is performed by multiple threads at once, which is totally possible, we end up with a data race. Switching it to thread local fixes it. Signed-off-by: Dariusz Sciebura --- prov/verbs/src/verbs_ep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prov/verbs/src/verbs_ep.c b/prov/verbs/src/verbs_ep.c index 63aea82778d..b9a1313b986 100644 --- a/prov/verbs/src/verbs_ep.c +++ b/prov/verbs/src/verbs_ep.c @@ -191,7 +191,7 @@ ssize_t vrb_post_send(struct vrb_ep *ep, struct ibv_send_wr *wr, uint64_t flags) } if (vrb_wr_consumes_recv(wr)) { - if (!ep->peer_rq_credits || + if (!ep->peer_rq_credits || (ep->peer_rq_credits == 1 && !(flags & OFI_PRIORITY))) /* Last credit is reserved for credit update */ goto freectx; @@ -1156,7 +1156,7 @@ static int vrb_dgram_ep_getname(fid_t ep_fid, void *addr, size_t *addrlen) return FI_SUCCESS; } -static struct fi_ops vrb_ep_ops = { +_Thread_local static struct fi_ops vrb_ep_ops = { .size = sizeof(struct fi_ops), .close = vrb_ep_close, .bind = vrb_ep_bind,