All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Matthew Whitehead <tedheadster@gmail.com>,
	john.stultz@linaro.org, linux-kernel@vger.kernel.org,
	mwhitehe@redhat.com
Subject: Re: nohz problem with idle time on old hardware
Date: Mon, 18 Nov 2013 14:44:34 -0800	[thread overview]
Message-ID: <20131118224434.GH4138@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1311132052240.30673@ionos.tec.linutronix.de>

On Wed, Nov 13, 2013 at 09:01:57PM +0100, Thomas Gleixner wrote:
> On Wed, 13 Nov 2013, Paul E. McKenney wrote:
> > On Wed, Nov 13, 2013 at 11:23:38AM -0500, Steven Rostedt wrote:
> > > On Wed, 13 Nov 2013 08:18:29 -0800
> > > "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:
> > > 
> > > > On Wed, Nov 13, 2013 at 11:12:57AM -0500, Steven Rostedt wrote:
> > > > > On Wed, 13 Nov 2013 17:07:18 +0100 (CET)
> > > > > Thomas Gleixner <tglx@linutronix.de> wrote:
> > > > > 
> > > > > 
> > > > > > Right. It's telling you if NOHZ is enabled. It's not telling you that
> > > > > > NOHZ is active.
> > > > > 
> > > > > Yeah, which makes this code rather silly:
> > > > > 
> > > > > in rcu_prepare_for_idle():
> > > > > 
> > > > > 	/* Handle nohz enablement switches conservatively. */
> > > > > 	tne = ACCESS_ONCE(tick_nohz_enabled);
> > > > > 	if (tne != rdtp->tick_nohz_enabled_snap) {
> > > > > 		if (rcu_cpu_has_callbacks(cpu, NULL))
> > > > > 			invoke_rcu_core(); /* force nohz to see update. */
> > > > > 		rdtp->tick_nohz_enabled_snap = tne;
> > > > > 		return;
> > > > > 	}
> > > > 
> > > > OK, what should I be checking instead?  Not much point in trying to
> > > > get RCU out of the way of disabling the scheduling-clock interrupt
> > > > if NOHZ is disabled.  ;-)
> > > 
> > > I'll leave the answer to Thomas, but checking tick_nohz_enabled just
> > > lets you know if someone booted with nohz=off or not (and has nohz
> > > configured). But it doesn't tell you if nohz is actually being used.
> > 
> > Based on Thomas's most recent response, it sounds like I need to check
> > a frozen shark or something.  ;-)
> 
> Correct. Fix for the whole mess below.
> 
> Thanks,
> 
> 	tglx
> 
> ---------------->
> Subject: NOHZ: Check for nohz active instead of nohz enabled
> 
> RCU and the fine grained idle time accounting functions check
> tick_nohz_enabled. But that variable is merily telling that NOHZ has
> been enabled in the config and not been disabled on the command line.
> 
> But it does not tell anything about nohz being active. That's what all
> this should check for.
> 
> Matthew reported, that the idle accounting on his old P1 machine
> showed bogus values, when he enabled NOHZ in the config and did not
> disable it on the kernel command line. The reason is that his machine
> uses (refined) jiffies as a clocksource which explains why the "fine"
> grained accounting went into lala land, because it depends on when the
> system goes and leaves idle relative to the jiffies increment.
> 
> Provide a tick_nohz_active indicator and let RCU and the accounting
> code use this instead of tick_nohz_enable.
> 
> Reported-by: Matthew Whitehead <tedheadster@gmail.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 3822ac0..da6e6de 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -1632,7 +1632,7 @@ module_param(rcu_idle_gp_delay, int, 0644);
>  static int rcu_idle_lazy_gp_delay = RCU_IDLE_LAZY_GP_DELAY;
>  module_param(rcu_idle_lazy_gp_delay, int, 0644);
> 
> -extern int tick_nohz_enabled;
> +extern int tick_nohz_active;
> 
>  /*
>   * Try to advance callbacks for all flavors of RCU on the current CPU, but
> @@ -1729,7 +1729,7 @@ static void rcu_prepare_for_idle(int cpu)
>  	int tne;
> 
>  	/* Handle nohz enablement switches conservatively. */
> -	tne = ACCESS_ONCE(tick_nohz_enabled);
> +	tne = ACCESS_ONCE(tick_nohz_active);
>  	if (tne != rdtp->tick_nohz_enabled_snap) {
>  		if (rcu_cpu_has_callbacks(cpu, NULL))
>  			invoke_rcu_core(); /* force nohz to see update. */
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index 3612fc7..a12df5a 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -361,8 +361,8 @@ void __init tick_nohz_init(void)
>  /*
>   * NO HZ enabled ?
>   */
> -int tick_nohz_enabled __read_mostly  = 1;
> -
> +static int tick_nohz_enabled __read_mostly  = 1;
> +int tick_nohz_active  __read_mostly;
>  /*
>   * Enable / Disable tickless mode
>   */
> @@ -465,7 +465,7 @@ u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
>  	struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
>  	ktime_t now, idle;
> 
> -	if (!tick_nohz_enabled)
> +	if (!tick_nohz_active)
>  		return -1;
> 
>  	now = ktime_get();
> @@ -506,7 +506,7 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
>  	struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
>  	ktime_t now, iowait;
> 
> -	if (!tick_nohz_enabled)
> +	if (!tick_nohz_active)
>  		return -1;
> 
>  	now = ktime_get();
> @@ -799,11 +799,6 @@ void tick_nohz_idle_enter(void)
>  	local_irq_disable();
> 
>  	ts = &__get_cpu_var(tick_cpu_sched);
> -	/*
> -	 * set ts->inidle unconditionally. even if the system did not
> -	 * switch to nohz mode the cpu frequency governers rely on the
> -	 * update of the idle time accounting in tick_nohz_start_idle().
> -	 */
>  	ts->inidle = 1;
>  	__tick_nohz_idle_enter(ts);
> 
> @@ -973,7 +968,7 @@ static void tick_nohz_switch_to_nohz(void)
>  	struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
>  	ktime_t next;
> 
> -	if (!tick_nohz_enabled)
> +	if (!tick_nohz_active)
>  		return;
> 
>  	local_irq_disable();
> @@ -981,7 +976,7 @@ static void tick_nohz_switch_to_nohz(void)
>  		local_irq_enable();
>  		return;
>  	}
> -
> +	tick_nohz_active = 1;
>  	ts->nohz_mode = NOHZ_MODE_LOWRES;
> 
>  	/*
> @@ -1139,8 +1134,10 @@ void tick_setup_sched_timer(void)
>  	}
> 
>  #ifdef CONFIG_NO_HZ_COMMON
> -	if (tick_nohz_enabled)
> +	if (tick_nohz_enabled) {
>  		ts->nohz_mode = NOHZ_MODE_HIGHRES;
> +		tick_nohz_active = 1;
> +	}
>  #endif
>  }
>  #endif /* HIGH_RES_TIMERS */
> 


  parent reply	other threads:[~2013-11-18 22:44 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13 11:39 nohz problem with idle time on old hardware Matthew Whitehead
2013-11-13 14:02 ` Thomas Gleixner
2013-11-13 15:21   ` Steven Rostedt
2013-11-13 15:31     ` Steven Rostedt
2013-11-13 15:50       ` Thomas Gleixner
2013-11-13 16:17         ` Paul E. McKenney
2013-11-13 15:57       ` Steven Rostedt
2013-11-13 16:07         ` Thomas Gleixner
2013-11-13 16:12           ` Steven Rostedt
2013-11-13 16:18             ` Paul E. McKenney
2013-11-13 16:23               ` Steven Rostedt
2013-11-13 16:35                 ` Paul E. McKenney
2013-11-13 20:01                   ` Thomas Gleixner
2013-11-13 20:07                     ` Steven Rostedt
2013-11-13 21:49                       ` Matthew Whitehead
2013-11-18 22:44                     ` Paul E. McKenney [this message]
2013-11-19 18:07                     ` [tip:timers/urgent] NOHZ: Check for nohz active instead of nohz enabled tip-bot for Thomas Gleixner
2014-04-09 13:51                     ` nohz problem with idle time on old hardware Viresh Kumar
2014-04-09 14:31                       ` Steven Rostedt
2014-04-09 15:20                         ` Viresh Kumar
2014-04-09 15:29                           ` Steven Rostedt
2014-04-09 15:31                             ` Steven Rostedt
2014-04-09 15:34                               ` Viresh Kumar
2014-04-09 15:39                               ` Steven Rostedt
2014-04-09 15:56                                 ` Viresh Kumar
2014-04-09 16:15                                   ` Steven Rostedt
2014-04-09 15:11                       ` Frederic Weisbecker
2013-11-13 16:21           ` Thomas Gleixner
2013-11-13 16:31             ` Steven Rostedt

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=20131118224434.GH4138@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mwhitehe@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tedheadster@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.