[tip/core/rcu,4/8] rcu: Ensure that ->rcu_urgent_qs is set before resched IPI
diff mbox series

Message ID 20191003013305.12854-4-paulmck@kernel.org
State New
Headers show
Series
  • Fixes for v5.5
Related show

Commit Message

Paul E. McKenney Oct. 3, 2019, 1:33 a.m. UTC
From: "Joel Fernandes (Google)" <joel@joelfernandes.org>

The RCU-specific resched_cpu() function sends a resched IPI to the
specified CPU, which can be used to force the tick on for a given
nohz_full CPU.  This is needed when this nohz_full CPU is looping in the
kernel while blocking the current grace period.  However, for the tick
to actually be forced on in all cases, that CPU's rcu_data structure's
->rcu_urgent_qs flag must be set beforehand.  This commit therefore
causes rcu_implicit_dynticks_qs() to set this flag prior to invoking
resched_cpu() on a holdout nohz_full CPU.

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
---
 kernel/rcu/tree.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steven Rostedt Oct. 3, 2019, 11:43 a.m. UTC | #1
On Wed,  2 Oct 2019 18:33:01 -0700
paulmck@kernel.org wrote:

> From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
> 
> The RCU-specific resched_cpu() function sends a resched IPI to the
> specified CPU, which can be used to force the tick on for a given
> nohz_full CPU.  This is needed when this nohz_full CPU is looping in the
> kernel while blocking the current grace period.  However, for the tick
> to actually be forced on in all cases, that CPU's rcu_data structure's
> ->rcu_urgent_qs flag must be set beforehand.  This commit therefore  
> causes rcu_implicit_dynticks_qs() to set this flag prior to invoking
> resched_cpu() on a holdout nohz_full CPU.

Should this be marked for stable?

-- Steve

> 
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
> ---
>  kernel/rcu/tree.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 8110514..0d83b19 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -1073,6 +1073,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
>  	if (tick_nohz_full_cpu(rdp->cpu) &&
>  		   time_after(jiffies,
>  			      READ_ONCE(rdp->last_fqs_resched) + jtsq * 3)) {
> +		WRITE_ONCE(*ruqp, true);
>  		resched_cpu(rdp->cpu);
>  		WRITE_ONCE(rdp->last_fqs_resched, jiffies);
>  	}
Paul E. McKenney Oct. 3, 2019, 1:45 p.m. UTC | #2
On Thu, Oct 03, 2019 at 07:43:19AM -0400, Steven Rostedt wrote:
> On Wed,  2 Oct 2019 18:33:01 -0700
> paulmck@kernel.org wrote:
> 
> > From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
> > 
> > The RCU-specific resched_cpu() function sends a resched IPI to the
> > specified CPU, which can be used to force the tick on for a given
> > nohz_full CPU.  This is needed when this nohz_full CPU is looping in the
> > kernel while blocking the current grace period.  However, for the tick
> > to actually be forced on in all cases, that CPU's rcu_data structure's
> > ->rcu_urgent_qs flag must be set beforehand.  This commit therefore  
> > causes rcu_implicit_dynticks_qs() to set this flag prior to invoking
> > resched_cpu() on a holdout nohz_full CPU.
> 
> Should this be marked for stable?

Not unless and until people are actually running into this.  NO_HZ_FULL
has left the tick off for in-kernel loops on nohz_full CPUs for almost
ten years now, and as far as I know, without complaint.

So from what I am seeing, the risk of backporting far exceeds the benefit.

							Thanx, Paul

> -- Steve
> 
> > 
> > Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> > Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
> > ---
> >  kernel/rcu/tree.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index 8110514..0d83b19 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -1073,6 +1073,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
> >  	if (tick_nohz_full_cpu(rdp->cpu) &&
> >  		   time_after(jiffies,
> >  			      READ_ONCE(rdp->last_fqs_resched) + jtsq * 3)) {
> > +		WRITE_ONCE(*ruqp, true);
> >  		resched_cpu(rdp->cpu);
> >  		WRITE_ONCE(rdp->last_fqs_resched, jiffies);
> >  	}
>

Patch
diff mbox series

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 8110514..0d83b19 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1073,6 +1073,7 @@  static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
 	if (tick_nohz_full_cpu(rdp->cpu) &&
 		   time_after(jiffies,
 			      READ_ONCE(rdp->last_fqs_resched) + jtsq * 3)) {
+		WRITE_ONCE(*ruqp, true);
 		resched_cpu(rdp->cpu);
 		WRITE_ONCE(rdp->last_fqs_resched, jiffies);
 	}