Skip to content

Commit aefc2ed

Browse files
committed
Merge pull request #1283 from artpol84/udcm_race_fix
Fix race condition in UDCM
2 parents 0fb7b07 + 84e4fb3 commit aefc2ed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

opal/mca/btl/openib/connect/btl_openib_connect_udcm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* and Technology (RIST). All rights reserved.
1010
* Copyright (c) 2014 Intel, Inc. All rights reserved.
1111
* Copyright (c) 2014 Bull SAS. All rights reserved.
12+
* Copyright (c) 2016 Mellanox Technologies. All rights reserved.
1213
*
1314
* $COPYRIGHT$
1415
*
@@ -2101,6 +2102,8 @@ static int udcm_process_messages (struct ibv_cq *event_cq, udcm_module_t *m)
21012102
udcm_module_post_one_recv (m, msg_num);
21022103
}
21032104

2105+
opal_atomic_wmb ();
2106+
21042107
if (0 == opal_atomic_swap_32 (&m->cm_message_event_active, 1)) {
21052108
opal_event_active (&m->cm_message_event, OPAL_EV_READ, 1);
21062109
}
@@ -2158,6 +2161,10 @@ static void *udcm_message_callback (int fd, int flags, void *context)
21582161

21592162
BTL_VERBOSE(("running message thread"));
21602163

2164+
/* Mark that the callback was started */
2165+
opal_atomic_swap_32 (&m->cm_message_event_active, 0);
2166+
opal_atomic_wmb ();
2167+
21612168
while ((item = (udcm_message_recv_t *) opal_fifo_pop_atomic (&m->cm_recv_msg_fifo))) {
21622169
mca_btl_openib_endpoint_t *lcl_ep = item->msg_hdr.lcl_ep;
21632170

@@ -2199,8 +2206,6 @@ static void *udcm_message_callback (int fd, int flags, void *context)
21992206

22002207
BTL_VERBOSE(("exiting message thread"));
22012208

2202-
opal_atomic_swap_32 (&m->cm_message_event_active, 0);
2203-
22042209
return NULL;
22052210
}
22062211

0 commit comments

Comments
 (0)