Skip to content

Commit a383312

Browse files
author
Sergey Oblomov
committed
UCX/WPOOL: fixed potential deadlock
- fixed funcs: opal_common_ucx_wpmem_putget opal_common_ucx_wpmem_cmpswp opal_common_ucx_wpmem_post opal_common_ucx_wpmem_fetch opal_common_ucx_wpmem_fetch_nb Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
1 parent 34f2f6a commit a383312

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

opal/mca/common/ucx/common_ucx_wpool.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,15 @@ opal_common_ucx_wpmem_putget(opal_common_ucx_wpmem_t *mem, opal_common_ucx_op_t
376376
if (OPAL_UNLIKELY(status != UCS_OK && status != UCS_INPROGRESS)) {
377377
MCA_COMMON_UCX_ERROR("%s failed: %d", called_func, status);
378378
rc = OPAL_ERROR;
379+
goto out;
379380
}
380381

381382
rc = _periodical_flush_nb(mem, winfo, target);
382383
if(OPAL_UNLIKELY(OPAL_SUCCESS != rc)){
383384
MCA_COMMON_UCX_VERBOSE(1, "_incr_and_check_inflight_ops failed: %d", rc);
384-
return rc;
385385
}
386386

387+
out:
387388
opal_mutex_unlock(&winfo->mutex);
388389

389390
return rc;
@@ -416,14 +417,15 @@ opal_common_ucx_wpmem_cmpswp(opal_common_ucx_wpmem_t *mem, uint64_t compare,
416417
if (OPAL_UNLIKELY(status != UCS_OK)) {
417418
MCA_COMMON_UCX_ERROR("opal_common_ucx_atomic_cswap failed: %d", status);
418419
rc = OPAL_ERROR;
420+
goto out;
419421
}
420422

421423
rc = _periodical_flush_nb(mem, winfo, target);
422424
if(OPAL_UNLIKELY(OPAL_SUCCESS != rc)){
423425
MCA_COMMON_UCX_VERBOSE(1, "_incr_and_check_inflight_ops failed: %d", rc);
424-
return rc;
425426
}
426427

428+
out:
427429
opal_mutex_unlock(&winfo->mutex);
428430

429431
return rc;
@@ -502,14 +504,15 @@ opal_common_ucx_wpmem_post(opal_common_ucx_wpmem_t *mem, ucp_atomic_post_op_t op
502504
if (OPAL_UNLIKELY(status != UCS_OK)) {
503505
MCA_COMMON_UCX_ERROR("ucp_atomic_post failed: %d", status);
504506
rc = OPAL_ERROR;
507+
goto out;
505508
}
506509

507510
rc = _periodical_flush_nb(mem, winfo, target);
508511
if(OPAL_UNLIKELY(OPAL_SUCCESS != rc)){
509512
MCA_COMMON_UCX_VERBOSE(1, "_incr_and_check_inflight_ops failed: %d", rc);
510-
return rc;
511513
}
512514

515+
out:
513516
opal_mutex_unlock(&winfo->mutex);
514517
return rc;
515518
}
@@ -541,14 +544,15 @@ opal_common_ucx_wpmem_fetch(opal_common_ucx_wpmem_t *mem,
541544
if (OPAL_UNLIKELY(status != UCS_OK)) {
542545
MCA_COMMON_UCX_ERROR("ucp_atomic_cswap64 failed: %d", status);
543546
rc = OPAL_ERROR;
547+
goto out;
544548
}
545549

546550
rc = _periodical_flush_nb(mem, winfo, target);
547551
if(OPAL_UNLIKELY(OPAL_SUCCESS != rc)){
548552
MCA_COMMON_UCX_VERBOSE(1, "_incr_and_check_inflight_ops failed: %d", rc);
549-
return rc;
550553
}
551554

555+
out:
552556
opal_mutex_unlock(&winfo->mutex);
553557

554558
return rc;
@@ -592,7 +596,6 @@ opal_common_ucx_wpmem_fetch_nb(opal_common_ucx_wpmem_t *mem,
592596
rc = _periodical_flush_nb(mem, winfo, target);
593597
if(OPAL_UNLIKELY(OPAL_SUCCESS != rc)){
594598
MCA_COMMON_UCX_VERBOSE(1, "_incr_and_check_inflight_ops failed: %d", rc);
595-
return rc;
596599
}
597600

598601
opal_mutex_unlock(&winfo->mutex);

0 commit comments

Comments
 (0)