hrtimer: Retrigger local timers after clock changes
PATCH 1/1 hrtimer: Retrigger local timers after clock changes
clock_was_set() selects CPUs whose hrtimer deadlines move earlier after a clock change. smp_call_function_many() excludes the calling CPU even when it is in the mask, leaving its clock event programmed for the old deadline. An overdue realtime timer can then expire only when a later event triggers timer handling.
Use on_each_cpu_mask() to retrigger the local CPU when selected, without interrupting CPUs with unaffected deadlines.
--- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/hrtimer.c +1 -1
@@ -1000,7 +1000,7 @@ void clock_was_set(unsigned int bases)cpumask_set_cpu (cpu, mask); } scoped_guard(preempt) - smp_call_function_many(mask, retrigger_next_event, NULL, 1); + on_each_cpu_mask(mask, retrigger_next_event, NULL, 1); } free_cpumask_var(mask);
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
Signature · 1 line
2.43.0
Quoted 20 lines · Avi Weiss
clock_was_set()selects CPUs whose hrtimer deadlines move earlier after a clock change.smp_call_function_many()excludes the calling CPU even when it is in the mask, leaving its clock event programmed for the old deadline. An overdue realtime timer can then expire only when a later event triggers timer handling.Use
on_each_cpu_mask()to retrigger the local CPU when selected, without interrupting CPUs with unaffected deadlines.Fixes 81d741d3460c ("hrtimer: Avoid unnecessary SMP function calls in clock_was_set()")Signed-off-by Avi Weiss <[email protected]>--- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/time/hrtimer.c +0
-0
kernel/time/hrtimer.c void clock_was_set(unsigned int bases) · line 1003
Quoted 5 lines
kernel/time/hrtimer.c +0
-1@@ -1000,7 +1000,7 @@ void clock_was_set(unsigned int bases)cpumask_set_cpu (cpu, mask); }scoped_guard (preempt) - smp_call_function_many(mask, retrigger_next_event, NULL, 1);
Heh, this API is so error prone... If it really doesn't want to call on the local CPU (for some undescribed reason), it should at least be renamed to smp_call_function_many_butself().
kernel/time/hrtimer.c void clock_was_set(unsigned int bases) · line 1003
Quoted 1 line
kernel/time/hrtimer.c +1
-0+on_each_cpu_mask (mask, retrigger_next_event,NULL ,1 );
Signature · 2 lines
Frederic Weisbecker SUSE Labs
The following commit has been merged into the timers/core branch of tip:
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 81b8beef105bd9151ca1fa2e0796933a46adb670 Gitweb: https://git.kernel.org/tip/81b8beef105bd9151ca1fa2e0796933a46adb670 Author: Avi Weiss <[email protected]> AuthorDate: Sun, 01 Nov 2026 16:15:53 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Mon, 09 Nov 2026 20:25:25 +01:00
hrtimer: Retrigger local timers after clock changes
clock_was_set() selects CPUs whose hrtimer deadlines move earlier after a clock change. smp_call_function_many() excludes the calling CPU even when it is in the mask, leaving its clock event programmed for the old deadline. An overdue realtime timer can then expire only when a later event triggers timer handling.
Use on_each_cpu_mask() to retrigger the local CPU when selected, without interrupting CPUs with unaffected deadlines.
--- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/hrtimer.c +1 -1
@@ -1000,7 +1000,7 @@ void clock_was_set(unsigned int bases)cpumask_set_cpu (cpu, mask); } scoped_guard(preempt) - smp_call_function_many(mask, retrigger_next_event, NULL, 1); + on_each_cpu_mask(mask, retrigger_next_event, NULL, 1); } free_cpumask_var(mask);