All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Yunhong Jiang <yunhong.jiang@linux.intel.com>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] timer: Lazily wakup nohz CPU when adding new timer.
Date: Fri, 13 Nov 2015 17:13:07 +0100	[thread overview]
Message-ID: <20151113161305.GC14397@lerouge> (raw)
In-Reply-To: <1443466096-31252-1-git-send-email-yunhong.jiang@linux.intel.com>

On Mon, Sep 28, 2015 at 11:48:16AM -0700, Yunhong Jiang wrote:
> Currently, when a new timer added to timer wheel for a nohz_active CPU,
> the target CPU will always be waked up.
> 
> In fact, if the new added timer is after the base->next_timer, we don't
> need wake up the target CPU since it will not change the sleep time. A
> lazy wake up is better in such scenario.
> 
> I cooked a test scenario. On my 32 cores system, a driver on CPU 15
> continuous enqueues timer to CPU 8/9/10/11 with random expire and then
> checks the idle_calls difference after 10 seconds. Below data shows
> that lazy wake up do reduce the wakeup a lot.
> 
> 		w/o Lazy	w/ lazy
> CPU 8:		135		88
> CPU 9:		238		43
> CPU 10:		157		83
> CPU 11:		172		70
> 
> Signed-off-by: Yunhong Jiang <yunhong.jiang@linux.intel.com>
> ---
>  kernel/time/timer.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/time/timer.c b/kernel/time/timer.c
> index d3f5e92f722a..a039d9e6b55a 100644
> --- a/kernel/time/timer.c
> +++ b/kernel/time/timer.c
> @@ -414,6 +414,8 @@ __internal_add_timer(struct tvec_base *base, struct timer_list *timer)
>  
>  static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
>  {
> +	bool kick_nohz = false;
> +
>  	/* Advance base->jiffies, if the base is empty */
>  	if (!base->all_timers++)
>  		base->timer_jiffies = jiffies;
> @@ -424,9 +426,17 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
>  	 */
>  	if (!(timer->flags & TIMER_DEFERRABLE)) {
>  		if (!base->active_timers++ ||
> -		    time_before(timer->expires, base->next_timer))
> +		    time_before(timer->expires, base->next_timer)) {
>  			base->next_timer = timer->expires;
> -	}
> +			/*
> +			 * CPU in dynticks need reevaluate the timer wheel
> +			 * if newer timer added with next_timer updated.
> +			 */
> +			if (base->nohz_active)
> +				kick_nohz = true;
> +		}
> +	} else if (base->nohz_active && tick_nohz_full_cpu(base->cpu))
> +		kick_nohz = true;
>  
>  	/*
>  	 * Check whether the other CPU is in dynticks mode and needs
> @@ -441,11 +451,8 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
>  	 * require special care against races with idle_cpu(), lets deal
>  	 * with that later.
>  	 */
> -	if (base->nohz_active) {
> -		if (!(timer->flags & TIMER_DEFERRABLE) ||
> -		    tick_nohz_full_cpu(base->cpu))
> -			wake_up_nohz_cpu(base->cpu);
> -	}
> +	if (kick_nohz)
> +		wake_up_nohz_cpu(base->cpu);
>  }


This patch makes sense. Thomas?

      parent reply	other threads:[~2015-11-13 16:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28 18:48 [PATCH] timer: Lazily wakup nohz CPU when adding new timer Yunhong Jiang
2015-10-05 20:51 ` Yunhong Jiang
2015-10-11 18:12 ` Thomas Gleixner
2015-10-20 22:47   ` Yunhong Jiang
2015-10-21 10:46     ` Viresh Kumar
2015-10-22 21:40       ` Yunhong Jiang
2015-10-23  2:19         ` Viresh Kumar
2015-10-23 22:10           ` Yunhong Jiang
2015-10-24  3:20             ` Viresh Kumar
2015-10-26 16:26               ` Yunhong Jiang
2015-10-27 15:11       ` Frederic Weisbecker
2015-11-13 16:13 ` Frederic Weisbecker [this message]

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=20151113161305.GC14397@lerouge \
    --to=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=yunhong.jiang@linux.intel.com \
    /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.