From: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
To: Ray Kinsella <mdr@ashroe.eu>, Neil Horman <nhorman@tuxdriver.com>
Cc: dev@dpdk.org, tomasz.piatkowski@ericsson.com, nd@arm.com,
stephen@networkplumber.org, Honnappa.Nagarahalli@arm.com,
harry.van.haaren@intel.com,
"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: [dpdk-dev] [RFC] eal: introduce function to get lcore thread id
Date: Mon, 10 Aug 2020 11:36:52 +0200 [thread overview]
Message-ID: <20200810093652.102078-1-mattias.ronnblom@ericsson.com> (raw)
In-Reply-To: <8df56fc2-781a-a2dd-c8b8-87696299b921@ericsson.com>
Introduce function in <rte_lcore.h> 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 <mattias.ronnblom@ericsson.com>
---
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
next prev parent reply other threads:[~2020-08-10 9:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 12:03 [dpdk-dev] Retrieving lcore worker " Mattias Rönnblom
2020-07-14 13:08 ` Van Haaren, Harry
2020-07-14 18:59 ` Honnappa Nagarahalli
2020-07-14 20:51 ` Stephen Hemminger
2020-07-15 10:17 ` Mattias Rönnblom
2020-07-15 16:21 ` Stephen Hemminger
2020-07-16 10:20 ` Mattias Rönnblom
2020-08-10 9:36 ` Mattias Rönnblom [this message]
2020-10-20 13:38 ` [dpdk-dev] [RFC] eal: introduce function to get lcore " David Marchand
2020-10-20 18:40 ` Mattias Rönnblom
2020-07-15 10:21 ` [dpdk-dev] Retrieving lcore worker " Mattias Rönnblom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200810093652.102078-1-mattias.ronnblom@ericsson.com \
--to=mattias.ronnblom@ericsson.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=mdr@ashroe.eu \
--cc=nd@arm.com \
--cc=nhorman@tuxdriver.com \
--cc=stephen@networkplumber.org \
--cc=tomasz.piatkowski@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).