From nobody Fri Apr 17 22:31:35 2026 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 57041C43334 for ; Thu, 21 Jul 2022 14:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbiGUO3D (ORCPT ); Thu, 21 Jul 2022 10:29:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbiGUO27 (ORCPT ); Thu, 21 Jul 2022 10:28:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9976781B2D for ; Thu, 21 Jul 2022 07:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658413737; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f1SjiiFwbm/IuhhOsQFJLO8wJ7hPNmr+cHkhaNf/rA4=; b=ffihKDqhPGDxUQL0//EGtp10vx4YlfihDr62R59qKeJG8x9HxmAwYIqMct1hNiX33C0xKd TBHD9XBJVDxbKbfCITsSRuDCOLXhqtLXVelC2Ti99X8N5uyzLo0PG6wgm5p+K72hckuLh8 Z7yjk9q0zEyDepcEvgHSZxK79IuQ6V4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-IGvYMb7_O2yLntOyMVlYsA-1; Thu, 21 Jul 2022 10:28:54 -0400 X-MC-Unique: IGvYMb7_O2yLntOyMVlYsA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 202A33C0E219; Thu, 21 Jul 2022 14:28:54 +0000 (UTC) Received: from pauld.bos.com (dhcp-17-237.bos.redhat.com [10.18.17.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC493404C6C9; Thu, 21 Jul 2022 14:28:53 +0000 (UTC) From: Phil Auld To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Valentin Schneider , Steven Price Subject: [PATCH v4 1/2] cpuhp: make target_store() a nop when target == state Date: Thu, 21 Jul 2022 10:28:51 -0400 Message-Id: <20220721142852.2712895-2-pauld@redhat.com> In-Reply-To: <20220721142852.2712895-1-pauld@redhat.com> References: <20220721142852.2712895-1-pauld@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Phil Auld Reviewed-by: Valentin Schneider --- kernel/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index bbad5e375d3b..979de993f853 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; --=20 2.31.1 From nobody Fri Apr 17 22:31:35 2026 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 146FAC433EF for ; Thu, 21 Jul 2022 14:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbiGUO3e (ORCPT ); Thu, 21 Jul 2022 10:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbiGUO3G (ORCPT ); Thu, 21 Jul 2022 10:29:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9FB3181B2D for ; Thu, 21 Jul 2022 07:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658413743; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g8hbGfcC3t7kTzh0ZPdNVBr4O3qAdtse/t3zfVgk4NA=; b=GxfzpQZBqZqMkuCR5kMomQNTu24hA572TOv44n6A96OZTGlGsow7NGVnqBuq2MlTTxVjq7 ZhybtQ+M37QSNyMHco2GFBfxA7Y/I9c3CVas2C9nGEMbC6JAA2PHOzANhWT9bLry1uvFxh yZ2XRYk8YIOTrYOUxJ3x0vufunkaDBg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-NpsUqWbLMJ2nJHMsgvV5hA-1; Thu, 21 Jul 2022 10:28:54 -0400 X-MC-Unique: NpsUqWbLMJ2nJHMsgvV5hA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50DAB294EDE2; Thu, 21 Jul 2022 14:28:54 +0000 (UTC) Received: from pauld.bos.com (dhcp-17-237.bos.redhat.com [10.18.17.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2903540CF916; Thu, 21 Jul 2022 14:28:54 +0000 (UTC) From: Phil Auld To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Valentin Schneider , Steven Price Subject: [PATCH v4 2/2] cpuhp: Set cpuhp target for boot cpu Date: Thu, 21 Jul 2022 10:28:52 -0400 Message-Id: <20220721142852.2712895-3-pauld@redhat.com> In-Reply-To: <20220721142852.2712895-1-pauld@redhat.com> References: <20220721142852.2712895-1-pauld@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since the boot cpu does not go through the hotplug process it ends up with state =3D=3D CPUHP_ONLINE but target =3D=3D CPUHP_OFFLINE. So set the target to match in boot_cpu_hotplug_init(). Signed-off-by: Phil Auld Reviewed-by: Valentin Schneider --- kernel/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 979de993f853..3f704a8896b0 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2690,6 +2690,7 @@ void __init boot_cpu_hotplug_init(void) cpumask_set_cpu(smp_processor_id(), &cpus_booted_once_mask); #endif this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); + this_cpu_write(cpuhp_state.target, CPUHP_ONLINE); } =20 /* --=20 2.31.1