linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: leo.yan@linaro.org
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched: idle: Reenable sched tick for cpuidle request
Date: Thu, 9 Aug 2018 19:17:26 +0800	[thread overview]
Message-ID: <20180809111726.GC14362@leoy-ThinkPad-X240s> (raw)
In-Reply-To: <20180809104549.GS2494@hirez.programming.kicks-ass.net>

On Thu, Aug 09, 2018 at 12:45:49PM +0200, Peter Zijlstra wrote:
> On Thu, Aug 09, 2018 at 01:47:27PM +0800, Leo Yan wrote:
> > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> > index 1a3e9bd..802286e 100644
> > --- a/kernel/sched/idle.c
> > +++ b/kernel/sched/idle.c
> > @@ -190,10 +190,18 @@ static void cpuidle_idle_call(void)
> >  		 */
> >  		next_state = cpuidle_select(drv, dev, &stop_tick);
> >  
> > -		if (stop_tick)
> > +		if (stop_tick) {
> >  			tick_nohz_idle_stop_tick();
> > -		else
> > +		} else {
> > +			/*
> > +			 * The cpuidle framework says to not stop tick but
> > +			 * the tick has been stopped yet, so restart it.
> > +			 */
> > +			if (tick_nohz_tick_stopped())
> > +				tick_nohz_idle_restart_tick();
> > +
> 
> I suspect you want an 'else' here. restart_tick already calls
> timer_clear_idle().

No, from the testing I found must call retain_tick, otherwise the
kernel compliants the warning from tick_nohz_idle_exit() when exit
from idle state:

        WARN_ON_ONCE(ts->timer_expires_base);

> >  			tick_nohz_idle_retain_tick();
> > +		}
> >  
> 
> However, I would rather we stuff all this into retain_tick.

Ah, yes; I tested below change and it also have same improvement for
idle state with my preivous change; please review if it's okay?

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index da9455a..fd2bfad 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -962,6 +962,10 @@ void tick_nohz_idle_stop_tick(void)
 
 void tick_nohz_idle_retain_tick(void)
 {
+       /* Restart the tikc if it has been stopped yet. */
+       if (tick_nohz_tick_stopped())
+               tick_nohz_idle_restart_tick();
+
        tick_nohz_retain_tick(this_cpu_ptr(&tick_cpu_sched));
        /*
         * Undo the effect of get_next_timer_interrupt() called from

Thanks,
Leo Yan

  reply	other threads:[~2018-08-09 11:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09  5:47 [PATCH] sched: idle: Reenable sched tick for cpuidle request Leo Yan
2018-08-09  6:57 ` leo.yan
2018-08-09 10:45 ` Peter Zijlstra
2018-08-09 11:17   ` leo.yan [this message]
2018-08-09 12:05 ` Rafael J. Wysocki
2018-08-09 15:42   ` Rafael J. Wysocki
2018-08-09 16:29     ` leo.yan
2018-08-09 16:43       ` Rafael J. Wysocki
2018-08-09 17:04         ` leo.yan
2018-08-09 17:06           ` Rafael J. Wysocki
2018-08-09 21:31         ` Rafael J. Wysocki
2018-08-10  5:53           ` leo.yan
2018-08-10  7:24             ` Rafael J. Wysocki

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=20180809111726.GC14362@leoy-ThinkPad-X240s \
    --to=leo.yan@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=vincent.guittot@linaro.org \
    /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).