Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4523344imw; Tue, 19 Jul 2022 08:10:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s8fdeDxGZm85JEj95Rgt/lTtnqpRiNJoVtzhVsDhoVrKaLbkCAldiViL2h7byl/mIEksbw X-Received: by 2002:a05:6870:c1c9:b0:fe:489c:ba41 with SMTP id i9-20020a056870c1c900b000fe489cba41mr22002812oad.270.1658243436383; Tue, 19 Jul 2022 08:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658243436; cv=none; d=google.com; s=arc-20160816; b=lSG1pjb56Yvj/84JQQ1lPwMLP01vWAq0HnRkw2R3efCuEhd35TqwO0zBjwNO8iEjYQ EvYPMqcbUCv3G1OxaQkImacSAPPZuwCm5V4wEeA4A/buEm3nB4DuiwPgAs2L0WgPfyFT z5DC4TEwfKjwg5BJloG85uKmyy0hAF8r9nRShmZuol/4mLvhXsnR+haK/z+EW2QQU6of olueqSvXOJCpKbgMClZAM4wogwA7QgTlHAvp7E9SzsSXB2ScF3dthKlO4ZrLh/w57Tlb v5GwcEPjBzkvo1YTJ97AGVYbeM76/Pc6/TTT3gqkV4CbD9MVQz/rRTA14E76t+X/0AcB 9JdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hO0GcOh2yvTNG+WhHrYEQsIpzVdakt9pGpX73qoC2no=; b=hrdPcuIpKRCB51/4ijqgVP7ItakcZcBdYtAjSacg0HL4fGq7AWgP/BamrZN991/a6G I7KPiFpAUschfNKGhuUFSfg7pV86RRc7m4pu9on/N5+Dc4Vz+l3/cVkVyYjQInB+REMF OFvVXM7BDlDcr8PKnSRqhHHGRTqFuxTeRuPl0/iwfMseR9Fwd5o0R0FFZPN3LpPCMS/W f7hc8JTM9yQFGhH1NayWLbPDOz98GktdtTUX3DpZH/3Pg2tY31unZ9FPel1ZjoYPUQoL iNeMvyQwiBdddYo1sMfsFvT4urur4H8hwOVDxCE7fs2w6oNfuHyVFyEWOGu3401ke1T+ MLxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G+jsYVwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020acad80a000000b0033a15ec04bfsi12707032oig.165.2022.07.19.08.10.22; Tue, 19 Jul 2022 08:10:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G+jsYVwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237933AbiGSPEX (ORCPT + 99 others); Tue, 19 Jul 2022 11:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237702AbiGSPDw (ORCPT ); Tue, 19 Jul 2022 11:03:52 -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 122FD4D167 for ; Tue, 19 Jul 2022 08:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658243031; 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: in-reply-to:in-reply-to:references:references; bh=hO0GcOh2yvTNG+WhHrYEQsIpzVdakt9pGpX73qoC2no=; b=G+jsYVwEJD8QF8HrAzwfKYNMmnoWQP6ixSvRTp1Tf+4x6kRt7z0WXX7pzlV3IRs3vkUACi mLDf1WHxDU5p1H6Yo4tHggP3+tdBCO/G8ExbiJOUwourCn62NfF2CDMBNi/OCi3w51Gh+L i6WeC6Xop/yJ9irRC5AUTRi7MfxrWWY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-aILb4swFM5i5n6AjkanRlg-1; Tue, 19 Jul 2022 11:03:41 -0400 X-MC-Unique: aILb4swFM5i5n6AjkanRlg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D59E882345; Tue, 19 Jul 2022 15:03:12 +0000 (UTC) Received: from lorien.usersys.redhat.com (unknown [10.22.17.107]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0417C40E80E0; Tue, 19 Jul 2022 15:03:11 +0000 (UTC) Date: Tue, 19 Jul 2022 11:03:10 -0400 From: Phil Auld To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Peter Zijlstra Subject: Re: [PATCH v3 1/2] cpuhp: make target_store() a nop when target == state Message-ID: References: <20220711211619.112854-1-pauld@redhat.com> <20220711211619.112854-2-pauld@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 19, 2022 at 03:34:03PM +0100 Valentin Schneider wrote: > On 11/07/22 17:16, Phil Auld wrote: > > 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 = cpu_up(dev->id, target); > > else > > ret = cpu_down(dev->id, target); > > > > cpu_down() -> cpu_set_state() > > bool bringup = st->state < target; > > ... > > if (cpu_dying(cpu) != !bringup) > > set_cpu_dying(cpu, !bringup); > > > > Fix this by letting state==target fall through in the target_store() > > conditional. Also make sure st->target == target in that case. > > > > Signed-off-by: Phil Auld > > One nit below, otherwise: > Reviewed-by: Valentin Schneider > Thanks! > > --- > > kernel/cpu.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/cpu.c b/kernel/cpu.c > > index bbad5e375d3b..305694a2ca26 100644 > > --- a/kernel/cpu.c > > +++ b/kernel/cpu.c > > @@ -2326,8 +2326,10 @@ static ssize_t target_store(struct device *dev, struct device_attribute *attr, > > > > if (st->state < target) > > ret = cpu_up(dev->id, target); > > - else > > + else if (st->state > target) > > ret = cpu_down(dev->id, target); > > + else if (st->target != target) > > Should we make this: > > else if (WARN(st->target != target)) > If you think that's important I can make it a WARN, sure. I'll try to remember to keep your Reviewed-bys this time if that's okay. Cheers, Phil > > + st->target = target; > > out: > > unlock_device_hotplug(); > > return ret ? ret : count; > > -- > > 2.31.1 > --