From nobody Thu Sep 18 21:40:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9562FC43217 for ; Thu, 1 Dec 2022 11:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbiLALlj (ORCPT ); Thu, 1 Dec 2022 06:41:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbiLALl2 (ORCPT ); Thu, 1 Dec 2022 06:41:28 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 380429582D; Thu, 1 Dec 2022 03:41:27 -0800 (PST) Date: Thu, 01 Dec 2022 11:41:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669894885; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VZMu+Ww/tIWv7+5nct9Y8zaEczZTGJtowfe2b2w4XBM=; b=cl33zYaBw6+x2HTKq3LZVbuQ9BL+d3PIERTDStFib0yXCudGYX/8vUNEiXX18IWLl+SrmN xoflbDH2hujPJ5Ld0nQKoUreVJqlChZMdnPMq/JEp4UbrXEJt2ZhZtMjDHAygMSkINdpgk 36HRG0Zzil2VSCMa7RMRR54qRuOhERpIj+aFa+0hcArmz8z2+KXAn7nXJ7uE3yD8zQEJaR KcWwtKYMW8w01gv/Fs/NQ7e70grmvYpCm40dF9c33Aat0aFHcAwbkGeuZHu1uu5rVw463H B8w7Y1WlmNQpi/t7niTtcIKkhY5IfsOdcCrUJ5ILH8MBPggVwG0kg5sHe0N2RA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669894885; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VZMu+Ww/tIWv7+5nct9Y8zaEczZTGJtowfe2b2w4XBM=; b=bb982MO/MHk4b6IlgtjlobBPYW8hV7N3JziIi3RwB7Mu4lWXF7CjxSkLWxR+QJxHnDuvyV g8l9F/fd1mZNeZDg== From: "tip-bot2 for Phil Auld" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpuhp: Make target_store() a nop when target == state Cc: Phil Auld , Thomas Gleixner , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221117162329.3164999-2-pauld@redhat.com> References: <20221117162329.3164999-2-pauld@redhat.com> MIME-Version: 1.0 Message-ID: <166989488463.4906.8715334204096231628.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the smp/core branch of tip: Commit-ID: 0fa5abb6b7d85bf5688b2e11113f50317fb0121c Gitweb: https://git.kernel.org/tip/0fa5abb6b7d85bf5688b2e11113f50317= fb0121c Author: Phil Auld AuthorDate: Thu, 17 Nov 2022 11:23:28 -05:00 Committer: Thomas Gleixner CommitterDate: Thu, 01 Dec 2022 12:35:08 +01:00 cpuhp: Make target_store() a nop when target =3D=3D state Writing the current state back in hotplug/target calls cpu_down() which will set cpu dying even when it isn't and then nothing will ever clear it. A stress test that reads values and writes them back for all cpu device files in sysfs will trigger the BUG() in select_fallback_rq once all cpus are marked as dying. kernel/cpu.c::target_store() ... if (st->state < target) ret =3D cpu_up(dev->id, target); else ret =3D cpu_down(dev->id, target); cpu_down() -> cpu_set_state() bool bringup =3D st->state < target; ... if (cpu_dying(cpu) !=3D !bringup) set_cpu_dying(cpu, !bringup); Fix this by letting state=3D=3Dtarget fall through in the target_store() conditional. Also make sure st->target =3D=3D target in that case. Fixes: 757c989b9994 ("cpu/hotplug: Make target state writeable") Signed-off-by: Phil Auld Signed-off-by: Thomas Gleixner Reviewed-by: Valentin Schneider Link: https://lore.kernel.org/r/20221117162329.3164999-2-pauld@redhat.com --- kernel/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index bbad5e3..979de99 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2326,8 +2326,10 @@ static ssize_t target_store(struct device *dev, stru= ct device_attribute *attr, =20 if (st->state < target) ret =3D cpu_up(dev->id, target); - else + else if (st->state > target) ret =3D cpu_down(dev->id, target); + else if (WARN_ON(st->target !=3D target)) + st->target =3D target; out: unlock_device_hotplug(); return ret ? ret : count;