summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAnna-Maria Behnsen <anna-maria@linutronix.de>2024-02-21 10:05:32 +0100
committerThomas Gleixner <tglx@linutronix.de>2024-02-22 17:52:30 +0100
commit73129cf4b69cd1aaa3dd5eb7900a9c349773f5ae (patch)
tree2a64ebb268d4bb9de36d266b29b5975ca53a9a56 /kernel
parenttimers: Move marking timer bases idle into tick_nohz_stop_tick() (diff)
downloadlinux-73129cf4b69cd1aaa3dd5eb7900a9c349773f5ae.tar.xz
linux-73129cf4b69cd1aaa3dd5eb7900a9c349773f5ae.zip
timers: Optimization for timer_base_try_to_set_idle()
When tick is stopped also the timer base is_idle flag is set. When reentering timer_base_try_to_set_idle() with the tick stopped, there is no need to check whether the timer base needs to be set idle again. When a timer was enqueued in the meantime, this is already handled by the tick_nohz_next_event() call which was executed before tick_nohz_stop_tick(). Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lore.kernel.org/r/20240221090548.36600-5-anna-maria@linutronix.de
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/tick-sched.c2
-rw-r--r--kernel/time/timer.c11
2 files changed, 9 insertions, 4 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 344b904f520f..f6b613380229 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -896,7 +896,7 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
unsigned long basejiff = ts->last_jiffies;
u64 basemono = ts->timer_expires_base;
- bool timer_idle;
+ bool timer_idle = ts->tick_stopped;
u64 expires;
/* Make sure we won't be trying to stop it twice in a row. */
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index a4b8a58d05e5..74cfe21f8fd9 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -2044,13 +2044,18 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
* timer_base_try_to_set_idle() - Try to set the idle state of the timer bases
* @basej: base time jiffies
* @basem: base time clock monotonic
- * @idle: pointer to store the value of timer_base->is_idle
+ * @idle: pointer to store the value of timer_base->is_idle on return;
+ * *idle contains the information whether tick was already stopped
*
- * Returns the tick aligned clock monotonic time of the next pending
- * timer or KTIME_MAX if no timer is pending.
+ * Returns the tick aligned clock monotonic time of the next pending timer or
+ * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is
+ * returned as well.
*/
u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle)
{
+ if (*idle)
+ return KTIME_MAX;
+
return __get_next_timer_interrupt(basej, basem, idle);
}