Skip to content

Commit 156677e

Browse files
fenghusthugregkh
authored andcommitted
hrtimers: Unconditionally update target CPU base after offline timer migration
[ Upstream commit e895f8e ] When testing softirq based hrtimers on an ARM32 board, with high resolution mode and NOHZ inactive, softirq based hrtimers fail to expire after being moved away from an offline CPU: CPU0 CPU1 hrtimer_start(..., HRTIMER_MODE_SOFT); cpu_down(CPU1) ... hrtimers_cpu_dying() // Migrate timers to CPU0 smp_call_function_single(CPU0, returgger_next_event); retrigger_next_event() if (!highres && !nohz) return; As retrigger_next_event() is a NOOP when both high resolution timers and NOHZ are inactive CPU0's hrtimer_cpu_base::softirq_expires_next is not updated and the migrated softirq timers never expire unless there is a softirq based hrtimer queued on CPU0 later. Fix this by removing the hrtimer_hres_active() and tick_nohz_active() check in retrigger_next_event(), which enforces a full update of the CPU base. As this is not a fast path the extra cost does not matter. [ tglx: Massaged change log ] Fixes: 5c0930c ("hrtimers: Push pending hrtimers away from outgoing CPU earlier") Co-developed-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250805081025.54235-1-wangxiongfeng2@huawei.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b1fa39f commit 156677e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

kernel/time/hrtimer.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,10 +808,10 @@ static void retrigger_next_event(void *arg)
808808
* of the next expiring timer is enough. The return from the SMP
809809
* function call will take care of the reprogramming in case the
810810
* CPU was in a NOHZ idle sleep.
811+
*
812+
* In periodic low resolution mode, the next softirq expiration
813+
* must also be updated.
811814
*/
812-
if (!hrtimer_hres_active(base) && !tick_nohz_active)
813-
return;
814-
815815
raw_spin_lock(&base->lock);
816816
hrtimer_update_base(base);
817817
if (hrtimer_hres_active(base))
@@ -2289,11 +2289,6 @@ int hrtimers_cpu_dying(unsigned int dying_cpu)
22892289
&new_base->clock_base[i]);
22902290
}
22912291

2292-
/*
2293-
* The migration might have changed the first expiring softirq
2294-
* timer on this CPU. Update it.
2295-
*/
2296-
__hrtimer_get_next_event(new_base, HRTIMER_ACTIVE_SOFT);
22972292
/* Tell the other CPU to retrigger the next event */
22982293
smp_call_function_single(ncpu, retrigger_next_event, NULL, 0);
22992294

0 commit comments

Comments
 (0)