From nobody Mon Dec 1 22:05:03 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14AD817C203 for ; Thu, 27 Nov 2025 14:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764254847; cv=none; b=VuL+i7eo6NNL3C9GdoW2hr9uI7RcfQIUcDArlCBA0Dq8YXO0noGFm8VyxxyZKjXIXAczi9kOfCIEMkDP8/j4QM53yQEk2W7ykVfs8PF+heq2CuoeUU3XUZe2ACcb3EOVTA4r15Qmw0piUu2RKP8UVE7h+tBhLrZFlXCBnodUkf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764254847; c=relaxed/simple; bh=2uv0kGKRlu4zX5QIqpmb/5CHf8Mp06a0lsgWfS/S3BA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=giAm06tYo719vjxOR1WerqNFF3lFa8XeqtgKuf7iYWrLTReJQlgs8gUCt9NzWTQZho5koApuFdlrnFdVZNJCjW8dOaky+aMv/g/l8YJw4plUjbzJeGrU+eIUbEOnRHDpPadG0pqZ9pO3coFdxF9rqe5F/hmOihL/A71r3rr8Xnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aKnA7A0D; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pG6tikrS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aKnA7A0D"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pG6tikrS" Date: Thu, 27 Nov 2025 15:47:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1764254844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=hrdmZFXM29gCnAV/k0NWiu56d590hcGBKQ+9cqeV3eY=; b=aKnA7A0DPQJvcQ/Yf158sn8wUenWv+sS+2R9CuQLdAmEFrxfkHCCkDy6W/rgVxZXrqaYyx Yve4qVJTRPbw8qzSRiRKulrWivEy1tYbiktI4molMqRvbj8r0wj6k1qPuAvDxr9zCF79nd ac29gB5R3ZsvKE6Gr8+kS2MJCW2X66dclD/DqI97STPgK7HE7ss1pP3GKmt0XrPFkYLvYt MV58BKwLF4ZCbAMMFBCfmKZ1lDYwXGyo3Y2IXNQmggdQxs7uXdzMg5rSWMJ8Evt5p28+4p DlobRom+0bnU+plFIqJmJyrvab1SZq7BATbW1l1+PqjsNVwLdBpQgBp6LKrzXw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1764254844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=hrdmZFXM29gCnAV/k0NWiu56d590hcGBKQ+9cqeV3eY=; b=pG6tikrSIylLGaKPLuTKDXaG84KJS0oOpAqVvVN6Vm6GKZQjOSc3fNGRtQXtdEw92vwNou 9JV4ZRQLEkWowPAw== From: Sebastian Andrzej Siewior To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar Subject: [PATCH REPOST v2] cpu: Make atomic callbacks run on UP with disabled interrupts Message-ID: <20251127144723.ev9DuXXR@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On SMP callbacks in the "starting" range are invoked while the CPU is brought up and interrupts are still disabled. Callbacks which are added later ar invoked via the hotplug-thread on the target CPU and interrupts are explicitly disabled. In the UP case callbacks which are added later are invoked "directly" without the thread. This is okay since there is just one CPU but with enabled interrupts debug code, such as smp_processor_id(), will issue warnings. Disable interrupts before invoking the calback on UP if the state is atomic and interrupts are expected to be disabled. The "save" part is required because this is also invoked early in the boot process while interrupts are disabled and must not be enabled. Fixes: 06ddd17521bf1 ("sched/smp: Always define is_percpu_thread() and sche= duler_ipi()") Signed-off-by: Sebastian Andrzej Siewior --- Not in -next, repost of https://lore.kernel.org/all/20251103132820.0llS_QPg@linutronix.de/ kernel/cpu.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index b674fdf96208b..9c5ba57955a3d 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -249,6 +249,14 @@ static int cpuhp_invoke_callback(unsigned int cpu, enu= m cpuhp_state state, return ret; } =20 +/* + * The former STARTING/DYING states, ran with IRQs disabled and must not f= ail. + */ +static bool cpuhp_is_atomic_state(enum cpuhp_state state) +{ + return CPUHP_AP_IDLE_DEAD <=3D state && state < CPUHP_AP_ONLINE; +} + #ifdef CONFIG_SMP static bool cpuhp_is_ap_state(enum cpuhp_state state) { @@ -271,14 +279,6 @@ static inline void complete_ap_thread(struct cpuhp_cpu= _state *st, bool bringup) complete(done); } =20 -/* - * The former STARTING/DYING states, ran with IRQs disabled and must not f= ail. - */ -static bool cpuhp_is_atomic_state(enum cpuhp_state state) -{ - return CPUHP_AP_IDLE_DEAD <=3D state && state < CPUHP_AP_ONLINE; -} - /* Synchronization state management */ enum cpuhp_sync_state { SYNC_STATE_DEAD, @@ -2364,7 +2364,16 @@ static int cpuhp_issue_call(int cpu, enum cpuhp_stat= e state, bool bringup, else ret =3D cpuhp_invoke_callback(cpu, state, bringup, node, NULL); #else - ret =3D cpuhp_invoke_callback(cpu, state, bringup, node, NULL); + if (cpuhp_is_atomic_state(state)) { + guard(irqsave)(); + ret =3D cpuhp_invoke_callback(cpu, state, bringup, node, NULL); + /* + * STARTING/DYING must not fail! + */ + WARN_ON_ONCE(ret); + } else { + ret =3D cpuhp_invoke_callback(cpu, state, bringup, node, NULL); + } #endif BUG_ON(ret && !bringup); return ret; --=20 2.51.0