Skip to content

Commit 3c8eb36

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
timers/migration: Assert that hotplug preparing CPU is part of stable active hierarchy
The CPU doing the prepare work for a remote target must be online from the tree point of view and its hierarchy must be active, otherwise propagating its active state up to the new root branch would be either incorrect or racy. Assert those conditions with more sanity checks. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://patch.msgid.link/20251024132536.39841-5-frederic@kernel.org
1 parent 5eb579d commit 3c8eb36

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

kernel/time/timer_migration.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,7 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node,
17031703

17041704
if (activate) {
17051705
struct tmigr_walk data;
1706+
union tmigr_state state;
17061707

17071708
/*
17081709
* To prevent inconsistent states, active children need to be active in
@@ -1726,6 +1727,8 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node,
17261727
* the new childmask and parent to subsequent walkers through this
17271728
* @child. Therefore propagate active state unconditionally.
17281729
*/
1730+
state.state = atomic_read(&start->migr_state);
1731+
WARN_ON_ONCE(!state.active);
17291732
WARN_ON_ONCE(!start->parent);
17301733
data.childmask = start->groupmask;
17311734
__walk_groups_from(tmigr_active_up, &data, start, start->parent);
@@ -1768,6 +1771,11 @@ static int tmigr_add_cpu(unsigned int cpu)
17681771
* active or not) and/or release an uninitialized childmask.
17691772
*/
17701773
WARN_ON_ONCE(cpu == raw_smp_processor_id());
1774+
/*
1775+
* The (likely) current CPU is expected to be online in the hierarchy,
1776+
* otherwise the old root may not be active as expected.
1777+
*/
1778+
WARN_ON_ONCE(!per_cpu_ptr(&tmigr_cpu, raw_smp_processor_id())->online);
17711779
ret = tmigr_setup_groups(-1, old_root->numa_node, old_root, true);
17721780
}
17731781

0 commit comments

Comments
 (0)