patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH] lib/rcu: fix possible spurious thread unregister
@ 2019-09-09 13:51 Ruifeng Wang
  2019-09-13  4:17 ` Honnappa Nagarahalli
  2019-09-25  8:01 ` [dpdk-stable] [dpdk-dev] " David Marchand
  0 siblings, 2 replies; 3+ messages in thread
From: Ruifeng Wang @ 2019-09-09 13:51 UTC (permalink / raw)
  To: honnappa.nagarahalli; +Cc: dev, gavin.hu, nd, Ruifeng Wang, stable

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


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

* Re: [dpdk-stable] [PATCH] lib/rcu: fix possible spurious thread unregister
  2019-09-09 13:51 [dpdk-stable] [PATCH] lib/rcu: fix possible spurious thread unregister Ruifeng Wang
@ 2019-09-13  4:17 ` Honnappa Nagarahalli
  2019-09-25  8:01 ` [dpdk-stable] [dpdk-dev] " David Marchand
  1 sibling, 0 replies; 3+ messages in thread
From: Honnappa Nagarahalli @ 2019-09-13  4:17 UTC (permalink / raw)
  To: Ruifeng Wang (Arm Technology China)
  Cc: dev, Gavin Hu (Arm Technology China),
	nd, Ruifeng Wang (Arm Technology China),
	stable, nd

Thanks Ruifeng, looks good.

> -----Original Message-----
> From: Ruifeng Wang <ruifeng.wang@arm.com>
> Sent: Monday, September 9, 2019 8:52 AM
> To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> Cc: dev@dpdk.org; Gavin Hu (Arm Technology China) <Gavin.Hu@arm.com>;
> nd <nd@arm.com>; Ruifeng Wang (Arm Technology China)
> <Ruifeng.Wang@arm.com>; stable@dpdk.org
> Subject: [PATCH] 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.
> 
> 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.
>  			 */
> --
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> 2.17.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] lib/rcu: fix possible spurious thread unregister
  2019-09-09 13:51 [dpdk-stable] [PATCH] lib/rcu: fix possible spurious thread unregister Ruifeng Wang
  2019-09-13  4:17 ` Honnappa Nagarahalli
@ 2019-09-25  8:01 ` " David Marchand
  1 sibling, 0 replies; 3+ messages in thread
From: David Marchand @ 2019-09-25  8:01 UTC (permalink / raw)
  To: Ruifeng Wang, Honnappa Nagarahalli; +Cc: dev, Gavin Hu, nd, dpdk stable

On Mon, Sep 9, 2019 at 3:52 PM Ruifeng Wang <ruifeng.wang@arm.com> wrote:
>
> 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.
>                          */

Reviewed-by: David Marchand <david.marchand@redhat.com>


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


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 13:51 [dpdk-stable] [PATCH] lib/rcu: fix possible spurious thread unregister Ruifeng Wang
2019-09-13  4:17 ` Honnappa Nagarahalli
2019-09-25  8:01 ` [dpdk-stable] [dpdk-dev] " David Marchand

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox