From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Chen Yu <yu.c.chen@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Len Brown <len.brown@intel.com>,
Linux PM <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Len Brown <lenb@kernel.org>
Subject: Re: [PATCH 1/2][v3] PM / s2idle: Clear _TIF_POLLING_NRFLAG before suspend to idle
Date: Tue, 23 Jun 2020 17:13:11 +0200 [thread overview]
Message-ID: <CAJZ5v0gJqPX55HvGb7dn8dV5jr3-MPNQHTRbsYCN47zp07VhsQ@mail.gmail.com> (raw)
In-Reply-To: <55caab9c03a0d6c3c0a1f45294d6c274b73c954b.1592892767.git.yu.c.chen@intel.com>
On Tue, Jun 23, 2020 at 8:30 AM Chen Yu <yu.c.chen@intel.com> wrote:
>
> Suspend to idle was found to not work on Goldmont CPU recently.
> And the issue was triggered due to:
>
> 1. On Goldmont the CPU in idle can only be woken up via IPIs,
> not POLLING mode:
> Commit 08e237fa56a1 ("x86/cpu: Add workaround for MONITOR
> instruction erratum on Goldmont based CPUs")
> 2. When the CPU is entering suspend to idle process, the
> _TIF_POLLING_NRFLAG is kept on, due to cpuidle_enter_s2idle()
> doesn't properly match call_cpuidle().
> 3. Commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()")
> makes use of _TIF_POLLING_NRFLAG to avoid sending IPIs to
> idle CPUs.
> 4. As a result, some IPIs related functions might not work
> well during suspend to idle on Goldmont. For example, one
> suspected victim:
> tick_unfreeze() -> timekeeping_resume() -> hrtimers_resume()
> -> clock_was_set() -> on_each_cpu() might wait forever,
> because the IPIs will not be sent to the CPUs which are
> sleeping with _TIF_POLLING_NRFLAG set, and Goldmont CPU
> could not be woken up by only setting _TIF_NEED_RESCHED
> on the monitor address.
>
> Clear the _TIF_POLLING_NRFLAG flag before entering suspend to idle,
> and let the driver's enter_s2idle() to decide whether to set
> _TIF_POLLING_NRFLAG or not. So that to avoid the scenario described
> above and keep the context consistent with before.
>
> Fixes: b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()")
> Reported-by: kbuild test robot <lkp@intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Len Brown <lenb@kernel.org>
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Applied (based on the previous discussion) with some subject and
changelog edits.
Thanks!
> ---
> v2: According to Peter's review, v1 is racy, if someone already
> set TIF_NEED_RESCHED this patch just clear POLLING and go to sleep.
> Check TIF_NEED_RESCHED before entering suspend to idle and
> adjust the naming to be consistent with call_cpuidle().
>
> v3: According to Rafael, it would be better to do the simplest fix
> first and then do the cleanup on top of it.
> ---
> drivers/cpuidle/cpuidle.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index c149d9e20dfd..e092789187c6 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -13,6 +13,7 @@
> #include <linux/mutex.h>
> #include <linux/sched.h>
> #include <linux/sched/clock.h>
> +#include <linux/sched/idle.h>
> #include <linux/notifier.h>
> #include <linux/pm_qos.h>
> #include <linux/cpu.h>
> @@ -186,7 +187,7 @@ int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev)
> * be frozen safely.
> */
> index = find_deepest_state(drv, dev, U64_MAX, 0, true);
> - if (index > 0)
> + if (index > 0 && !current_clr_polling_and_test())
> enter_s2idle_proper(drv, dev, index);
>
> return index;
> --
> 2.17.1
>
next prev parent reply other threads:[~2020-06-23 15:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 6:31 [PATCH 0/2][v3] Fix IPI missing issue when woken from suspend to idle Chen Yu
2020-06-23 6:31 ` [PATCH 1/2][v3] PM / s2idle: Clear _TIF_POLLING_NRFLAG before " Chen Yu
2020-06-23 15:13 ` Rafael J. Wysocki [this message]
2020-06-23 6:31 ` [PATCH 2/2][v3] PM / s2idle: Code cleanup to make s2idle consistent with normal idle path Chen Yu
2020-06-23 17:57 ` Rafael J. Wysocki
2020-06-25 5:15 ` Chen Yu
2020-06-25 10:49 ` 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=CAJZ5v0gJqPX55HvGb7dn8dV5jr3-MPNQHTRbsYCN47zp07VhsQ@mail.gmail.com \
--to=rafael@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=len.brown@intel.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=yu.c.chen@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 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).