linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: leo.yan@linaro.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v3] cpuidle: menu: Handle stopped tick more aggressively
Date: Mon, 20 Aug 2018 12:15:41 +0200	[thread overview]
Message-ID: <20180820101541.GW2494@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180812145515.GB28966@leoy-ThinkPad-X240s>

On Sun, Aug 12, 2018 at 10:55:15PM +0800, leo.yan@linaro.org wrote:
> The first one issue is caused by timer cancel, I wrote one case for
> CPU_0 starting a hrtimer with pinned mode with short expire time and
> when the CPU_0 goes to sleep this short timeout timer can let idle
> governor selects a shallow state; at the meantime another CPU_1 will
> be used to try to cancel the timer, my purpose is to cheat CPU_0 so can
> see the CPU_0 staying in shallow state for long time;  it has low
> percentage to cancel the timer successfully, but I do see seldomly the
> timer can be canceled successfully so CPU_0 will stay in idle for long
> time (I cannot explain why the timer cannot be canceled successfully
> for every time, this might be another issue?).  This case is tricky,
> but it's possible happen in drivers with timer cancel.

So this is really difficuly to make hapen I think; you first need the
CPU to go deep idle, such that it disabled the tick. Then you have to
start the hrtimer there (using an IPI I suppose) which will then force
the governor to pick a shallow idle state, and then you have to cancel
the timer before it gets triggered.

And then, if the CPU stays perfectly idle, it will be stuck in that
shallow state... forever more.

_However_ IIRC when we (remotely) cancel an hrtimer, we do not in fact
reprogram the timer hardware. So the timer _will_ trigger.
hrtimer_interrupt() will observe nothing to do and reprogram the
hardware for the next timer (if there is one).

This should be enough to cycle through the idle loop and re-select an
idle state and avoid this whole problem.

If that is not happening, then something is busted and we need to figure
out what.

  parent reply	other threads:[~2018-08-20 10:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-10  7:34 [PATCH] cpuidle: menu: Handle stopped tick more aggressively Rafael J. Wysocki
2018-08-10  7:57 ` [PATCH v2] " Rafael J. Wysocki
2018-08-10  9:20   ` leo.yan
2018-08-10 11:04     ` Rafael J. Wysocki
2018-08-10 12:31       ` leo.yan
2018-08-12 10:07         ` Rafael J. Wysocki
2018-08-12 13:44           ` leo.yan
2018-08-13  7:58             ` Rafael J. Wysocki
2018-08-10 11:15   ` [PATCH v3] " Rafael J. Wysocki
2018-08-12 14:55     ` leo.yan
2018-08-13  8:11       ` Rafael J. Wysocki
2018-08-20 10:15       ` Peter Zijlstra [this message]
2018-08-13 11:26     ` [PATCH v4] " Rafael J. Wysocki
2018-08-14 10:34       ` [PATCH v5] " Rafael J. Wysocki
2018-08-14 15:44         ` leo.yan
2018-08-14 17:26           ` Rafael J. Wysocki
2018-08-20 11:04           ` Peter Zijlstra
2018-08-20 11:02         ` Peter Zijlstra
2018-08-11 16:32 ` [PATCH] " kbuild test robot
2018-08-12 22:13 ` Dan Carpenter

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=20180820101541.GW2494@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=frederic@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --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).