diff --git a/opal/mca/btl/ofi/btl_ofi_component.c b/opal/mca/btl/ofi/btl_ofi_component.c index e97cd6f8e9..41d991d11e 100644 --- a/opal/mca/btl/ofi/btl_ofi_component.c +++ b/opal/mca/btl/ofi/btl_ofi_component.c @@ -417,6 +417,12 @@ static int mca_btl_ofi_init_device(struct fi_info *info) ep_attr = ofi_info->ep_attr; domain_attr = ofi_info->domain_attr; + /* mtl_btl_ofi_rcache_init() initializes patcher which should only + * take place things are single threaded. OFI providers may start + * spawn threads, so initialize the rcache before creating OFI objects + * to prevent races. */ + mca_btl_ofi_rcache_init(module); + linux_device_name = info->domain_attr->name; BTL_VERBOSE(("initializing dev:%s provider:%s", linux_device_name, @@ -547,9 +553,6 @@ static int mca_btl_ofi_init_device(struct fi_info *info) module->use_virt_addr = true; } - /* initialize the rcache */ - mca_btl_ofi_rcache_init(module); - /* create endpoint list */ OBJ_CONSTRUCT(&module->endpoints, opal_list_t); OBJ_CONSTRUCT(&module->module_lock, opal_mutex_t);