public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	laijs@cn.fujitsu.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de,
	peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com,
	edumazet@google.com, darren@dvhart.com, fweisbec@gmail.com,
	sbw@mit.edu
Subject: Re: [PATCH tip/core/timers 1/3] timers: Reduce __run_timers() latency for empty list
Date: Tue, 14 Jan 2014 19:48:28 +0100	[thread overview]
Message-ID: <20140114184828.GA29331@redhat.com> (raw)
In-Reply-To: <1389672919-14621-1-git-send-email-paulmck@linux.vnet.ibm.com>

On 01/13, Paul E. McKenney wrote:
>
> The __run_timers() function currently steps through the list one jiffy at
> a time in order to update the timer wheel.  However, if the timer wheel
> is empty, no adjustment is needed other than updating ->timer_jiffies.

Yes, but ->active_timers == 0 doesn't necessarily mean "empty", it only
counts the non-deferrable timers?

> In this case, which is likely to be common for NO_HZ_FULL kernels, the
> kernel currently incurs a large latency for no good reason.  This commit
> therefore short-circuits this case.
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>  kernel/timer.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/kernel/timer.c b/kernel/timer.c
> index 6582b82fa966..21849275828f 100644
> --- a/kernel/timer.c
> +++ b/kernel/timer.c
> @@ -337,6 +337,17 @@ void set_timer_slack(struct timer_list *timer, int slack_hz)
>  }
>  EXPORT_SYMBOL_GPL(set_timer_slack);
>
> +static bool catchup_timer_jiffies(struct tvec_base *base)
> +{
> +#ifdef CONFIG_NO_HZ_FULL
> +	if (!base->active_timers) {
> +		base->timer_jiffies = jiffies;
> +		return 1;
> +	}
> +#endif /* #ifdef CONFIG_NO_HZ_FULL */
> +	return 0;
> +}
> +
>  static void
>  __internal_add_timer(struct tvec_base *base, struct timer_list *timer)
>  {
> @@ -1146,6 +1157,10 @@ static inline void __run_timers(struct tvec_base *base)
>  	struct timer_list *timer;
>
>  	spin_lock_irq(&base->lock);

Do we really need to take base->lock before catchup_timer_jiffies() ?
->timer_jiffies can only be changed by us, and it seems that we do
not care if we race with base->active_timers++.

> +	if (catchup_timer_jiffies(base)) {
> +		spin_unlock_irq(&base->lock);
> +		return;

This is what I can't understand... Doesn't this mean that, unless this
base have a non-deferrable timer, we can never run the pending deferrable
timers even if the system/cpu is "busy" ?

Oleg.


  parent reply	other threads:[~2014-01-14 18:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14  4:14 [PATCH tip/core/rcu 0/3] Crude timer-wheel latency hacks Paul E. McKenney
2014-01-14  4:15 ` [PATCH tip/core/timers 1/3] timers: Reduce __run_timers() latency for empty list Paul E. McKenney
2014-01-14  4:15   ` [PATCH tip/core/timers 2/3] timers: Reduce future __run_timers() latency for newly emptied list Paul E. McKenney
2014-01-14  4:15   ` [PATCH tip/core/timers 3/3] timers: Reduce future __run_timers() latency for first add to empty list Paul E. McKenney
2014-01-14 18:48   ` Oleg Nesterov [this message]
2014-01-14 23:50     ` [PATCH tip/core/timers 1/3] timers: Reduce __run_timers() latency for " Paul E. McKenney
2014-01-15 16:25       ` Oleg Nesterov

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=20140114184828.GA29331@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=darren@dvhart.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=niv@us.ibm.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sbw@mit.edu \
    --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