WSL2-Linux-Kernel/kernel/time
Yu Liao d3b165c104 tick/broadcast: Make takeover of broadcast hrtimer reliable
commit f7d43dd206e7e18c182f200e67a8db8c209907fa upstream.

Running the LTP hotplug stress test on a aarch64 machine results in
rcu_sched stall warnings when the broadcast hrtimer was owned by the
un-plugged CPU. The issue is the following:

CPU1 (owns the broadcast hrtimer)	CPU2

				tick_broadcast_enter()
				  // shutdown local timer device
				  broadcast_shutdown_local()
				...
				tick_broadcast_exit()
				  clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT)
				  // timer device is not programmed
				  cpumask_set_cpu(cpu, tick_broadcast_force_mask)

				initiates offlining of CPU1
take_cpu_down()
/*
 * CPU1 shuts down and does not
 * send broadcast IPI anymore
 */
				takedown_cpu()
				  hotplug_cpu__broadcast_tick_pull()
				    // move broadcast hrtimer to this CPU
				    clockevents_program_event()
				      bc_set_next()
					hrtimer_start()
					/*
					 * timer device is not programmed
					 * because only the first expiring
					 * timer will trigger clockevent
					 * device reprogramming
					 */

What happens is that CPU2 exits broadcast mode with force bit set, then the
local timer device is not reprogrammed and CPU2 expects to receive the
expired event by the broadcast IPI. But this does not happen because CPU1
is offlined by CPU2. CPU switches the clockevent device to ONESHOT state,
but does not reprogram the device.

The subsequent reprogramming of the hrtimer broadcast device does not
program the clockevent device of CPU2 either because the pending expiry
time is already in the past and the CPU expects the event to be delivered.
As a consequence all CPUs which wait for a broadcast event to be delivered
are stuck forever.

Fix this issue by reprogramming the local timer device if the broadcast
force bit of the CPU is set so that the broadcast hrtimer is delivered.

[ tglx: Massage comment and change log. Add Fixes tag ]

Fixes: 989dcb645c ("tick: Handle broadcast wakeup of multiple cpus")
Signed-off-by: Yu Liao <liaoyu15@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240711124843.64167-1-liaoyu15@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-19 05:45:10 +02:00
..
Kconfig
Makefile
alarmtimer.c
clockevents.c
clocksource-wdtest.c
clocksource.c clocksource: Skip watchdog check for large watchdog intervals 2024-02-23 08:55:01 +01:00
hrtimer.c hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() 2024-02-23 08:55:14 +01:00
itimer.c
jiffies.c
namespace.c
ntp.c
ntp_internal.h
posix-clock.c
posix-cpu-timers.c
posix-stubs.c
posix-timers.c posix-timers: Ensure timer ID search-loop limit is valid 2024-03-01 13:21:55 +01:00
posix-timers.h
sched_clock.c
test_udelay.c
tick-broadcast-hrtimer.c
tick-broadcast.c tick/broadcast: Make takeover of broadcast hrtimer reliable 2024-08-19 05:45:10 +02:00
tick-common.c tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device() 2024-07-05 09:14:22 +02:00
tick-internal.h
tick-legacy.c
tick-oneshot.c
tick-sched.c tick/sched: Preserve number of idle sleeps across CPU hotplug events 2024-02-23 08:54:36 +01:00
tick-sched.h tick: Detect and fix jiffies update stall 2023-08-16 18:22:04 +02:00
time.c
time_test.c time: test: Fix incorrect format specifier 2024-03-26 18:21:15 -04:00
timeconst.bc
timeconv.c
timecounter.c
timekeeping.c timekeeping: Fix cross-timestamp interpolation for non-x86 2024-03-26 18:21:15 -04:00
timekeeping.h
timekeeping_debug.c
timekeeping_internal.h
timer.c timers: Rename del_timer_sync() to timer_delete_sync() 2024-04-10 16:18:33 +02:00
timer_list.c
vsyscall.c