From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8D7B5B524 for ; Sun, 15 Feb 2015 04:16:16 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 14 Feb 2015 19:08:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,579,1418112000"; d="scan'208";a="652336350" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 14 Feb 2015 19:16:14 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1F3GBTa022813; Sun, 15 Feb 2015 11:16:11 +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 t1F3G9tZ032088; Sun, 15 Feb 2015 11:16:11 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1F3G9Lc032084; Sun, 15 Feb 2015 11:16:09 +0800 From: Cunming Liang To: dev@dpdk.org Date: Sun, 15 Feb 2015 11:15:32 +0800 Message-Id: <1423970145-31985-7-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 06/19] eal: new TLS definition and API declaration 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:17 -0000 1. add two TLS *_socket_id* and *_cpuset* 2. add two internal API, eal_cpu_socket_id/eal_thread_dump_affinity 3. add two public API, rte_thread_set/get_affinity 4. update EAL version map for EAL public API Signed-off-by: Cunming Liang --- v7 changes: update version map for EAL public API and reword comments v5 changes: add comments for RTE_CPU_AFFINITY_STR_LEN update comments for eal_thread_dump_affinity() return void for rte_thread_get_affinity() move rte_socket_id() change to another patch lib/librte_eal/bsdapp/eal/eal_thread.c | 2 ++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_thread.h | 36 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 26 +++++++++++++++++- lib/librte_eal/linuxapp/eal/eal_thread.c | 2 ++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c b/lib/librte_eal/bsdapp/eal/eal_thread.c index ab05368..10220c7 100644 --- a/lib/librte_eal/bsdapp/eal/eal_thread.c +++ b/lib/librte_eal/bsdapp/eal/eal_thread.c @@ -56,6 +56,8 @@ #include "eal_thread.h" RTE_DEFINE_PER_LCORE(unsigned, _lcore_id); +RTE_DEFINE_PER_LCORE(unsigned, _socket_id); +RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset); /* * Send a message to a slave lcore identified by slave_id to call a diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index d36286e..00b2ccd 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -82,6 +82,8 @@ DPDK_2.0 { rte_snprintf; rte_strerror; rte_strsplit; + rte_thread_get_affinity; + rte_thread_set_affinity; rte_vlog; rte_xen_dom0_memory_attach; rte_xen_dom0_memory_init; diff --git a/lib/librte_eal/common/eal_thread.h b/lib/librte_eal/common/eal_thread.h index f1ce0bd..e4e76b9 100644 --- a/lib/librte_eal/common/eal_thread.h +++ b/lib/librte_eal/common/eal_thread.h @@ -34,6 +34,8 @@ #ifndef EAL_THREAD_H #define EAL_THREAD_H +#include + /** * basic loop of thread, called for each thread by eal_init(). * @@ -61,4 +63,38 @@ void eal_thread_init_master(unsigned lcore_id); */ unsigned eal_cpu_socket_id(unsigned cpu_id); +/** + * Get the NUMA socket id from cpuset. + * This function is private to EAL. + * + * @param cpusetp + * The point to a valid cpu set. + * @return + * socket_id or SOCKET_ID_ANY + */ +int eal_cpuset_socket_id(rte_cpuset_t *cpusetp); + +/** + * Default buffer size to use with eal_thread_dump_affinity() + */ +#define RTE_CPU_AFFINITY_STR_LEN 256 + +/** + * Dump the current pthread cpuset. + * This function is private to EAL. + * + * Note: + * If the dump size is greater than the size of given buffer, + * the string will be truncated and with '\0' at the end. + * + * @param str + * The string buffer the cpuset will dump to. + * @param size + * The string buffer size. + * @return + * 0 for success, -1 if truncation happens. + */ +int +eal_thread_dump_affinity(char *str, unsigned size); + #endif /* EAL_THREAD_H */ diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 4c7d6bb..33f558e 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -80,7 +80,9 @@ struct lcore_config { */ extern struct lcore_config lcore_config[RTE_MAX_LCORE]; -RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per core "core id". */ +RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per thread "lcore id". */ +RTE_DECLARE_PER_LCORE(unsigned, _socket_id); /**< Per thread "socket id". */ +RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread "cpuset". */ /** * Return the ID of the execution unit we are running on. @@ -229,6 +231,28 @@ rte_get_next_lcore(unsigned i, int skip_master, int wrap) i