Skip to contentSkip to conversation

support set thread name

PATCH Superseded Min Hu (Connor) 6 participants 24 messages Apr 10, 2021 – Apr 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover support set thread name

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

 drivers/net/ark/ark_ethdev.c                    |  1 +
 drivers/net/ice/ice_dcf_parent.c                |  5 +++++
 drivers/raw/ifpga/ifpga_rawdev.c                |  1 +
 drivers/vdpa/ifc/ifcvf_vdpa.c                   | 12 ++++++++++++
 examples/performance-thread/pthread_shim/main.c |  5 +++++
 examples/vhost_blk/vhost_blk.c                  |  1 +
 lib/librte_telemetry/telemetry.c                |  3 ++-
 7 files changed, 27 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/7 net/ark: support set thread name

From: Chengwen Feng <[email protected]>

This patch supports set delay packet generator start thread name which is helpful for debugging.

---
 drivers/net/ark/ark_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ark/ark_ethdev.c +1 -0
index 9dea5fa..d62a869 100644
@@ -574,6 +574,7 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
 				    "starter thread\n");
 			return -1;
 		}
+		rte_thread_setname(thread, "ark-delay-pg");
 	}
 
 	if (ark->user_ext.dev_start)
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/7 net/ice: support set VSI reset thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set VSI reset thread name which is helpful for debugging.

---
 drivers/net/ice/ice_dcf_parent.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ice/ice_dcf_parent.c +5 -0
index a8571b3..86aa32b 100644
@@ -151,7 +151,9 @@ ice_dcf_vsi_update_service_handler(void *param)
 static void
 start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
 {
+#define THREAD_NAME_LEN	16
 	struct ice_dcf_reset_event_param *param;
+	char name[THREAD_NAME_LEN];
 	pthread_t thread;
 	int ret;
 
@@ -171,6 +173,9 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
 		PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling");
 		free(param);
 	}
+
+	snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
+	rte_thread_setname(thread, name);
 }
 
 void
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/7 vdpa/ifc: support set notify and vring relay thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set notify and vring relay thread name which is helpful for debugging.

---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/vdpa/ifc/ifcvf_vdpa.c +12 -0
index 39237ae..8a5efa9 100644
@@ -37,6 +37,8 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 #define IFCVF_VDPA_MODE		"vdpa"
 #define IFCVF_SW_FALLBACK_LM	"sw-live-migration"
 
+#define THREAD_NAME_LEN	16
+
 static const char * const ifcvf_valid_arguments[] = {
 	IFCVF_VDPA_MODE,
 	IFCVF_SW_FALLBACK_LM,
@@ -494,6 +496,7 @@ notify_relay(void *arg)
 static int
 setup_notify_relay(struct ifcvf_internal *internal)
 {
+	char name[THREAD_NAME_LEN];
 	int ret;
 
 	ret = pthread_create(&internal->tid, NULL, notify_relay,
@@ -502,6 +505,10 @@ setup_notify_relay(struct ifcvf_internal *internal)
 		DRV_LOG(ERR, "failed to create notify relay pthread.");
 		return -1;
 	}
+
+	snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
+	rte_thread_setname(internal->tid, name);
+
 	return 0;
 }
 
@@ -797,6 +804,7 @@ vring_relay(void *arg)
 static int
 setup_vring_relay(struct ifcvf_internal *internal)
 {
+	char name[THREAD_NAME_LEN];
 	int ret;
 
 	ret = pthread_create(&internal->tid, NULL, vring_relay,
@@ -805,6 +813,10 @@ setup_vring_relay(struct ifcvf_internal *internal)
 		DRV_LOG(ERR, "failed to create ring relay pthread.");
 		return -1;
 	}
+
+	snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
+	rte_thread_setname(internal->tid, name);
+
 	return 0;
 }
 
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/7 raw/ifpga: support set monitor thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set monitor thread name which is helpful for debugging.

---
 drivers/raw/ifpga/ifpga_rawdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/raw/ifpga/ifpga_rawdev.c +1 -0
index 05d79bf..4db6884 100644
@@ -534,6 +534,7 @@ ifpga_monitor_start_func(void)
 				"Fail to create ifpga nonitor thread");
 			return -1;
 		}
+		rte_thread_setname(ifpga_monitor_start_thread, "ifpga-monitor");
 		ifpga_monitor_start = 1;
 	}
 
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/7 examples/performance-thread: support set thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set helloworld thread name which is helpful for debugging.

---
 examples/performance-thread/pthread_shim/main.c | 5 +++++
 1 file changed, 5 insertions(+)
examples/performance-thread/pthread_shim/main.c +5 -0
index 23e3b5e..4ce3622 100644
@@ -27,6 +27,7 @@
 
 #define DEBUG_APP 0
 #define HELLOW_WORLD_MAX_LTHREADS 10
+#define THREAD_NAME_LEN	16
 
 #ifndef __GLIBC__ /* sched_getcpu() is glibc-specific */
 #define sched_getcpu() rte_lcore_id()
@@ -149,6 +150,7 @@ static void *initial_lthread(void *args __rte_unused)
 		 */
 		pthread_attr_t attr;
 		rte_cpuset_t cpuset;
+		char name[THREAD_NAME_LEN];
 
 		CPU_ZERO(&cpuset);
 		CPU_SET(lcore, &cpuset);
@@ -160,6 +162,9 @@ static void *initial_lthread(void *args __rte_unused)
 				helloworld_pthread, (void *) i);
 		if (ret != 0)
 			rte_exit(EXIT_FAILURE, "Cannot create helloworld thread\n");
+
+		snprintf(name, sizeof(name), "helloworld-%u", (uint32_t)i);
+		rte_thread_setname(tid[i], name);
 	}
 
 	/* wait for 1s to allow threads
Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/7 telemetry: support set init threads name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set init threads name which is helpful for debugging.

---
 lib/librte_telemetry/telemetry.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_telemetry/telemetry.c +2 -1
index 7e08afd..8f48337 100644
@@ -442,7 +442,7 @@ telemetry_legacy_init(void)
 		return -1;
 	pthread_create(&t_old, NULL, socket_listener, &v1_socket);
 	pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), thread_cpuset);
-
+	pthread_setname_np(t_old, "telemetry-v1");
 	TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n");
 	return 0;
 }
@@ -471,6 +471,7 @@ telemetry_v2_init(void)
 		return -1;
 	pthread_create(&t_new, NULL, socket_listener, &v2_socket);
 	pthread_setaffinity_np(t_new, sizeof(*thread_cpuset), thread_cpuset);
+	pthread_setname_np(t_new, "telemetry-v2");
 	atexit(unlink_sockets);
 
 	return 0;
Signature · 1 line
2.7.4
#7 lore raw

PATCH 7/7 examples/vhost_blk: support set ctrl worker thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set ctrl worker thread name which is helpful for debugging.

---
 examples/vhost_blk/vhost_blk.c | 1 +
 1 file changed, 1 insertion(+)
examples/vhost_blk/vhost_blk.c +1 -0
index 5c64071..4d24dca 100644
@@ -689,6 +689,7 @@ new_device(int vid)
 		fprintf(stderr, "Worker Thread Started Failed\n");
 		return -1;
 	}
+	rte_thread_setname(tid, "vhostblk-ctrlr");
 
 	/* device has been started */
 	ctrlr->started = 1;
Signature · 1 line
2.7.4
#8 lore raw
In reply to Min Hu (Connor)
Quoted 11 lines · Min Hu (Connor)

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

Rather than add those calls, can maintainers check if their component can use ctrl threads instead?
rte_ctrl_thread_create ensures both that the name is set, and that the ctrl thread won't run on the same cpu as "datapath" threads.

I also saw some issues with components creating threads. I'll post a series addressing those later (net/ark, net/ice not detaching/joining created threads + telemetry not checking pthread_create failures).

Signature · 1 line
David Marchand
#9 lore raw
Quoted 26 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday 12 April 2021 08:20
To: Min Hu (Connor) <[email protected]>; Shepard Siegel <[email protected]>; Yang, Qiming <[email protected]>; Wang, Xiao W <[email protected]>; Xu, Rosen <[email protected]>; Maxime Coquelin <[email protected]>
Cc: dev <[email protected]>; Yigit, Ferruh <[email protected]>; Mcnamara, John <[email protected]>; Power, Ciara <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/7] support set thread name

Quoted 11 lines · Min Hu (Connor)

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

Quoted 10 lines

Rather than add those calls, can maintainers check if their component can use ctrl threads instead?
rte_ctrl_thread_create ensures both that the name is set, and that the ctrl thread won't run on the same cpu as "datapath" threads.

I also saw some issues with components creating threads.
I'll post a series addressing those later (net/ark, net/ice not detaching/joining created threads + telemetry not checking pthread_create failures).

Hi David,

Telemetry has no dependency on EAL, so using the ctrl thread functions isn't possible for that component.

Thanks,
Ciara

Quoted 2 lines

--
David Marchand

#10 lore raw
In reply to David Marchand
Quoted 18 lines · David Marchand
Quoted 11 lines · Min Hu (Connor)

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

Rather than add those calls, can maintainers check if their component can use ctrl threads instead?
rte_ctrl_thread_create ensures both that the name is set, and that the ctrl thread won't run on the same cpu as "datapath" threads.

Quoted 5 lines

I also saw some issues with components creating threads. I'll post a series addressing those later (net/ark, net/ice not detaching/joining created threads + telemetry not checking pthread_create failures).

Totally agree with David.
By the way, for "telemetry not checking pthread_create failures", I have sent patches to fix it. Please check it out.
Thanks.

Quoted 1 line
#11 lore raw

13/04/2021 03:12, Min Hu (Connor):

Quoted 24 lines · David Marchand
Quoted 18 lines · Min Hu (Connor)
Quoted 11 lines

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

Rather than add those calls, can maintainers check if their component can use ctrl threads instead?
rte_ctrl_thread_create ensures both that the name is set, and that the ctrl thread won't run on the same cpu as "datapath" threads.

Quoted 5 lines

I also saw some issues with components creating threads. I'll post a series addressing those later (net/ark, net/ice not detaching/joining created threads + telemetry not checking pthread_create failures).

Quoted 4 lines

Totally agree with David.
By the way, for "telemetry not checking pthread_create failures", I have sent patches to fix it. Please check it out.
Thanks.

Do I understand correctly that we prefer switching to rte_ctrl_thread_create() instead of this patch series adding rte_thread_setname()?

Any volunteer to add the use of rte_ctrl_thread_create() in these drivers and examples?

#12 lore raw
Quoted 30 lines · Thomas Monjalon

13/04/2021 03:12, Min Hu (Connor):

Quoted 24 lines · David Marchand
Quoted 18 lines · Min Hu (Connor)
Quoted 11 lines

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

Rather than add those calls, can maintainers check if their component can use ctrl threads instead?
rte_ctrl_thread_create ensures both that the name is set, and that the ctrl thread won't run on the same cpu as "datapath" threads.

Quoted 5 lines

I also saw some issues with components creating threads. I'll post a series addressing those later (net/ark, net/ice not detaching/joining created threads + telemetry not checking pthread_create failures).

Quoted 4 lines

Totally agree with David.
By the way, for "telemetry not checking pthread_create failures", I have sent patches to fix it. Please check it out.
Thanks.

Quoted 7 lines

Do I understand correctly that we prefer switching to rte_ctrl_thread_create() instead of this patch series adding rte_thread_setname()?

Any volunteer to add the use of rte_ctrl_thread_create() in these drivers and examples?

Hi, Thomos, we will send next patch to fix it, thanks.

Quoted 3 lines

.

#13 lore raw
In reply to David Marchand
Quoted 18 lines · David Marchand
Quoted 11 lines · Min Hu (Connor)

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name

Rather than add those calls, can maintainers check if their component can use ctrl threads instead?
rte_ctrl_thread_create ensures both that the name is set, and that the ctrl thread won't run on the same cpu as "datapath" threads.

Quoted 6 lines

I also saw some issues with components creating threads. I'll post a series addressing those later (net/ark, net/ice not detaching/joining created threads + telemetry not checking pthread_create failures).

There already have reviewing patches:
([dpdk-dev] [PATCH v2 0/2] fix missing check for thread creation) to fix telemetry not checking pthread_create failure.

Please review it, thanks

#14 lore raw

v2 cover support set thread name

In reply to Min Hu (Connor)

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name
vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name
---
v2:
* change 'pthread_create' to 'rte_ctrl_thread_create' except two:
'examples/performance-thread', because special CPU affinity needs to be set, the ctrl interface cannot be used to set the affinity. 'telemetry', telemetry is an independent lib and does not depend on EAL.

 drivers/net/ark/ark_ethdev.c                    |  4 ++--
 drivers/net/ice/ice_dcf_parent.c                |  9 ++++++---
 drivers/raw/ifpga/ifpga_rawdev.c                |  8 ++++----
 drivers/vdpa/ifc/ifcvf_vdpa.c                   | 20 ++++++++++++++------
 examples/performance-thread/pthread_shim/main.c |  5 +++++
 examples/vhost_blk/vhost_blk.c                  |  3 ++-
 lib/librte_telemetry/telemetry.c                |  3 ++-
 7 files changed, 35 insertions(+), 17 deletions(-)
Signature · 1 line
2.7.4
#15 lore raw

PATCH v2 1/7 net/ark: support set thread name

From: Chengwen Feng <[email protected]>

This patch supports set delay packet generator start thread name which is helpful for debugging.

---
 drivers/net/ark/ark_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ark/ark_ethdev.c +2 -2
index 9dea5fa..6372cf7 100644
@@ -568,8 +568,8 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
 		/* Delay packet generatpr start allow the hardware to be ready
 		 * This is only used for sanity checking with internal generator
 		 */
-		if (pthread_create(&thread, NULL,
-				   ark_pktgen_delay_start, ark->pg)) {
+		if (rte_ctrl_thread_create(&thread, "ark-delay-pg", NULL,
+					   ark_pktgen_delay_start, ark) != 0) {
 			ARK_PMD_LOG(ERR, "Could not create pktgen "
 				    "starter thread\n");
 			return -1;
Signature · 1 line
2.7.4
#16 lore raw

PATCH v2 2/7 net/ice: support set VSI reset thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set VSI reset thread name which is helpful for debugging.

---
 drivers/net/ice/ice_dcf_parent.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ice/ice_dcf_parent.c +6 -3
index a8571b3..c8e4332 100644
@@ -151,7 +151,9 @@ ice_dcf_vsi_update_service_handler(void *param)
 static void
 start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
 {
+#define THREAD_NAME_LEN	16
 	struct ice_dcf_reset_event_param *param;
+	char name[THREAD_NAME_LEN];
 	pthread_t thread;
 	int ret;
 
@@ -165,9 +167,10 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
 	param->vfr = vfr;
 	param->vf_id = vf_id;
 
-	ret = pthread_create(&thread, NULL,
-			     ice_dcf_vsi_update_service_handler, param);
-	if (ret) {
+	snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
+	ret = rte_ctrl_thread_create(&thread, name, NULL,
+				     ice_dcf_vsi_update_service_handler, param);
+	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling");
 		free(param);
 	}
Signature · 1 line
2.7.4
#17 lore raw

PATCH v2 3/7 vdpa/ifc: support set notify and vring relay thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set notify and vring relay thread name which is helpful for debugging.

---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/vdpa/ifc/ifcvf_vdpa.c +14 -6
index 7a06f97..1dc813d 100644
@@ -37,6 +37,8 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.vdpa.ifcvf, NOTICE);
 #define IFCVF_VDPA_MODE		"vdpa"
 #define IFCVF_SW_FALLBACK_LM	"sw-live-migration"
 
+#define THREAD_NAME_LEN	16
+
 static const char * const ifcvf_valid_arguments[] = {
 	IFCVF_VDPA_MODE,
 	IFCVF_SW_FALLBACK_LM,
@@ -494,14 +496,17 @@ notify_relay(void *arg)
 static int
 setup_notify_relay(struct ifcvf_internal *internal)
 {
+	char name[THREAD_NAME_LEN];
 	int ret;
 
-	ret = pthread_create(&internal->tid, NULL, notify_relay,
-			(void *)internal);
-	if (ret) {
+	snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
+	ret = rte_ctrl_thread_create(&internal->tid, name, NULL, notify_relay,
+				     (void *)internal);
+	if (ret != 0) {
 		DRV_LOG(ERR, "failed to create notify relay pthread.");
 		return -1;
 	}
+
 	return 0;
 }
 
@@ -797,14 +802,17 @@ vring_relay(void *arg)
 static int
 setup_vring_relay(struct ifcvf_internal *internal)
 {
+	char name[THREAD_NAME_LEN];
 	int ret;
 
-	ret = pthread_create(&internal->tid, NULL, vring_relay,
-			(void *)internal);
-	if (ret) {
+	snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
+	ret = rte_ctrl_thread_create(&internal->tid, name, NULL, vring_relay,
+				     (void *)internal);
+	if (ret != 0) {
 		DRV_LOG(ERR, "failed to create ring relay pthread.");
 		return -1;
 	}
+
 	return 0;
 }
 
Signature · 1 line
2.7.4
#18 lore raw

PATCH v2 4/7 raw/ifpga: support set monitor thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set monitor thread name which is helpful for debugging.

---
 drivers/raw/ifpga/ifpga_rawdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/raw/ifpga/ifpga_rawdev.c +4 -4
index d9a46ef..f2551be 100644
@@ -526,10 +526,10 @@ ifpga_monitor_start_func(void)
 	int ret;
 
 	if (ifpga_monitor_start == 0) {
-		ret = pthread_create(&ifpga_monitor_start_thread,
-			NULL,
-			ifpga_rawdev_gsd_handle, NULL);
-		if (ret) {
+		ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread,
+					     "ifpga-monitor", NULL,
+					     ifpga_rawdev_gsd_handle, NULL);
+		if (ret != 0) {
 			IFPGA_RAWDEV_PMD_ERR(
 				"Fail to create ifpga nonitor thread");
 			return -1;
Signature · 1 line
2.7.4
#19 lore raw

PATCH v2 5/7 examples/performance-thread: support set thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set helloworld thread name which is helpful for debugging.

---
 examples/performance-thread/pthread_shim/main.c | 5 +++++
 1 file changed, 5 insertions(+)
examples/performance-thread/pthread_shim/main.c +5 -0
index 23e3b5e..4ce3622 100644
@@ -27,6 +27,7 @@
 
 #define DEBUG_APP 0
 #define HELLOW_WORLD_MAX_LTHREADS 10
+#define THREAD_NAME_LEN	16
 
 #ifndef __GLIBC__ /* sched_getcpu() is glibc-specific */
 #define sched_getcpu() rte_lcore_id()
@@ -149,6 +150,7 @@ static void *initial_lthread(void *args __rte_unused)
 		 */
 		pthread_attr_t attr;
 		rte_cpuset_t cpuset;
+		char name[THREAD_NAME_LEN];
 
 		CPU_ZERO(&cpuset);
 		CPU_SET(lcore, &cpuset);
@@ -160,6 +162,9 @@ static void *initial_lthread(void *args __rte_unused)
 				helloworld_pthread, (void *) i);
 		if (ret != 0)
 			rte_exit(EXIT_FAILURE, "Cannot create helloworld thread\n");
+
+		snprintf(name, sizeof(name), "helloworld-%u", (uint32_t)i);
+		rte_thread_setname(tid[i], name);
 	}
 
 	/* wait for 1s to allow threads
Signature · 1 line
2.7.4
#20 lore raw

PATCH v2 6/7 telemetry: support set init threads name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set init threads name which is helpful for debugging.

---
 lib/librte_telemetry/telemetry.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_telemetry/telemetry.c +2 -1
index 7e08afd..8f48337 100644
@@ -442,7 +442,7 @@ telemetry_legacy_init(void)
 		return -1;
 	pthread_create(&t_old, NULL, socket_listener, &v1_socket);
 	pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), thread_cpuset);
-
+	pthread_setname_np(t_old, "telemetry-v1");
 	TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n");
 	return 0;
 }
@@ -471,6 +471,7 @@ telemetry_v2_init(void)
 		return -1;
 	pthread_create(&t_new, NULL, socket_listener, &v2_socket);
 	pthread_setaffinity_np(t_new, sizeof(*thread_cpuset), thread_cpuset);
+	pthread_setname_np(t_new, "telemetry-v2");
 	atexit(unlink_sockets);
 
 	return 0;
Signature · 1 line
2.7.4
#22 lore raw

PATCH v2 7/7 examples/vhost_blk: support set ctrl worker thread name

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch supports set ctrl worker thread name which is helpful for debugging.

---
 examples/vhost_blk/vhost_blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
examples/vhost_blk/vhost_blk.c +2 -1
index 5c64071..54f81b3 100644
@@ -685,7 +685,8 @@ new_device(int vid)
 	/* start polling vring */
 	worker_thread_status = WORKER_STATE_START;
 	fprintf(stdout, "New Device %s, Device ID %d\n", path, vid);
-	if (pthread_create(&tid, NULL, &ctrlr_worker, ctrlr) < 0) {
+	if (rte_ctrl_thread_create(&tid, "vhostblk-ctrlr", NULL,
+				   &ctrlr_worker, ctrlr) != 0) {
 		fprintf(stderr, "Worker Thread Started Failed\n");
 		return -1;
 	}
Signature · 1 line
2.7.4
#23 lore raw
In reply to Min Hu (Connor)

17/04/2021 11:09, Min Hu (Connor):

Quoted 17 lines

This set of patches support set thread name for debugging.

Chengwen Feng (7):
net/ark: support set thread name
net/ice: support set VSI reset thread name
vdpa/ifc: support set notify and vring relay thread name raw/ifpga: support set monitor thread name examples/performance-thread: support set thread name
telemetry: support set init threads name examples/vhost_blk: support set ctrl worker thread name
---
v2:
* change 'pthread_create' to 'rte_ctrl_thread_create' except two:
'examples/performance-thread', because special CPU affinity needs to be set, the ctrl interface cannot be used to set the affinity. 'telemetry', telemetry is an independent lib and does not depend on EAL.

Applied, thanks