From de7a94beceb72d6c97e1120ff90d444c3b824ad4 Mon Sep 17 00:00:00 2001 From: Dengke Date: Mon, 28 Oct 2024 13:53:20 -0700 Subject: [PATCH 1/2] check if numa available or not --- source/common.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/source/common.c b/source/common.c index 1822f93e2..1087c2644 100644 --- a/source/common.c +++ b/source/common.c @@ -358,26 +358,33 @@ 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."); + AWS_FATAL_ASSERT(-1); } 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 { From 418bbea110f4866eced687511c94732c7a75ae0b Mon Sep 17 00:00:00 2001 From: Dengke Date: Mon, 28 Oct 2024 13:58:58 -0700 Subject: [PATCH 2/2] remove the fatal assert we put up for testing --- source/common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/common.c b/source/common.c index 1087c2644..a391f4fcb 100644 --- a/source/common.c +++ b/source/common.c @@ -363,7 +363,6 @@ void aws_common_library_init(struct aws_allocator *allocator) { AWS_LS_COMMON_GENERAL, "static: numa_available() returns -1, numa functions are not available. Skip loading the other " "numa functions."); - AWS_FATAL_ASSERT(-1); } else { *(void **)(&g_numa_num_configured_nodes_ptr) = dlsym(g_libnuma_handle, "numa_num_configured_nodes"); if (g_numa_num_configured_nodes_ptr) {