]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
clockevents: Shutdown and unregister current clockevents at CPUHP_AP_TICK_DYING
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 29 Oct 2024 12:54:43 +0000 (13:54 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 31 Oct 2024 09:41:42 +0000 (10:41 +0100)
commit3b1596a21fbf210f5b763fd3c0be280650475b52
tree76f3b8b3709e56f4914b0e3d28be40879b271f37
parent17a8945f369ce2de2532ba8abdb93bb5b2d1c118
clockevents: Shutdown and unregister current clockevents at CPUHP_AP_TICK_DYING

The way the clockevent devices are finally stopped while a CPU is
offlining is currently chaotic. The layout being by order:

1) tick_sched_timer_dying() stops the tick and the underlying clockevent
  but only for oneshot case. The periodic tick and its related
  clockevent still runs.

2) tick_broadcast_offline() detaches and stops the per-cpu oneshot
  broadcast and append it to the released list.

3) Some individual clockevent drivers stop the clockevents (a second time if
  the tick is oneshot)

4) Once the CPU is dead, a control CPU remotely detaches and stops
  (a 3rd time if oneshot mode) the CPU clockevent and adds it to the
  released list.

5) The released list containing the broadcast device released on step 2)
   and the remotely detached clockevent from step 4) are unregistered.

These random events can be factorized if the current clockevent is
detached and stopped by the dying CPU at the generic layer, that is
from the dying CPU:

a) Stop the tick
b) Stop/detach the underlying per-cpu oneshot broadcast clockevent
c) Stop/detach the underlying clockevent
d) Release / unregister the clockevents from b) and c)
e) Release / unregister the remaining clockevents from the dying CPU.
   This part could be performed by the dying CPU

This way the drivers and the tick layer don't need to care about
clockevent operations during cpuhotplug down. This also unifies the tick
behaviour on offline CPUs between oneshot and periodic modes, avoiding
offline ticks altogether for sanity.

Adopt the simplification.

[ tglx: Remove the WARN_ON() in clockevents_register_device() as that
   is called from an upcoming CPU before the CPU is marked online ]

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241029125451.54574-3-frederic@kernel.org
include/linux/tick.h
kernel/cpu.c
kernel/time/clockevents.c
kernel/time/tick-internal.h