Does memif support primary<->secondary process communication?
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)
BTW, I use it for primary and secondary communication, so that will use memif to share data between primary and secondary. Thanks.
Best Regards,
Dave(Jianyue)
From: Wu, Jianyue (NSB - CN/Hangzhou)
Sent: 2021年6月9日 19:26
To: [email protected]; '[email protected]' <[email protected]>
Subject: Does memif support primary<->secondary process communication?
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)
PATCH 1/1 eal/linux: enhanced error handling for affinity
Hello,
Good day~
I hope this message finds you well. I am writing to submit a patch for consideration, which primarily adds enhanced error handling for affinity sets within the eal/linux of DPDK. Unfortunately, my current environment does not support git send-email, so I am sending this patch attached to this email.
Thank you~
Best regards,
Dave
From 89d879f762dc5e6901fc6cde06b8c36b641424de Mon Sep 17 00:00:00 2001
From: Jianyue Wu <[email protected]>
Date: Fri, 19 Apr 2024 13:57:35 +0300
Subject: [PATCH] eal/linux: enhanced error handling for affinity
Improve the robustness of setting thread affinity in DPDK by adding detailed error logging.
Changes:
1. Set errno to 0 before calling pthread_setaffinity_np() to ensure clean error status.
2. Check the return value of pthread_setaffinity_np() and log an error if the call fails.
3. 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
--- lib/eal/unix/rte_thread.c | 51 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-)
lib/eal/unix/rte_thread.c +49 -2
@@ -5,6 +5,7 @@#include <errno.h> #include <pthread.h> +#include <sched.h> #include <stdbool.h> #include <stdlib.h> #include <string.h>
@@ -114,6 +115,35 @@ thread_start_wrapper(void *arg)return (void *)(uintptr_t )thread_func (thread_args); } +/* Function to convert cpu_set_t to a string. */ +static void cpuset_to_string (const cpu_set_t *cpuset, +char *cpus_str,size_t cpus_str_size) { +int cpu; +// Track the current position in the string +size_t offset =0 ; + +// Clear the string buffer +memset (cpus_str,0 , cpus_str_size); + cpus_str_size =RTE_MAX_LCORE < cpus_str_size ? +RTE_MAX_LCORE : cpus_str_size; + +// Iterate over each CPU core, and check if it is included in the set +for (cpu =0 ; cpu <RTE_MAX_LCORE && offset < cpus_str_size -1 ; ++cpu) { +if (CPU_ISSET (cpu, cpuset)) { +// Append the current CPU number to the string +int written =snprintf (cpus_str + offset, cpus_str_size - offset, +"%s%d" , (offset >0 ?"," :"" ), cpu); +if (written >0 ) + offset += written; +if (offset >= cpus_str_size -1 ) +break ; + } + } + +// Ensure the string is properly terminated + cpus_str[cpus_str_size -1 ] ='\0' ; +} + int rte_thread_create(rte_thread_t *thread_id, const rte_thread_attr_t *thread_attr,
@@ -369,8 +399,25 @@ 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_MAX_LCORE +1 ] = {'\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!" ); +cpuset_to_string (cpuset, cpus_str,sizeof (cpus_str)); +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
Signature · 1 line
2.42.0
PATCH 1/1 eal/linux: enhanced error handling for affinity
From: Jianyue Wu <[email protected]>
Improve the robustness of setting thread affinity in DPDK by adding detailed error logging.
Changes:
1. Set errno to 0 before calling pthread_setaffinity_np() to ensure clean error status.
2. Check the return value of pthread_setaffinity_np() and log an error if the call fails.
3. 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
--- .mailmap | 1 + lib/eal/unix/rte_thread.c | 51 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-)
.mailmap +1 -0
@@ -639,6 +639,7 @@ Jianfeng Tan <[email protected]> Jiangu Zhao <[email protected]> Jianwei Ma <[email protected]> Jianwei Mei <[email protected]> +Jianyue Wu <[email protected]> Jiaqi Min <[email protected]> Jiawei Wang <[email protected]> <[email protected]> Jiawei Zhu <[email protected]>
lib/eal/unix/rte_thread.c +49 -2
69 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH] eal/linux: enhanced error handling for affinity
Recheck-request: iol-compile-amd64-testing
The DPDK Community Lab updated to the latest Alpine image yesterday, which resulted in all Alpine builds failing. The failure is unrelated to your patch, and this recheck should remove the fail on Patchwork, as we have disabled Alpine testing for now.
Re: [PATCH] eal/linux: enhanced error handling for affinity
In reply to Jianyue Wu (NSB)Quoted 4 lines · Jianyue Wu (NSB)
Hello,
Quoted 8 lines
Good day~
I hope this message finds you well. I am writing to submit a patch for consideration, which primarily adds enhanced error handling for affinity sets within the eal/linux of DPDK. Unfortunately, my current environment does not support git send-email, so I am sending this patch attached to this email.
Thanks Dave, I sent the patch for you, you can follow the CI test results from patchwork link:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Re: [PATCH] eal/linux: enhanced error handling for affinity
In reply to Jianyue Wu (NSB)lib/eal/unix/rte_thread.c thread_start_wrapper(void *arg) · line 122
Quoted 5 lines · On Mon, 22 Apr 2024 13:23:50 +0000 "Jianyue Wu (NSB)"…
lib/eal/unix/rte_thread.c +5
-0+/* Function to convert cpu_set_t to a string. */ +static void cpuset_to_string (const cpu_set_t *cpuset, +char *cpus_str,size_t cpus_str_size) { +int cpu; +// Track the current position in the string
DPDK does not use C++ style comments.
All patches should match the style of existing code.
Re: [PATCH] eal/linux: enhanced error handling for affinity
In reply to Jianyue Wu (NSB)lib/eal/unix/rte_thread.c int · line 405
Quoted 3 lines · On Mon, 22 Apr 2024 13:23:50 +0000 "Jianyue Wu (NSB)"…
lib/eal/unix/rte_thread.c +3
-0+char cpus_str[RTE_MAX_LCORE +1 ] = {'\0' }; +char thread_name[RTE_MAX_THREAD_NAME_LEN ] = {'\0' }; +
You don't need '\0' here, just doing { } will have same effect.
Re: [PATCH] eal/linux: enhanced error handling for affinity
In reply to Jianyue Wu (NSB)lib/eal/unix/rte_thread.c int · line 418
Quoted 5 lines · On Mon, 22 Apr 2024 13:23:50 +0000 "Jianyue Wu (NSB)"…
lib/eal/unix/rte_thread.c +5
-0+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)); + }
That error message is way too long, and error strings should not be broken across lines.
"Set affinity thread %s to %s failed: %s"
And it is a lot effort to deduce the cpuset and thread name here. Probably better to just move the error message back to the caller.
RE: [PATCH] eal/linux: enhanced error handling for affinity
In reply to Jianyue Wu (NSB)Hello,
Please disregard this email; I will use a different mailbox instead.
Thank you~
Best regards,
Dave
From: Jianyue Wu (NSB)
Sent: 2024年4月22日 21:24
To: '[email protected]' <[email protected]>; '[email protected]' <[email protected]>; '[email protected]' <[email protected]>
Cc: '[email protected]' <[email protected]>
Subject: [PATCH] eal/linux: enhanced error handling for affinity
Hello,
Good day~
I hope this message finds you well. I am writing to submit a patch for consideration, which primarily adds enhanced error handling for affinity sets within the eal/linux of DPDK. Unfortunately, my current environment does not support git send-email, so I am sending this patch attached to this email.
Thank you~
Best regards,
Dave
RE: [PATCH v2] eal/linux: enhanced error handling for affinity
In reply to Jianyue Wu (NSB)Hello,
I've noticed some coding style issues eal/linux: enhanced error handling for affinity - Patchwork (dpdk.org)<https://patches.dpdk.org/project/dpdk/patch/[email protected]/> and have attempted to update the patch accordingly. Could you please help by updating it with version 2 of the patch? Thank you very much! 😊
Thank you~
Best regards,
Dave
From: Jianyue Wu (NSB)
Sent: 2024年4月22日 21:24
To: '[email protected]' <[email protected]>; '[email protected]' <[email protected]>; '[email protected]' <[email protected]>
Cc: '[email protected]' <[email protected]>
Subject: [PATCH] eal/linux: enhanced error handling for affinity
Hello,
Good day~
I hope this message finds you well. I am writing to submit a patch for consideration, which primarily adds enhanced error handling for affinity sets within the eal/linux of DPDK. Unfortunately, my current environment does not support git send-email, so I am sending this patch attached to this email.
Thank you~
Best regards,
Dave
From bc7ed0f08373b0159a5990511f15312815bf36bd Mon Sep 17 00:00:00 2001
From: Jianyue Wu <[email protected]>
Date: Fri, 19 Apr 2024 13:57:35 +0300
Subject: [PATCH v2] eal/linux: enhanced error handling for affinity
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
--- lib/eal/unix/rte_thread.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
lib/eal/unix/rte_thread.c +20 -2
@@ -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
Signature · 1 line
2.34.1