Skip to content

Commit 37c2581

Browse files
authored
Merge pull request #8954 from devreal/fix-osc-ucx-rkey-alloc
OSC/UCX: Use existing mem_recs when unpacking the rkey
2 parents 40ce2ff + ebdc173 commit 37c2581

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

opal/mca/common/ucx/common_ucx_wpool.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ int opal_common_ucx_wpmem_create(opal_common_ucx_ctx_t *ctx, void **mem_base, si
433433
mem->mem_displs = NULL;
434434

435435
OBJ_CONSTRUCT(&mem->mutex, opal_mutex_t);
436-
OBJ_CONSTRUCT(&mem->mem_records, opal_list_t);
437436

438437
ret = _comm_ucx_wpmem_map(ctx->wpool, mem_base, mem_size, &mem->memh, mem_type);
439438
if (ret != OPAL_SUCCESS) {
@@ -528,13 +527,6 @@ void opal_common_ucx_wpmem_free(opal_common_ucx_wpmem_t *mem)
528527

529528
OBJ_DESTRUCT(&mem->tls_key);
530529

531-
/* Loop through list of records */
532-
OPAL_LIST_FOREACH_SAFE (mem_rec, next, &mem->mem_records, _mem_record_t) {
533-
_tlocal_mem_rec_cleanup(mem_rec);
534-
}
535-
536-
OBJ_DESTRUCT(&mem->mem_records);
537-
538530
free(mem->mem_addrs);
539531
free(mem->mem_displs);
540532

@@ -673,11 +665,6 @@ static void _tlocal_mem_rec_cleanup(_mem_record_t *mem_rec)
673665
opal_mutex_unlock(&mem_rec->winfo->mutex);
674666
free(mem_rec->rkeys);
675667

676-
/* Remove item from the list */
677-
opal_mutex_lock(&mem_rec->gmem->mutex);
678-
opal_list_remove_item(&mem_rec->gmem->mem_records, &mem_rec->super);
679-
opal_mutex_unlock(&mem_rec->gmem->mutex);
680-
681668
OBJ_RELEASE(mem_rec);
682669

683670
return;
@@ -701,10 +688,6 @@ static _mem_record_t *_tlocal_add_mem_rec(opal_common_ucx_wpmem_t *mem, _ctx_rec
701688
return NULL;
702689
}
703690

704-
opal_mutex_lock(&mem->mutex);
705-
opal_list_append(&mem->mem_records, &mem_rec->super);
706-
opal_mutex_unlock(&mem->mutex);
707-
708691
return mem_rec;
709692
}
710693

@@ -752,11 +735,19 @@ OPAL_DECLSPEC int opal_common_ucx_tlocal_fetch_spath(opal_common_ucx_wpmem_t *me
752735
}
753736
ep = winfo->endpoints[target];
754737

755-
/* Obtain the memory region info */
756-
mem_rec = _tlocal_add_mem_rec(mem, ctx_rec);
738+
739+
rc = opal_tsd_tracked_key_get(&mem->tls_key, (void **) &mem_rec);
740+
if (OPAL_SUCCESS != rc) {
741+
return rc;
742+
}
743+
744+
if (NULL == mem_rec) {
745+
/* Allocate a memory region info */
746+
mem_rec = _tlocal_add_mem_rec(mem, ctx_rec);
747+
}
757748

758749
/* Obtain the rkey */
759-
if (OPAL_UNLIKELY(NULL == mem_rec->rkeys[target])) {
750+
if (NULL == mem_rec->rkeys[target]) {
760751
/* Create the rkey */
761752
rc = _tlocal_mem_create_rkey(mem_rec, ep, target);
762753
if (rc) {

opal/mca/common/ucx/common_ucx_wpool.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ typedef struct {
101101
char *mem_addrs;
102102
int *mem_displs;
103103

104-
/* A list of mem records
105-
* We need to kepp trakc o fallocated memory records so that we can free them at the end
106-
* if a thread fails to release the memory record */
107-
opal_list_t mem_records;
108-
109104
/* TLS item that allows each thread to
110105
* store endpoints and rkey arrays
111106
* for faster access */

0 commit comments

Comments
 (0)