From: Ruifeng Wang <ruifeng.wang@arm.com>
To: honnappa.nagarahalli@arm.com
Cc: dev@dpdk.org, gavin.hu@arm.com, nd@arm.com,
Ruifeng Wang <ruifeng.wang@arm.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH] lib/rcu: fix possible spurious thread unregister
Date: Mon, 9 Sep 2019 21:51:42 +0800 [thread overview]
Message-ID: <20190909135142.3510-1-ruifeng.wang@arm.com> (raw)
Thread unregister returns success while unregister not been performed.
This is due to incorrect thread registration status check.
Fix this issue by correcting bitmap check.
Fixes: 64994b56cfd7 ("rcu: add RCU library supporting QSBR mechanism")
Cc: stable@dpdk.org
Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
---
lib/librte_rcu/rte_rcu_qsbr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c
index ce7f93dd3..8c37c88cd 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.c
+++ b/lib/librte_rcu/rte_rcu_qsbr.c
@@ -158,7 +158,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id)
/* Check if the thread is already unregistered */
old_bmap = __atomic_load_n(__RTE_QSBR_THRID_ARRAY_ELM(v, i),
__ATOMIC_RELAXED);
- if (old_bmap & ~(1UL << id))
+ if (!(old_bmap & (1UL << id)))
return 0;
do {
@@ -175,7 +175,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id)
if (success)
__atomic_fetch_sub(&v->num_threads,
1, __ATOMIC_RELAXED);
- else if (old_bmap & ~(1UL << id))
+ else if (!(old_bmap & (1UL << id)))
/* Someone else unregistered this thread.
* Counter should not be incremented.
*/
--
2.17.1
next reply other threads:[~2019-09-09 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-09 13:51 Ruifeng Wang [this message]
2019-09-13 4:17 ` Honnappa Nagarahalli
2019-09-25 8:01 ` David Marchand
2019-10-18 4:11 ` David Marchand
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=20190909135142.3510-1-ruifeng.wang@arm.com \
--to=ruifeng.wang@arm.com \
--cc=dev@dpdk.org \
--cc=gavin.hu@arm.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=nd@arm.com \
--cc=stable@dpdk.org \
/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).