From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB524C982C3 for ; Wed, 16 Sep 2026 14:55:25 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84C3242ECD; Wed, 16 Sep 2026 16:55:20 +0200 (CEST) Received: from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75]) by mails.dpdk.org (Postfix) with ESMTP id D9AAC4028B for ; Wed, 16 Sep 2026 16:55:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=3536; q=dns/txt; s=iport01; t=1789570519; x=1790780119; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hXh8dvY6O4+ZzaZ1+kKLr2D8pBQaERoBMY2St71ueRo=; b=Sz0C7CiZYvs0qAQwW+qecoz97hZ3aLA7ctMQ3UYikwdfaKWP3+vO1iMo HAAdNrHhtGD3bWLT0bqF2GiRFtVQqXRjwSewDOS6tfYxPK5zk977Om8eH rIfrZNtni2YAkoWvktWEzYSSGXmFN/eHz1erCEuadvZ21YG0osDyvIufu v2DU9KaCDgVaHfPwDw1RFcyfj/p7jqu/3fRopDMfWjOL0+qJ3pLohAa7/ URTLMisxB+TngJepFSruNAW7OzjEFA8T6XiasPbzke+tbF4f2F2KOMaeF DAot/k4R+d5y21nDMRLGCPiyh1xZ+EBwuyftq78zguvyaiE2ei4PR8ys/ w==; X-CSE-ConnectionGUID: jXYMu/l7T/+OBRFz1oOAVw== X-CSE-MsgGUID: UVnWLFsnTP26E/LL5NThSg== X-IPAS-Result: =?us-ascii?q?A0BEAgAYrapq/5P/Ja1QCoJZgleBVkJJlkqBFopRkje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QLSlTtnumo F3i0X//PilAavHY7R7Y1E6sveCayEsXX6pXTtVU7MVCjFCN7mALBB5QUkG0ydGlikm7Usl3L ksS+CMqqq508kG3JuQRRDWiq3KC+xpZUN1KHqhjsEeGy7Hf5ECSAW1soiN9VeHKffQeHVQCv mJlVfuwbdCzmNV5kU6gy4o= IronPort-HdrOrdr: A9a23:Igzod6OC0LH8c8BcTuGjsMiBIKoaSvp037Dk7SxMoHtuA6ilfq +V8sjzuSWftN9VYgBCpTniAtjkfZqjz/9ICOAqVN/IYOClghrLEGgI1+TfKlPbdhEWjtQ86Y 5QN45jFdb3EV92yez+4AW+DpIc5ePvytHOuQ8bpE0dND2DrMpbnmFENjo= X-Talos-CUID: 9a23:MLJl0236+ICMx2XddWHx27xfGPAUV2CayCjsZAyfI1xHWuSSbnau5/Yx X-Talos-MUID: 9a23:X7EmEgZqflNxFeBTigHquxVML8FU2/7wJQcptcggh8m/Onkl X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.27,103,1787011200"; d="scan'208";a="524511082" Received: from rcdn-l-core-10.cisco.com ([173.37.255.147]) by rcdn-iport-4.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 16 Sep 2026 14:55:17 +0000 Received: from rtp-orb-10405.cisco.com (rtp-orb-10405.cisco.com [64.100.22.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by rcdn-l-core-10.cisco.com (Postfix) with ESMTPS id 741C91800027C; Wed, 16 Sep 2026 14:55:17 +0000 (GMT) From: Randy L Tice To: dev@dpdk.org Cc: Thomas Monjalon , Randy L Tice Subject: [PATCH v3 1/1] eal: add API to get CPU socket ID Date: Wed, 16 Sep 2026 10:55:16 -0400 Message-Id: <20260916145516.3-2-rtice@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20260916145516.3-1-rtice@cisco.com> References: <20260915150507.3-1-rtice@cisco.com> <20260916145516.3-1-rtice@cisco.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-Client-TLS: ANONYMOUS; rtp-orb-10405.cisco.com [64.100.22.53]; TLSv1.3; TLS_AES_256_GCM_SHA384; 256 X-Outbound-SMTP-Client: 64.100.22.53, rtp-orb-10405.cisco.com X-Outbound-Node: rcdn-l-core-10.cisco.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add experimental rte_cpu_socket_id() so applications can map an OS logical CPU ID to its NUMA socket without requiring an EAL lcore ID. Existing public socket APIs depend on EAL lcore configuration or the calling thread's EAL state. They do not cover code that needs to look up topology by OS CPU ID, such as building socket memory policy. Reuse the existing per-OS EAL CPU socket lookup internally, while keeping the eal_cpu_socket_id() helper private to EAL. Signed-off-by: Randy L Tice --- .mailmap | 1 + doc/guides/rel_notes/release_26_11.rst | 3 +++ lib/eal/common/eal_common_lcore.c | 11 +++++++++++ lib/eal/include/rte_lcore.h | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/.mailmap b/.mailmap index fcb3d1bb3f..2a8b54ea23 100644 --- a/.mailmap +++ b/.mailmap @@ -1379,6 +1379,7 @@ Rakesh Kudurumalla Ralf Hoffmann Rami Rosen Rami Rosen +Randy L Tice Randy Schacher Rani Sharoni Ranjit Menon diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst index 87c7e81bde..b26e9fae88 100644 --- a/doc/guides/rel_notes/release_26_11.rst +++ b/doc/guides/rel_notes/release_26_11.rst @@ -95,6 +95,9 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* eal: Added experimental ``rte_cpu_socket_id()`` to map an OS logical + CPU ID to the NUMA socket containing that CPU. + ABI Changes ----------- diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c index b5f59a6380..1b6d77d8bc 100644 --- a/lib/eal/common/eal_common_lcore.c +++ b/lib/eal/common/eal_common_lcore.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifndef RTE_EXEC_ENV_WINDOWS #include #endif @@ -130,6 +131,16 @@ rte_lcore_to_socket_id(unsigned int lcore_id) return lcore_config[lcore_id].numa_id; } +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_cpu_socket_id, 26.11) +unsigned int +rte_cpu_socket_id(unsigned int cpu_id) +{ + if (eal_cpu_detected(cpu_id) == 0) + return (unsigned int)SOCKET_ID_ANY; + + return eal_cpu_socket_id(cpu_id); +} + static int socket_id_cmp(const void *a, const void *b) { diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 10f965b4f0..696ae9ec95 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -160,6 +160,25 @@ rte_socket_id_by_idx(unsigned int idx); unsigned int rte_lcore_to_socket_id(unsigned int lcore_id); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get the ID of the NUMA node for a CPU. + * + * This function maps an OS logical CPU ID to the NUMA node containing + * that CPU. + * + * @param cpu_id + * The OS logical CPU ID. If cpu_id does not identify a detected CPU, the + * function returns SOCKET_ID_ANY. + * @return + * The ID of cpu_id's NUMA node, or SOCKET_ID_ANY if cpu_id is not valid. + */ +__rte_experimental +unsigned int +rte_cpu_socket_id(unsigned int cpu_id); + /** * Return the id of the lcore on a socket starting from zero. * -- 2.35.6