From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id BA7B6B536 for ; Sun, 15 Feb 2015 04:16:13 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 14 Feb 2015 19:16:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,579,1418112000"; d="scan'208";a="678124560" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 14 Feb 2015 19:16:11 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1F3G9Zc022733; Sun, 15 Feb 2015 11:16:09 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t1F3G7Qm032079; Sun, 15 Feb 2015 11:16:09 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1F3G7Ft032075; Sun, 15 Feb 2015 11:16:07 +0800 From: Cunming Liang To: dev@dpdk.org Date: Sun, 15 Feb 2015 11:15:31 +0800 Message-Id: <1423970145-31985-6-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1423970145-31985-1-git-send-email-cunming.liang@intel.com> References: <1423791501-1555-1-git-send-email-cunming.liang@intel.com> <1423970145-31985-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH v7 05/19] eal: add public function parsing socket_id from cpuid X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 03:16:14 -0000 It defines eal_cpu_socket_id() which exposing the origin private cpu_socket_id(). The function is only used inside EAL. It returns socket_id of the specified cpu_id. Signed-off-by: Cunming Liang --- v7 changes: reword comments v5 changes: expose cpu_socket_id as eal_cpu_socket_id for linuxapp eal_cpuset_socket_id() remove static inline and move to c file lib/librte_eal/bsdapp/eal/eal_lcore.c | 7 +++++++ lib/librte_eal/common/eal_thread.h | 11 +++++++++++ lib/librte_eal/linuxapp/eal/eal_lcore.c | 7 ++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_lcore.c b/lib/librte_eal/bsdapp/eal/eal_lcore.c index 72f8ac2..162fb4f 100644 --- a/lib/librte_eal/bsdapp/eal/eal_lcore.c +++ b/lib/librte_eal/bsdapp/eal/eal_lcore.c @@ -41,6 +41,7 @@ #include #include "eal_private.h" +#include "eal_thread.h" /* No topology information available on FreeBSD including NUMA info */ #define cpu_core_id(X) 0 @@ -112,3 +113,9 @@ rte_eal_cpu_init(void) return 0; } + +unsigned +eal_cpu_socket_id(__rte_unused unsigned cpu_id) +{ + return cpu_socket_id(cpu_id); +} diff --git a/lib/librte_eal/common/eal_thread.h b/lib/librte_eal/common/eal_thread.h index b53b84d..f1ce0bd 100644 --- a/lib/librte_eal/common/eal_thread.h +++ b/lib/librte_eal/common/eal_thread.h @@ -50,4 +50,15 @@ __attribute__((noreturn)) void *eal_thread_loop(void *arg); */ void eal_thread_init_master(unsigned lcore_id); +/** + * Get the NUMA socket id from cpu id. + * This function is private to EAL. + * + * @param cpu_id + * The logical process id. + * @return + * socket_id or SOCKET_ID_ANY + */ +unsigned eal_cpu_socket_id(unsigned cpu_id); + #endif /* EAL_THREAD_H */ diff --git a/lib/librte_eal/linuxapp/eal/eal_lcore.c b/lib/librte_eal/linuxapp/eal/eal_lcore.c index 29615f8..ef8c433 100644 --- a/lib/librte_eal/linuxapp/eal/eal_lcore.c +++ b/lib/librte_eal/linuxapp/eal/eal_lcore.c @@ -45,6 +45,7 @@ #include "eal_private.h" #include "eal_filesystem.h" +#include "eal_thread.h" #define SYS_CPU_DIR "/sys/devices/system/cpu/cpu%u" #define CORE_ID_FILE "topology/core_id" @@ -71,8 +72,8 @@ cpu_detected(unsigned lcore_id) * Note: physical package id != NUMA node, but we use it as a * fallback for kernels which don't create a nodeY link */ -static unsigned -cpu_socket_id(unsigned lcore_id) +unsigned +eal_cpu_socket_id(unsigned lcore_id) { const char node_prefix[] = "node"; const size_t prefix_len = sizeof(node_prefix) - 1; @@ -174,7 +175,7 @@ rte_eal_cpu_init(void) /* By default, each detected core is enabled */ config->lcore_role[lcore_id] = ROLE_RTE; lcore_config[lcore_id].core_id = cpu_core_id(lcore_id); - lcore_config[lcore_id].socket_id = cpu_socket_id(lcore_id); + lcore_config[lcore_id].socket_id = eal_cpu_socket_id(lcore_id); if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES) #ifdef RTE_EAL_ALLOW_INV_SOCKET_ID lcore_config[lcore_id].socket_id = 0; -- 1.8.1.4