linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
	linux-kernel@vger.kernel.org,
	Dipankar Sarma <dipankar@in.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: Re: linux-next-20110923: warning kernel/rcutree.c:1833
Date: Sun, 2 Oct 2011 13:45:58 +0200	[thread overview]
Message-ID: <20111002114555.GG3391@somewhere> (raw)
In-Reply-To: <20111002032316.GA29617@linux.vnet.ibm.com>

On Sat, Oct 01, 2011 at 08:23:16PM -0700, Paul E. McKenney wrote:
> On Sat, Oct 01, 2011 at 10:07:14AM -0700, Paul E. McKenney wrote:
> > On Sat, Oct 01, 2011 at 02:24:45PM +0200, Frederic Weisbecker wrote:
> > > On Fri, Sep 30, 2011 at 12:24:38PM -0700, Paul E. McKenney wrote:
> > > > And here is a first cut, probably totally broken, but a start.
> > > > 
> > > > With this change, I am wondering about tick_nohz_stop_sched_tick()'s
> > > > invocation of rcu_idle_enter() -- this now needs to be called regardless
> > > > of whether or not tick_nohz_stop_sched_tick() actually stops the tick.
> > > > Except that if tick_nohz_stop_sched_tick() is invoked with inidle==0,
> > > > it looks like we should -not- call rcu_idle_enter().
> > > 
> > > Because of the new check in rcu_check_callbacks()? Yeah.
> > > 
> > > If you think it's fine to call rcu_enter_nohz() unconditionally
> > > everytime we enter the idle loop then yeah. I just don't know
> > > the overhead it adds, as it adds an unconditional tiny piece of
> > > code before we can finally save the power.
> > > 
> > > Either entering idle involves extended quiescent state as in this
> > > patch, or you separate both and then rcu_enter_nohz() is only
> > > called when the tick is stopped.
> > > 
> > > If you choose to merge both, you indeed need to call rcu_idle_enter()
> > > and rcu_idle_exit() whether the tick is stopped or not.
> > > 
> > > > I eventually just left the rcu_idle_enter() calls in their current
> > > > places due to paranoia about messing up and ending up with unbalanced
> > > > rcu_idle_enter() and rcu_idle_exit() calls.  Any thoughts on how to
> > > > make this work better?
> > > 
> > > Yeah something like this (untested):
> > > 
> > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> > > index d5097c4..ad3ecad 100644
> > > --- a/kernel/time/tick-sched.c
> > > +++ b/kernel/time/tick-sched.c
> > > @@ -273,9 +273,12 @@ void tick_nohz_stop_sched_tick(int inidle)
> > >  	 * updated. Thus, it must not be called in the event we are called from
> > >  	 * irq_exit() with the prior state different than idle.
> > >  	 */
> > > -	if (!inidle && !ts->inidle)
> > > +	if (inidle)
> > > +		rcu_idle_enter();
> > > +	else if (!ts->inidle)
> > >  		goto end;
> > > 
> > > +
> > >  	/*
> > >  	 * Set ts->inidle unconditionally. Even if the system did not
> > >  	 * switch to NOHZ mode the cpu frequency governers rely on the
> > > @@ -409,7 +412,6 @@ void tick_nohz_stop_sched_tick(int inidle)
> > >  			ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
> > >  			ts->tick_stopped = 1;
> > >  			ts->idle_jiffies = last_jiffies;
> > > -			rcu_enter_nohz();
> > >  		}
> > > 
> > >  		ts->idle_sleeps++;
> > > @@ -505,6 +507,9 @@ void tick_nohz_restart_sched_tick(void)
> > >  	ktime_t now;
> > > 
> > >  	local_irq_disable();
> > > +
> > > +	rcu_idle_exit();
> > > +
> > >  	if (ts->idle_active || (ts->inidle && ts->tick_stopped))
> > >  		now = ktime_get();
> > > 
> > > @@ -519,8 +524,6 @@ void tick_nohz_restart_sched_tick(void)
> > > 
> > >  	ts->inidle = 0;
> > > 
> > > -	rcu_exit_nohz();
> > > -
> > >  	/* Update jiffies first */
> > >  	select_nohz_load_balancer(0);
> > >  	tick_do_update_jiffies64(now);
> > > 
> > > 
> > > 
> > > 
> > > More things about your patch below:
> > > 
> > > > --- a/kernel/rcutiny.c
> > > > +++ b/kernel/rcutiny.c
> > > > @@ -54,31 +54,47 @@ static void __call_rcu(struct rcu_head *head,
> > > >  
> > > >  #include "rcutiny_plugin.h"
> > > >  
> > > > -#ifdef CONFIG_NO_HZ
> > > > -
> > > >  static long rcu_dynticks_nesting = 1;
> > > >  
> > > >  /*
> > > > - * Enter dynticks-idle mode, which is an extended quiescent state
> > > > - * if we have fully entered that mode (i.e., if the new value of
> > > > - * dynticks_nesting is zero).
> > > > + * Enter idle, which is an extended quiescent state if we have fully
> > > > + * entered that mode (i.e., if the new value of dynticks_nesting is zero).
> > > >   */
> > > > -void rcu_enter_nohz(void)
> > > > +void rcu_idle_enter(void)
> > > >  {
> > > >  	if (--rcu_dynticks_nesting == 0)
> > > >  		rcu_sched_qs(0); /* implies rcu_bh_qsctr_inc(0) */
> > > >  }
> > > >  
> > > >  /*
> > > > - * Exit dynticks-idle mode, so that we are no longer in an extended
> > > > - * quiescent state.
> > > > + * Exit idle, so that we are no longer in an extended quiescent state.
> > > >   */
> > > > -void rcu_exit_nohz(void)
> > > > +void rcu_idle_exit(void)
> > > >  {
> > > >  	rcu_dynticks_nesting++;
> > > >  }
> > > >  
> > > > -#endif /* #ifdef CONFIG_NO_HZ */
> > > > +#ifdef CONFIG_PROVE_RCU
> > > > +
> > > > +/*
> > > > + * Test whether the current CPU is idle.
> > > > + */
> > > 
> > > Is idle from an RCU point of view yeah.
> > 
> > Good point -- I now say "Test whether RCU thinks that the current CPU is idle."
> > 
> > > > +int rcu_is_cpu_idle(void)
> > > > +{
> > > > +	return !rcu_dynticks_nesting;
> > > > +}
> > > > +
> > > > +#endif /* #ifdef CONFIG_PROVE_RCU */
> > > > +
> > > > +/*
> > > > + * Test whether the current CPU was interrupted from idle.  Nested
> > > > + * interrupts don't count, we must be running at the first interrupt
> > > > + * level.
> > > > + */
> > > > +int rcu_is_cpu_rrupt_from_idle(void)
> > > > +{
> > > > +	return rcu_dynticks_nesting <= 0;
> > > > +}
> > > >  
> > > >  /*
> > > >   * Helper function for rcu_sched_qs() and rcu_bh_qs().
> > > > @@ -131,10 +147,7 @@ void rcu_bh_qs(int cpu)
> > > >   */
> > > >  void rcu_check_callbacks(int cpu, int user)
> > > >  {
> > > > -	if (user ||
> > > > -	    (idle_cpu(cpu) &&
> > > > -	     !in_softirq() &&
> > > > -	     hardirq_count() <= (1 << HARDIRQ_SHIFT)))
> > > > +	if (user || rcu_is_cpu_rrupt_from_idle())
> > > >  		rcu_sched_qs(cpu);
> > > 
> > > It wasn't obvious to me in the first shot. This might need a comment
> > > that tells rcu_check_callbacks() is called from an interrupt
> > > and thus need to handle that first level in the check.
> > 
> > OK, I added "This function must be called from hardirq context".
> > 
> > > Other than that, looks good overall.
> > 
> > Keeping fingers firmly crossed for the testing...
> 
> And it appears sane in testing thus far.  I have consolidated to one
> patch and pushed to https://github.com/paulmckrcu/linux branch rcu/dev.
> 
> Testing continues.

Great. I'll start the rebase then.

Thanks.

  reply	other threads:[~2011-10-02 11:46 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-25  0:24 linux-next-20110923: warning kernel/rcutree.c:1833 Kirill A. Shutemov
2011-09-25  5:08 ` Paul E. McKenney
2011-09-25 11:26   ` Kirill A. Shutemov
2011-09-25 13:06     ` Frederic Weisbecker
2011-09-25 14:19       ` Kirill A. Shutemov
2011-09-25 16:48       ` Paul E. McKenney
2011-09-26  1:04         ` Frederic Weisbecker
2011-09-26  1:10           ` Frederic Weisbecker
2011-09-26  1:26             ` Paul E. McKenney
2011-09-26  1:41               ` Paul E. McKenney
2011-09-26  9:39                 ` Frederic Weisbecker
2011-09-26 22:34                   ` Paul E. McKenney
2011-09-27 12:07                     ` Frederic Weisbecker
2011-09-26  9:42                 ` Frederic Weisbecker
2011-09-26 22:35                   ` Paul E. McKenney
2011-09-26  9:20               ` Frederic Weisbecker
2011-09-26 22:50                 ` Paul E. McKenney
2011-09-27 12:16                   ` Frederic Weisbecker
2011-09-27 18:01                     ` Paul E. McKenney
2011-09-28 12:31                       ` Frederic Weisbecker
2011-09-28 18:40                         ` Paul E. McKenney
2011-09-28 23:46                           ` Frederic Weisbecker
2011-09-29  0:55                             ` Paul E. McKenney
2011-09-29  4:49                               ` Paul E. McKenney
2011-09-29 12:30                               ` Frederic Weisbecker
2011-09-29 17:12                                 ` Paul E. McKenney
2011-09-29 17:19                                   ` Paul E. McKenney
2011-09-29 23:18                                     ` Paul E. McKenney
2011-09-30 13:11                                   ` Frederic Weisbecker
2011-09-30 15:29                                     ` Paul E. McKenney
2011-09-30 19:24                                       ` Paul E. McKenney
2011-10-01  4:34                                         ` Paul E. McKenney
2011-10-01 12:24                                         ` Frederic Weisbecker
2011-10-01 12:28                                           ` Frederic Weisbecker
2011-10-01 16:35                                             ` Paul E. McKenney
2011-10-01 17:07                                           ` Paul E. McKenney
2011-10-02  3:23                                             ` Paul E. McKenney
2011-10-02 11:45                                               ` Frederic Weisbecker [this message]
2011-10-02 22:50                                         ` Frederic Weisbecker
2011-10-03  0:28                                           ` Paul E. McKenney
2011-10-03 12:59                                             ` Frederic Weisbecker
2011-10-03 16:22                                               ` Paul E. McKenney
2011-10-03 17:11                                                 ` Frederic Weisbecker
2011-10-02 23:07                                         ` Frederic Weisbecker
2011-10-03  0:32                                           ` Paul E. McKenney
2011-10-03 13:03                                             ` Frederic Weisbecker
2011-10-03 16:30                                               ` Paul E. McKenney
2011-10-06  0:58                                                 ` Paul E. McKenney
2011-10-06  1:59                                                   ` Paul E. McKenney
2011-10-06 12:11                                                   ` Frederic Weisbecker
2011-10-06 18:44                                                     ` Paul E. McKenney
2011-10-06 23:44                                                       ` Paul E. McKenney
2011-09-26  1:25           ` Paul E. McKenney
2011-09-26  8:48             ` Frederic Weisbecker
2011-09-26  8:49             ` Frederic Weisbecker
2011-09-26 22:30               ` Paul E. McKenney
2011-09-27 11:55                 ` Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111002114555.GG3391@somewhere \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dipankar@in.ibm.com \
    --cc=kirill@shutemov.name \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).