DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] eal: expose lcore pthread id
@ 2022-10-14  6:20 Markus Theil
  2022-10-14  6:21 ` [PATCH 2/2] eal: prevent OOB read in rte_lcore_to_socket_id Markus Theil
  2022-10-14  7:54 ` [PATCH v2 1/2] eal: expose lcore pthread id Markus Theil
  0 siblings, 2 replies; 11+ messages in thread
From: Markus Theil @ 2022-10-14  6:20 UTC (permalink / raw)
  To: dev; +Cc: Michael Pfeiffer

From: Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>

Also expose the pthread id of each lcore, in
order to allow modification of pthread attributes,
for example use rte_thread_setname without executing
pthread_self() on the maybe already running lcore.

The rte_lcore_to_thread_id function is added to API.

Signed-off-by: Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>
---
 lib/eal/common/eal_common_lcore.c |  9 +++++++++
 lib/eal/include/rte_lcore.h       | 14 ++++++++++++++
 lib/eal/version.map               |  1 +
 3 files changed, 24 insertions(+)

diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c
index 06c594b022..48c333cff1 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -114,6 +114,15 @@ rte_lcore_to_socket_id(unsigned int lcore_id)
 	return lcore_config[lcore_id].socket_id;
 }
 
+int
+rte_lcore_to_thread_id(int lcore_id, pthread_t *thread_id) {
+	if (unlikely(lcore_id < 0 || lcore_id >= RTE_MAX_LCORE))
+		return -1;
+
+	*thread_id = lcore_config[lcore_id].thread_id;
+	return 0;
+}
+
 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 4d3978512c..3ccd0a73b9 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -171,6 +171,20 @@ rte_lcore_to_socket_id(unsigned int lcore_id);
  */
 int rte_lcore_to_cpu_id(int lcore_id);
 
+/**
+ * Get the ID of the thread of the specified lcore
+ *
+ * @param lcore_id
+ *   the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1.
+ * @param thread_id
+ *   the thread id is returned in this argument if lcore_id is in range
+ * @return
+ *   0 on success, or -1 if out of range
+ */
+__rte_experimental
+int
+rte_lcore_to_thread_id(int lcore_id, pthread_t *thread_id);
+
 #ifdef RTE_HAS_CPUSET
 
 /**
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 2d64a2592e..2e57242920 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -440,6 +440,7 @@ EXPERIMENTAL {
 	rte_thread_detach;
 	rte_thread_equal;
 	rte_thread_join;
+	rte_lcore_to_thread_id;
 };
 
 INTERNAL {
-- 
2.38.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-06  5:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14  6:20 [PATCH 1/2] eal: expose lcore pthread id Markus Theil
2022-10-14  6:21 ` [PATCH 2/2] eal: prevent OOB read in rte_lcore_to_socket_id Markus Theil
2022-10-14  7:54 ` [PATCH v2 1/2] eal: expose lcore pthread id Markus Theil
2022-10-14  7:54   ` [PATCH v2 2/2] eal: prevent OOB read in rte_lcore_to_socket_id Markus Theil
2022-10-20 11:20   ` [PATCH v2 1/2] eal: expose lcore pthread id David Marchand
2022-10-20 15:36     ` Stephen Hemminger
2022-10-20 20:03       ` Michael Pfeiffer
2022-11-29 22:04         ` Tyler Retzlaff
2023-07-06  2:57           ` Stephen Hemminger
2023-07-06  5:50             ` Michael Pfeiffer
2022-11-12  0:34       ` Tyler Retzlaff

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).