Skip to content

Commit a0a9306

Browse files
author
Sergey Oblomov
committed
COMMON/UCX: init memhooks infra on external hooks only
- initialize memory hooks infrastructure only in case if external memory hooks are requested Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
1 parent fe5ad67 commit a0a9306

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

opal/mca/common/ucx/common_ucx.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "opal/memoryhooks/memory.h"
1717

1818
#include <ucm/api/ucm.h>
19+
#include <ucs/sys/math.h>
1920

2021
/***********************************************************************/
2122

@@ -91,23 +92,22 @@ OPAL_DECLSPEC void opal_common_ucx_mca_register(void)
9192
opal_common_ucx.output = opal_output_open(NULL);
9293
opal_output_set_verbosity(opal_common_ucx.output, opal_common_ucx.verbose);
9394

94-
ret = mca_base_framework_open(&opal_memory_base_framework, 0);
95-
if (OPAL_SUCCESS != ret) {
96-
/* failed to initialize memory framework - just exit */
97-
MCA_COMMON_UCX_VERBOSE(1, "failed to initialize memory base framework: %d, "
98-
"memory hooks will not be used", ret);
99-
return;
100-
}
101-
10295
/* Set memory hooks */
103-
if (opal_common_ucx.opal_mem_hooks &&
104-
(OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) ==
105-
((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) &
106-
opal_mem_hooks_support_level()))
107-
{
108-
MCA_COMMON_UCX_VERBOSE(1, "%s", "using OPAL memory hooks as external events");
109-
ucm_set_external_event(UCM_EVENT_VM_UNMAPPED);
110-
opal_mem_hooks_register_release(opal_common_ucx_mem_release_cb, NULL);
96+
if (opal_common_ucx.opal_mem_hooks) {
97+
ret = mca_base_framework_open(&opal_memory_base_framework, 0);
98+
if (OPAL_SUCCESS != ret) {
99+
/* failed to initialize memory framework - just exit */
100+
MCA_COMMON_UCX_VERBOSE(1, "failed to initialize memory base framework: %d, "
101+
"memory hooks will not be used", ret);
102+
return;
103+
}
104+
105+
if (ucs_test_all_flags(opal_mem_hooks_support_level(),
106+
OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT)) {
107+
MCA_COMMON_UCX_VERBOSE(1, "%s", "using OPAL memory hooks as external events");
108+
ucm_set_external_event(UCM_EVENT_VM_UNMAPPED);
109+
opal_mem_hooks_register_release(opal_common_ucx_mem_release_cb, NULL);
110+
}
111111
}
112112
}
113113

0 commit comments

Comments
 (0)