lib/rcu: fix possible spurious thread unregister
PATCH 1/1 lib/rcu: fix possible spurious thread unregister
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.
--- lib/librte_rcu/rte_rcu_qsbr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_rcu/rte_rcu_qsbr.c +2 -2
@@ -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. */
Signature · 1 line
2.17.1
Thanks Ruifeng, looks good.
Quoted 45 lines
-----Original Message-----
From: Ruifeng Wang <[email protected]>
Sent: Monday, September 9, 2019 8:52 AM
To: Honnappa Nagarahalli <[email protected]>
Cc: [email protected]; Gavin Hu (Arm Technology China) <[email protected]>; nd <[email protected]>; Ruifeng Wang (Arm Technology China) <[email protected]>; [email protected]
Subject: [PATCH] lib/rcu: fix possible spurious thread unregisterThread 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")Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- lib/librte_rcu/rte_rcu_qsbr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_rcu/rte_rcu_qsbr.c index renamed from lib/librte_rcu/rte_rcu_qsbr.c +0
-0
ce7f93dd3..8c37c88cd100644lib/librte_rcu/rte_rcu_qsbr.c +1
-1@@ -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 ;lib/librte_rcu/rte_rcu_qsbr.c +1
-1do {@@ -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.
Quoted 2 lines
*/
--
Quoted 1 line
2.17.1
Quoted 28 lines · Ruifeng Wang
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")Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- lib/librte_rcu/rte_rcu_qsbr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_rcu/rte_rcu_qsbr.c +1
-1@@ -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 {
lib/librte_rcu/rte_rcu_qsbr.c rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) · line 181
Quoted 8 lines
lib/librte_rcu/rte_rcu_qsbr.c +1
-1@@ -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. */
Honnappa,
While looking at the rcu doxygen, I noted it does not describe what return values to expect from register/unregister.
We also have typos on s/rte_rcu_thread_offline/rte_rcu_qsbr_thread_offline/g.
Could you send a patch for this?
Thanks.
--
David Marchand
David Marchand
AppliedQuoted 7 lines · David Marchand
Quoted 5 lines · Ruifeng Wang
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.
Quoted 7 lines
Quoted 5 lines
Fixes 64994b56cfd7 ("rcu: add RCU library supporting QSBR mechanism")Signed-off-by Ruifeng Wang <[email protected]>Reviewed-by Gavin Hu <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>Reviewed-by David Marchand <[email protected]>
Applied, thanks.
--
David Marchand