@@ -433,7 +433,6 @@ int opal_common_ucx_wpmem_create(opal_common_ucx_ctx_t *ctx, void **mem_base, si
433
433
mem -> mem_displs = NULL ;
434
434
435
435
OBJ_CONSTRUCT (& mem -> mutex , opal_mutex_t );
436
- OBJ_CONSTRUCT (& mem -> mem_records , opal_list_t );
437
436
438
437
ret = _comm_ucx_wpmem_map (ctx -> wpool , mem_base , mem_size , & mem -> memh , mem_type );
439
438
if (ret != OPAL_SUCCESS ) {
@@ -528,13 +527,6 @@ void opal_common_ucx_wpmem_free(opal_common_ucx_wpmem_t *mem)
528
527
529
528
OBJ_DESTRUCT (& mem -> tls_key );
530
529
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
-
538
530
free (mem -> mem_addrs );
539
531
free (mem -> mem_displs );
540
532
@@ -673,11 +665,6 @@ static void _tlocal_mem_rec_cleanup(_mem_record_t *mem_rec)
673
665
opal_mutex_unlock (& mem_rec -> winfo -> mutex );
674
666
free (mem_rec -> rkeys );
675
667
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
-
681
668
OBJ_RELEASE (mem_rec );
682
669
683
670
return ;
@@ -701,10 +688,6 @@ static _mem_record_t *_tlocal_add_mem_rec(opal_common_ucx_wpmem_t *mem, _ctx_rec
701
688
return NULL ;
702
689
}
703
690
704
- opal_mutex_lock (& mem -> mutex );
705
- opal_list_append (& mem -> mem_records , & mem_rec -> super );
706
- opal_mutex_unlock (& mem -> mutex );
707
-
708
691
return mem_rec ;
709
692
}
710
693
@@ -752,11 +735,19 @@ OPAL_DECLSPEC int opal_common_ucx_tlocal_fetch_spath(opal_common_ucx_wpmem_t *me
752
735
}
753
736
ep = winfo -> endpoints [target ];
754
737
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
+ }
757
748
758
749
/* Obtain the rkey */
759
- if (OPAL_UNLIKELY ( NULL == mem_rec -> rkeys [target ]) ) {
750
+ if (NULL == mem_rec -> rkeys [target ]) {
760
751
/* Create the rkey */
761
752
rc = _tlocal_mem_create_rkey (mem_rec , ep , target );
762
753
if (rc ) {
0 commit comments