From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, Jianfeng Tan <jianfeng.tan@intel.com>,
Olivier Matz <olivier.matz@6wind.com>,
Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH] eal: fix threads block on barrier
Date: Fri, 27 Apr 2018 16:41:42 +0000 [thread overview]
Message-ID: <1524847302-88110-1-git-send-email-jianfeng.tan@intel.com> (raw)
Below commit introduced pthread barrier for synchronization.
But two IPC threads block on the barrier, and never wake up.
(gdb) bt
#0 futex_wait (private=0, expected=0, futex_word=0x7fffffffcff4)
at ../sysdeps/unix/sysv/linux/futex-internal.h:61
#1 futex_wait_simple (private=0, expected=0, futex_word=0x7fffffffcff4)
at ../sysdeps/nptl/futex-internal.h:135
#2 __pthread_barrier_wait (barrier=0x7fffffffcff0) at pthread_barrier_wait.c:184
#3 rte_thread_init (arg=0x7fffffffcfe0)
at ../dpdk/lib/librte_eal/common/eal_common_thread.c:160
#4 start_thread (arg=0x7ffff6ecf700) at pthread_create.c:333
#5 clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
Through analysis, we find the barrier defined on the stack could be the
root cause. This patch will change to use heap memory as the barrier.
Fixes: d651ee4919cd ("eal: set affinity for control threads")
Cc: Olivier Matz <olivier.matz@6wind.com>
Cc: Anatoly Burakov <anatoly.burakov@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
lib/librte_eal/common/eal_common_thread.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c
index 4e75cb8..da2b84f 100644
--- a/lib/librte_eal/common/eal_common_thread.c
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -166,17 +166,21 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
- struct rte_thread_ctrl_params params = {
- .start_routine = start_routine,
- .arg = arg,
- };
+ struct rte_thread_ctrl_params *params;
unsigned int lcore_id;
rte_cpuset_t cpuset;
int cpu_found, ret;
- pthread_barrier_init(¶ms.configured, NULL, 2);
+ params = malloc(sizeof(*params));
+ if (!params)
+ return -1;
+
+ params->start_routine = start_routine;
+ params->arg = arg;
- ret = pthread_create(thread, attr, rte_thread_init, (void *)¶ms);
+ pthread_barrier_init(¶ms->configured, NULL, 2);
+
+ ret = pthread_create(thread, attr, rte_thread_init, (void *)params);
if (ret != 0)
return ret;
@@ -203,12 +207,14 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
if (ret < 0)
goto fail;
- pthread_barrier_wait(¶ms.configured);
+ pthread_barrier_wait(¶ms->configured);
+ free(params);
return 0;
fail:
pthread_cancel(*thread);
pthread_join(*thread, NULL);
+ free(params);
return ret;
}
--
2.7.4
next reply other threads:[~2018-04-27 16:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-27 16:41 Jianfeng Tan [this message]
2018-04-27 16:42 ` Thomas Monjalon
2018-04-27 17:03 ` Stephen Hemminger
2018-04-27 17:36 ` Shreyansh Jain
2018-04-27 17:39 ` Stephen Hemminger
2018-04-27 17:45 ` Shreyansh Jain
2018-04-27 19:52 ` Thomas Monjalon
2018-04-28 1:21 ` Stephen Hemminger
2018-04-28 4:15 ` Tan, Jianfeng
2018-04-28 1:24 ` Stephen Hemminger
2018-04-28 4:22 ` Tan, Jianfeng
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=1524847302-88110-1-git-send-email-jianfeng.tan@intel.com \
--to=jianfeng.tan@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
--cc=thomas@monjalon.net \
/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).