diff mbox series

[11/13] rcu/nocb: Only cancel nocb timer if not polling

Message ID 20210223001011.127063-12-frederic@kernel.org
State Accepted
Commit f9fc166b790bd214083035d865653133b8a963d1
Headers show
Series rcu/nocb updates v2 | expand

Commit Message

Frederic Weisbecker Feb. 23, 2021, 12:10 a.m. UTC
No need to disarm the nocb_timer if rcu_nocb is polling because it
shouldn't be armed either.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Neeraj Upadhyay <neeraju@codeaurora.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
---
 kernel/rcu/tree_plugin.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Paul E. McKenney March 3, 2021, 1:22 a.m. UTC | #1
On Tue, Feb 23, 2021 at 01:10:09AM +0100, Frederic Weisbecker wrote:
> No need to disarm the nocb_timer if rcu_nocb is polling because it
> shouldn't be armed either.
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> Cc: Joel Fernandes <joel@joelfernandes.org>
> Cc: Neeraj Upadhyay <neeraju@codeaurora.org>
> Cc: Boqun Feng <boqun.feng@gmail.com>

OK, so it does make sense to move that del_timer() under the following
"if" statement, then.  ;-)

> ---
>  kernel/rcu/tree_plugin.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 9da67b0d3997..d8b50ff40e4b 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -2186,18 +2186,18 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
>  	my_rdp->nocb_gp_gp = needwait_gp;
>  	my_rdp->nocb_gp_seq = needwait_gp ? wait_gp_seq : 0;
>  	if (bypass) {
> -		raw_spin_lock_irqsave(&my_rdp->nocb_gp_lock, flags);
> -		// Avoid race with first bypass CB.
> -		if (my_rdp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
> -			WRITE_ONCE(my_rdp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
> -			del_timer(&my_rdp->nocb_timer);
> -		}
>  		if (!rcu_nocb_poll) {
> +			raw_spin_lock_irqsave(&my_rdp->nocb_gp_lock, flags);
> +			// Avoid race with first bypass CB.
> +			if (my_rdp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
> +				WRITE_ONCE(my_rdp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
> +				del_timer(&my_rdp->nocb_timer);
> +			}
>  			// At least one child with non-empty ->nocb_bypass, so set
>  			// timer in order to avoid stranding its callbacks.
>  			mod_timer(&my_rdp->nocb_bypass_timer, j + 2);
> +			raw_spin_unlock_irqrestore(&my_rdp->nocb_gp_lock, flags);
>  		}
> -		raw_spin_unlock_irqrestore(&my_rdp->nocb_gp_lock, flags);
>  	}
>  	if (rcu_nocb_poll) {
>  		/* Polling, so trace if first poll in the series. */
> -- 
> 2.25.1
>
Frederic Weisbecker March 10, 2021, 10:08 p.m. UTC | #2
On Tue, Mar 02, 2021 at 05:22:29PM -0800, Paul E. McKenney wrote:
> On Tue, Feb 23, 2021 at 01:10:09AM +0100, Frederic Weisbecker wrote:

> > No need to disarm the nocb_timer if rcu_nocb is polling because it

> > shouldn't be armed either.

> > 

> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>

> > Cc: Josh Triplett <josh@joshtriplett.org>

> > Cc: Lai Jiangshan <jiangshanlai@gmail.com>

> > Cc: Joel Fernandes <joel@joelfernandes.org>

> > Cc: Neeraj Upadhyay <neeraju@codeaurora.org>

> > Cc: Boqun Feng <boqun.feng@gmail.com>

> 

> OK, so it does make sense to move that del_timer() under the following

> "if" statement, then.  ;-)


Right, probably I should have handled that in the beginning of the patchset
instead of the end but heh, my mind is never that clear.

Thanks.
diff mbox series

Patch

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 9da67b0d3997..d8b50ff40e4b 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2186,18 +2186,18 @@  static void nocb_gp_wait(struct rcu_data *my_rdp)
 	my_rdp->nocb_gp_gp = needwait_gp;
 	my_rdp->nocb_gp_seq = needwait_gp ? wait_gp_seq : 0;
 	if (bypass) {
-		raw_spin_lock_irqsave(&my_rdp->nocb_gp_lock, flags);
-		// Avoid race with first bypass CB.
-		if (my_rdp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
-			WRITE_ONCE(my_rdp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
-			del_timer(&my_rdp->nocb_timer);
-		}
 		if (!rcu_nocb_poll) {
+			raw_spin_lock_irqsave(&my_rdp->nocb_gp_lock, flags);
+			// Avoid race with first bypass CB.
+			if (my_rdp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
+				WRITE_ONCE(my_rdp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
+				del_timer(&my_rdp->nocb_timer);
+			}
 			// At least one child with non-empty ->nocb_bypass, so set
 			// timer in order to avoid stranding its callbacks.
 			mod_timer(&my_rdp->nocb_bypass_timer, j + 2);
+			raw_spin_unlock_irqrestore(&my_rdp->nocb_gp_lock, flags);
 		}
-		raw_spin_unlock_irqrestore(&my_rdp->nocb_gp_lock, flags);
 	}
 	if (rcu_nocb_poll) {
 		/* Polling, so trace if first poll in the series. */