Skip to content

Commit 1fa7054

Browse files
xinzhao3artpol84
authored andcommitted
opal/common/ucx: use trylock in opal_common_progress
Signed-off-by: Xin Zhao <xinz@mellanox.com>
1 parent 2d3cffe commit 1fa7054

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

opal/mca/common/ucx/common_ucx_wpool.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -290,24 +290,24 @@ opal_common_ucx_wpool_progress(opal_common_ucx_wpool_t *wpool)
290290
/* Go over all active workers and progress them
291291
* TODO: may want to have some partitioning to progress only part of
292292
* workers */
293-
opal_mutex_lock(&wpool->mutex);
294-
OPAL_LIST_FOREACH_SAFE(item, next, &wpool->active_workers,
295-
_winfo_list_item_t) {
296-
opal_common_ucx_winfo_t *winfo = item->ptr;
297-
opal_mutex_lock(&winfo->mutex);
298-
if( OPAL_UNLIKELY(winfo->released) ) {
299-
/* Do garbage collection of worker info's if needed */
300-
opal_list_remove_item(&wpool->active_workers, &item->super);
301-
_winfo_reset(winfo);
302-
opal_list_append(&wpool->idle_workers, &item->super);
303-
} else {
304-
/* Progress worker until there are existing events */
305-
while(ucp_worker_progress(winfo->worker));
293+
if (!opal_mutex_trylock (&wpool->mutex)) {
294+
OPAL_LIST_FOREACH_SAFE(item, next, &wpool->active_workers,
295+
_winfo_list_item_t) {
296+
opal_common_ucx_winfo_t *winfo = item->ptr;
297+
opal_mutex_lock(&winfo->mutex);
298+
if( OPAL_UNLIKELY(winfo->released) ) {
299+
/* Do garbage collection of worker info's if needed */
300+
opal_list_remove_item(&wpool->active_workers, &item->super);
301+
_winfo_reset(winfo);
302+
opal_list_append(&wpool->idle_workers, &item->super);
303+
} else {
304+
/* Progress worker until there are existing events */
305+
while(ucp_worker_progress(winfo->worker));
306+
}
307+
opal_mutex_unlock(&winfo->mutex);
306308
}
307-
opal_mutex_unlock(&winfo->mutex);
309+
opal_mutex_unlock(&wpool->mutex);
308310
}
309-
310-
opal_mutex_unlock(&wpool->mutex);
311311
}
312312

313313
static int

0 commit comments

Comments
 (0)