Skip to content

Commit

Permalink
check if numa available or not before loading numa functions (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK authored Oct 29, 2024
1 parent 6f20cfb commit bb29dc8
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions source/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,32 @@ void aws_common_library_init(struct aws_allocator *allocator) {
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_available() failed to load");
}

*(void **)(&g_numa_num_configured_nodes_ptr) = dlsym(g_libnuma_handle, "numa_num_configured_nodes");
if (g_numa_num_configured_nodes_ptr) {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_configured_nodes() loaded");
if (g_numa_available_ptr() == -1) {
AWS_LOGF_INFO(
AWS_LS_COMMON_GENERAL,
"static: numa_available() returns -1, numa functions are not available. Skip loading the other "
"numa functions.");
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_configured_nodes() failed to load");
}
*(void **)(&g_numa_num_configured_nodes_ptr) = dlsym(g_libnuma_handle, "numa_num_configured_nodes");
if (g_numa_num_configured_nodes_ptr) {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_configured_nodes() loaded");
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_configured_nodes() failed to load");
}

*(void **)(&g_numa_num_possible_cpus_ptr) = dlsym(g_libnuma_handle, "numa_num_possible_cpus");
if (g_numa_num_possible_cpus_ptr) {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_possible_cpus() loaded");
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_possible_cpus() failed to load");
}
*(void **)(&g_numa_num_possible_cpus_ptr) = dlsym(g_libnuma_handle, "numa_num_possible_cpus");
if (g_numa_num_possible_cpus_ptr) {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_possible_cpus() loaded");
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_num_possible_cpus() failed to load");
}

*(void **)(&g_numa_node_of_cpu_ptr) = dlsym(g_libnuma_handle, "numa_node_of_cpu");
if (g_numa_node_of_cpu_ptr) {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_node_of_cpu() loaded");
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_node_of_cpu() failed to load");
*(void **)(&g_numa_node_of_cpu_ptr) = dlsym(g_libnuma_handle, "numa_node_of_cpu");
if (g_numa_node_of_cpu_ptr) {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_node_of_cpu() loaded");
} else {
AWS_LOGF_INFO(AWS_LS_COMMON_GENERAL, "static: numa_node_of_cpu() failed to load");
}
}

} else {
Expand Down

0 comments on commit bb29dc8

Please sign in to comment.