From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9A880A04C1; Mon, 10 Aug 2020 11:37:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F1FDF3195; Mon, 10 Aug 2020 11:37:21 +0200 (CEST) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by dpdk.org (Postfix) with ESMTP id ED8792986 for ; Mon, 10 Aug 2020 11:37:19 +0200 (CEST) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id B8C634001A for ; Mon, 10 Aug 2020 11:37:17 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id A3CB44000F; Mon, 10 Aug 2020 11:37:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on bernadotte.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.2 X-Spam-Score: -1.0 Received: from isengard.friendlyfire.se (host-95-192-203-127.mobileonline.telia.com [95.192.203.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 2BC3C40005; Mon, 10 Aug 2020 11:37:13 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: Ray Kinsella , Neil Horman Cc: dev@dpdk.org, tomasz.piatkowski@ericsson.com, nd@arm.com, stephen@networkplumber.org, Honnappa.Nagarahalli@arm.com, harry.van.haaren@intel.com, =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Mon, 10 Aug 2020 11:36:52 +0200 Message-Id: <20200810093652.102078-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <8df56fc2-781a-a2dd-c8b8-87696299b921@ericsson.com> References: <8df56fc2-781a-a2dd-c8b8-87696299b921@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [RFC] eal: introduce function to get lcore thread id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Introduce function in to retrieve a lcore worker thread's pthread id. This change allows applications to do things like changing the name of a lcore thread, or detect if it's getting interrupted (e.g. getting preempted by another thread). Signed-off-by: Mattias Rönnblom --- lib/librte_eal/common/eal_common_thread.c | 8 ++++++++ lib/librte_eal/include/rte_lcore.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 3 +++ 3 files changed, 25 insertions(+) diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c index 73a055902..6233aef11 100644 --- a/lib/librte_eal/common/eal_common_thread.c +++ b/lib/librte_eal/common/eal_common_thread.c @@ -294,3 +294,11 @@ rte_thread_unregister(void) RTE_LOG(DEBUG, EAL, "Unregistered non-EAL thread (was lcore %u).\n", lcore_id); } + +int rte_lcore_thread_id(unsigned int lcore_id, pthread_t *id) +{ + if (lcore_id >= RTE_MAX_LCORE) + return -1; + *id = lcore_config[lcore_id].thread_id; + return 0; +} diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h index b8b64a625..dae8d11ca 100644 --- a/lib/librte_eal/include/rte_lcore.h +++ b/lib/librte_eal/include/rte_lcore.h @@ -363,6 +363,20 @@ int rte_thread_set_affinity(rte_cpuset_t *cpusetp); */ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); +/** + * Get the thread id of a lcore worker thread. + * + * @param lcore_id + * The identifier of the lcore, which MUST be between 0 and RTE_MAX_LCORE-1. + * @param[out] id + * A pointer that will be filled in with the lcore worker thread's POSIX + * thread id, on success. + * @return + * On success, return 0; otherwise return a negative value. + */ +__rte_experimental +int rte_lcore_thread_id(unsigned int lcore_id, pthread_t *id); + /** * Set thread names. * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index bf0c17c23..571aacd17 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -403,6 +403,9 @@ EXPERIMENTAL { rte_mp_disable; rte_thread_register; rte_thread_unregister; + + # added in 20.11 + rte_lcore_thread_id; }; INTERNAL { -- 2.25.1