linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] percpu_ref: Don't opencode percpu_ref_is_dying
@ 2021-05-11 13:16 Nikolay Borisov
  2021-05-11 13:49 ` Dennis Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2021-05-11 13:16 UTC (permalink / raw)
  To: dennis; +Cc: tj, linux-kernel, Nikolay Borisov

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 lib/percpu-refcount.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index a1071cdefb5a..af9302141bcf 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -275,7 +275,7 @@ static void __percpu_ref_switch_mode(struct percpu_ref *ref,
 	wait_event_lock_irq(percpu_ref_switch_waitq, !data->confirm_switch,
 			    percpu_ref_switch_lock);
 
-	if (data->force_atomic || (ref->percpu_count_ptr & __PERCPU_REF_DEAD))
+	if (data->force_atomic || percpu_ref_is_dying(ref))
 		__percpu_ref_switch_to_atomic(ref, confirm_switch);
 	else
 		__percpu_ref_switch_to_percpu(ref);
@@ -385,7 +385,7 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
 
 	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
 
-	WARN_ONCE(ref->percpu_count_ptr & __PERCPU_REF_DEAD,
+	WARN_ONCE(percpu_ref_is_dying(ref),
 		  "%s called more than once on %ps!", __func__,
 		  ref->data->release);
 
@@ -465,7 +465,7 @@ void percpu_ref_resurrect(struct percpu_ref *ref)
 
 	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
 
-	WARN_ON_ONCE(!(ref->percpu_count_ptr & __PERCPU_REF_DEAD));
+	WARN_ON_ONCE(!percpu_ref_is_dying(ref));
 	WARN_ON_ONCE(__ref_is_percpu(ref, &percpu_count));
 
 	ref->percpu_count_ptr &= ~__PERCPU_REF_DEAD;
-- 
2.25.1


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

* Re: [PATCH] percpu_ref: Don't opencode percpu_ref_is_dying
  2021-05-11 13:16 [PATCH] percpu_ref: Don't opencode percpu_ref_is_dying Nikolay Borisov
@ 2021-05-11 13:49 ` Dennis Zhou
  2021-05-13  4:48   ` Dennis Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: Dennis Zhou @ 2021-05-11 13:49 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: tj, linux-kernel

Hello,

On Tue, May 11, 2021 at 04:16:33PM +0300, Nikolay Borisov wrote:
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  lib/percpu-refcount.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
> index a1071cdefb5a..af9302141bcf 100644
> --- a/lib/percpu-refcount.c
> +++ b/lib/percpu-refcount.c
> @@ -275,7 +275,7 @@ static void __percpu_ref_switch_mode(struct percpu_ref *ref,
>  	wait_event_lock_irq(percpu_ref_switch_waitq, !data->confirm_switch,
>  			    percpu_ref_switch_lock);
>  
> -	if (data->force_atomic || (ref->percpu_count_ptr & __PERCPU_REF_DEAD))
> +	if (data->force_atomic || percpu_ref_is_dying(ref))
>  		__percpu_ref_switch_to_atomic(ref, confirm_switch);
>  	else
>  		__percpu_ref_switch_to_percpu(ref);
> @@ -385,7 +385,7 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
>  
>  	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
>  
> -	WARN_ONCE(ref->percpu_count_ptr & __PERCPU_REF_DEAD,
> +	WARN_ONCE(percpu_ref_is_dying(ref),
>  		  "%s called more than once on %ps!", __func__,
>  		  ref->data->release);
>  
> @@ -465,7 +465,7 @@ void percpu_ref_resurrect(struct percpu_ref *ref)
>  
>  	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
>  
> -	WARN_ON_ONCE(!(ref->percpu_count_ptr & __PERCPU_REF_DEAD));
> +	WARN_ON_ONCE(!percpu_ref_is_dying(ref));
>  	WARN_ON_ONCE(__ref_is_percpu(ref, &percpu_count));
>  
>  	ref->percpu_count_ptr &= ~__PERCPU_REF_DEAD;
> -- 
> 2.25.1
> 

If no one has any objections to me officially taking percpu_ref, I'll
pick this up.

Thanks,
Dennis

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

* Re: [PATCH] percpu_ref: Don't opencode percpu_ref_is_dying
  2021-05-11 13:49 ` Dennis Zhou
@ 2021-05-13  4:48   ` Dennis Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Dennis Zhou @ 2021-05-13  4:48 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: tj, linux-kernel

On Tue, May 11, 2021 at 01:49:23PM +0000, Dennis Zhou wrote:
> Hello,
> 
> On Tue, May 11, 2021 at 04:16:33PM +0300, Nikolay Borisov wrote:
> > Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> > ---
> >  lib/percpu-refcount.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
> > index a1071cdefb5a..af9302141bcf 100644
> > --- a/lib/percpu-refcount.c
> > +++ b/lib/percpu-refcount.c
> > @@ -275,7 +275,7 @@ static void __percpu_ref_switch_mode(struct percpu_ref *ref,
> >  	wait_event_lock_irq(percpu_ref_switch_waitq, !data->confirm_switch,
> >  			    percpu_ref_switch_lock);
> >  
> > -	if (data->force_atomic || (ref->percpu_count_ptr & __PERCPU_REF_DEAD))
> > +	if (data->force_atomic || percpu_ref_is_dying(ref))
> >  		__percpu_ref_switch_to_atomic(ref, confirm_switch);
> >  	else
> >  		__percpu_ref_switch_to_percpu(ref);
> > @@ -385,7 +385,7 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
> >  
> >  	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
> >  
> > -	WARN_ONCE(ref->percpu_count_ptr & __PERCPU_REF_DEAD,
> > +	WARN_ONCE(percpu_ref_is_dying(ref),
> >  		  "%s called more than once on %ps!", __func__,
> >  		  ref->data->release);
> >  
> > @@ -465,7 +465,7 @@ void percpu_ref_resurrect(struct percpu_ref *ref)
> >  
> >  	spin_lock_irqsave(&percpu_ref_switch_lock, flags);
> >  
> > -	WARN_ON_ONCE(!(ref->percpu_count_ptr & __PERCPU_REF_DEAD));
> > +	WARN_ON_ONCE(!percpu_ref_is_dying(ref));
> >  	WARN_ON_ONCE(__ref_is_percpu(ref, &percpu_count));
> >  
> >  	ref->percpu_count_ptr &= ~__PERCPU_REF_DEAD;
> > -- 
> > 2.25.1
> > 
> 
> If no one has any objections to me officially taking percpu_ref, I'll
> pick this up.
> 
> Thanks,
> Dennis

I've applied this to for-5.13-fixes.

Thanks,
Dennis

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

end of thread, other threads:[~2021-05-13  4:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 13:16 [PATCH] percpu_ref: Don't opencode percpu_ref_is_dying Nikolay Borisov
2021-05-11 13:49 ` Dennis Zhou
2021-05-13  4:48   ` Dennis Zhou

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).