DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] Does memif support primary<->secondary process communication?
@ 2021-06-09 11:25 Wu, Jianyue (NSB - CN/Hangzhou)
  2021-06-09 12:07 ` Wu, Jianyue (NSB - CN/Hangzhou)
  0 siblings, 1 reply; 14+ messages in thread
From: Wu, Jianyue (NSB - CN/Hangzhou) @ 2021-06-09 11:25 UTC (permalink / raw)
  To: users, dev

Hello,

May I ask a question about memif?
When I'm trying to develop a communication mechanism for two processes, which also need to share memzones between the processes, so need primary<->secondary.
https://doc.dpdk.org/guides/nics/memif.html
But from the guideline, it seems always use primary<->primary. Does it support primary<->secondary? Thanks indeed in advance!

Best Regards,
Dave(Jianyue)


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH] eal/linux: enhanced error handling for affinity
@ 2024-04-23  3:02 Jianyue Wu
  2024-04-24 15:50 ` Stephen Hemminger
  0 siblings, 1 reply; 14+ messages in thread
From: Jianyue Wu @ 2024-04-23  3:02 UTC (permalink / raw)
  Cc: dev, Jianyue Wu

Improve the robustness of setting thread affinity in DPDK
by adding detailed error logging.

Changes:
1. Check the return value of pthread_setaffinity_np() and log an error
if the call fails.
2. Include the current thread name, the intended CPU set, and a detailed
error message in the log.

Sample prints:
EAL: Cannot set affinity for thread dpdk-test with cpus 0,
ret: 22, errno: 0, error description: Success
EAL: Cannot set affinity for thread dpdk-worker1 with cpus 1,
ret: 22, errno: 0, error description: Success

Signed-off-by: Jianyue Wu <wujianyue000@163.com>
---
 lib/eal/unix/rte_thread.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c
index 1b4c73f58e..8f9eaf0dcf 100644
--- a/lib/eal/unix/rte_thread.c
+++ b/lib/eal/unix/rte_thread.c
@@ -369,8 +369,26 @@ int
 rte_thread_set_affinity_by_id(rte_thread_t thread_id,
 		const rte_cpuset_t *cpuset)
 {
-	return pthread_setaffinity_np((pthread_t)thread_id.opaque_id,
-		sizeof(*cpuset), cpuset);
+	int ret;
+	char cpus_str[RTE_CPU_AFFINITY_STR_LEN] = {'\0'};
+	char thread_name[RTE_MAX_THREAD_NAME_LEN] = {'\0'};
+
+	errno = 0;
+	ret = pthread_setaffinity_np((pthread_t)thread_id.opaque_id,
+				sizeof(*cpuset), cpuset);
+	if (ret != 0) {
+		if (pthread_getname_np((pthread_t)thread_id.opaque_id,
+					thread_name, sizeof(thread_name)) != 0)
+			EAL_LOG(ERR, "pthread_getname_np failed!");
+		if (eal_thread_dump_affinity(cpuset, cpus_str, RTE_CPU_AFFINITY_STR_LEN) != 0)
+			EAL_LOG(ERR, "eal_thread_dump_affinity failed!");
+		EAL_LOG(ERR, "Cannot set affinity for thread %s with cpus %s, "
+			"ret: %d, errno: %d, error description: %s",
+			thread_name, cpus_str,
+			ret, errno, strerror(errno));
+	}
+
+	return ret;
 }
 
 int
-- 
2.34.1


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

end of thread, other threads:[~2024-04-26 21:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 11:25 [dpdk-dev] Does memif support primary<->secondary process communication? Wu, Jianyue (NSB - CN/Hangzhou)
2021-06-09 12:07 ` Wu, Jianyue (NSB - CN/Hangzhou)
2024-04-22 13:23   ` [PATCH] eal/linux: enhanced error handling for affinity Jianyue Wu (NSB)
2024-04-22 13:49     ` Ferruh Yigit
2024-04-26 21:31       ` Patrick Robb
2024-04-22 13:50     ` Ferruh Yigit
2024-04-22 15:26     ` Stephen Hemminger
2024-04-22 15:27     ` Stephen Hemminger
2024-04-22 15:30     ` Stephen Hemminger
2024-04-23  3:01     ` Jianyue Wu (NSB)
2024-04-24  5:45     ` [PATCH v2] " Jianyue Wu (NSB)
2024-04-23  3:02 [PATCH] " Jianyue Wu
2024-04-24 15:50 ` Stephen Hemminger
2024-04-25  1:08   ` 吴剑跃
2024-04-25  5:40     ` 吴剑跃
2024-04-25 15:04       ` Stephen Hemminger

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