From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Anna-Maria Behnsen <anna-maria@linutronix.de>
Subject: [PATCH 03/10] cpuidle: Report illegal tick stopped while polling
Date: Fri, 11 Aug 2023 19:00:42 +0200 [thread overview]
Message-ID: <20230811170049.308866-4-frederic@kernel.org> (raw)
In-Reply-To: <20230811170049.308866-1-frederic@kernel.org>
poll_idle() can't be called while the tick is stopped because it enables
interrupts and only polls on TIF_NEED_RESCHED, which doesn't tell if an
interrupt queues a timer that would require a tick re-programming.
There is no point anyway to poll with the tick stopped so add a check
to make sure it never happens.
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
drivers/cpuidle/poll_state.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c
index 9b6d90a72601..009f46f121ae 100644
--- a/drivers/cpuidle/poll_state.c
+++ b/drivers/cpuidle/poll_state.c
@@ -7,6 +7,7 @@
#include <linux/sched.h>
#include <linux/sched/clock.h>
#include <linux/sched/idle.h>
+#include <linux/tick.h>
#define POLL_IDLE_RELAX_COUNT 200
@@ -19,6 +20,13 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
dev->poll_time_limit = false;
+ /*
+ * This re-enables IRQs and only polls on TIF_NEED_RESCHED.
+ * A timer queued by an interrupt here may go unnoticed if
+ * the tick is stopped.
+ */
+ WARN_ON_ONCE(tick_nohz_tick_stopped());
+
raw_local_irq_enable();
if (!current_set_polling_and_test()) {
unsigned int loop_count = 0;
--
2.34.1
next prev parent reply other threads:[~2023-08-11 17:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 17:00 [PATCH 00/10] timers/cpuidle: Fixes and cleanups Frederic Weisbecker
2023-08-11 17:00 ` [PATCH 01/10] x86: Add a comment about the "magic" behind shadow sti before mwait Frederic Weisbecker
2023-08-11 17:44 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 02/10] cpuidle: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram Frederic Weisbecker
2023-08-11 17:35 ` Rafael J. Wysocki
2023-08-11 17:00 ` Frederic Weisbecker [this message]
2023-08-11 17:37 ` [PATCH 03/10] cpuidle: Report illegal tick stopped while polling Rafael J. Wysocki
2023-08-29 13:04 ` Frederic Weisbecker
2023-08-11 17:00 ` [PATCH 04/10] loongson: Fix idle VS timer enqueue Frederic Weisbecker
2023-08-14 2:58 ` bibo mao
2023-08-11 17:00 ` [PATCH 05/10] cpuidle: Comment about timers requirements VS idle handler Frederic Weisbecker
2023-08-11 17:38 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 06/10] cpuidle: Remove unnecessary current_clr_polling_and_test() from haltpoll Frederic Weisbecker
2023-08-11 17:39 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 07/10] cpuidle: Remove unnecessary current_clr_polling() on poll_idle() Frederic Weisbecker
2023-08-11 17:40 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 08/10] x86: Remove __current_clr_polling() from mwait_idle() Frederic Weisbecker
2023-08-11 17:40 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 09/10] x86: Remove the current_clr_polling() call upon mwait exit Frederic Weisbecker
2023-08-11 17:41 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 10/10] sched/timers: Explain why idle task schedules out on remote timer enqueue Frederic Weisbecker
2023-08-11 17:43 ` Rafael J. Wysocki
2023-08-15 16:10 ` [PATCH 00/10] timers/cpuidle: Fixes and cleanups Peter Zijlstra
2023-08-29 11:28 ` Frederic Weisbecker
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=20230811170049.308866-4-frederic@kernel.org \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--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