From: Frederic Weisbecker <frederic@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>
Subject: [PATCH 4/6] timers/migration: Assert that hotplug preparing CPU is part of stable active hierarchy
Date: Fri, 24 Oct 2025 15:25:34 +0200 [thread overview]
Message-ID: <20251024132536.39841-5-frederic@kernel.org> (raw)
In-Reply-To: <20251024132536.39841-1-frederic@kernel.org>
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>
---
kernel/time/timer_migration.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 49635a2b7ee2..bddd816faaeb 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1703,6 +1703,7 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node,
if (activate) {
struct tmigr_walk data;
+ union tmigr_state state;
/*
* 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,
* the new childmask and parent to subsequent walkers through this
* @child. Therefore propagate active state unconditionally.
*/
+ state.state = atomic_read(&start->migr_state);
+ WARN_ON_ONCE(!state.active);
WARN_ON_ONCE(!start->parent);
data.childmask = start->groupmask;
__walk_groups_from(tmigr_active_up, &data, start, start->parent);
@@ -1768,6 +1771,11 @@ static int tmigr_add_cpu(unsigned int cpu)
* active or not) and/or release an uninitialized childmask.
*/
WARN_ON_ONCE(cpu == raw_smp_processor_id());
+ /*
+ * The (likely) current CPU is expected to be online in the hierarchy,
+ * otherwise the old root may not be active as expected.
+ */
+ WARN_ON_ONCE(!per_cpu_ptr(&tmigr_cpu, raw_smp_processor_id())->online);
ret = tmigr_setup_groups(-1, old_root->numa_node, old_root, true);
}
--
2.51.0
next prev parent reply other threads:[~2025-10-24 13:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 13:25 [PATCH 0/6] timers/migration: Fix NUMA trees + cleanups Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 1/6] timers/migration: Convert "while" loops to use "for" Frederic Weisbecker
2025-11-01 19:41 ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 2/6] timers/migration: Remove locking on group connection Frederic Weisbecker
2025-11-01 19:41 ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 3/6] timers/migration: Fix imbalanced NUMA trees Frederic Weisbecker
2025-11-01 19:41 ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` Frederic Weisbecker [this message]
2025-11-01 19:41 ` [tip: timers/core] timers/migration: Assert that hotplug preparing CPU is part of stable active hierarchy tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 5/6] timers/migration: Remove unused "cpu" parameter from tmigr_get_group() Frederic Weisbecker
2025-11-01 19:41 ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 6/6] timers/migration: Remove dead code handling idle CPU checking for remote timers Frederic Weisbecker
2025-11-01 19:41 ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251024132536.39841-5-frederic@kernel.org \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox