Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3722719imw; Mon, 11 Jul 2022 14:32:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uwMthTIbnibIaeTMqB2INUjAWLUoyMl09yZylwlVT5wh6mK9Yw8KsiMxWiPvPEAPUDTm7S X-Received: by 2002:a05:6402:43c4:b0:43a:6309:6c9b with SMTP id p4-20020a05640243c400b0043a63096c9bmr27272941edc.91.1657575140362; Mon, 11 Jul 2022 14:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657575140; cv=none; d=google.com; s=arc-20160816; b=aKTMb/D4YgYxT3ppmmMjay3IJrY1Netm8/DyYBUkas/eq6BA/6PFGIW0np2raId56O GyDzPENLb50ZTJFVg8Un6bpTwqhKIFwvQJcagmtaGGqF2+KhYn2w3KwRJeaPpt/OV9oc yOZrSDsgcD1sdAT0O5s6wf2ydEJ411CrvtW7gDhwoOaWZfg/IGz/VnLbcIPPMh60xCSz i41tGn3puTT64m8hUe/Y/BC/cO5ZAouxJX7kyYvm74+OSvEd/p49fNY2p812NRmtK+aE pdfZl6pLiEHfe7S3/4+pS9ZK6rKBdaMXufPZACjnmWEo4Ta/hkcGdpuAoGY4Ecrascr+ D6Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B17g9wAT+9shoXVHnJnHIlRvD72JVpKr/HdI9ugSZ80=; b=DxOSxAVGF48QRWUc6sAFL4C0NWr8zSBrnrOvDdfcWz+lZSL6GCFeIw7JQ0q/fAMGuK LW0EwuLlcR/GrgNERktnZnKAxHYWduJWGrTiKvT3BsO2XT1lhbn3tcI5hdkZ9aDIBmti Yl5ssv2HFxDie9fkUKj0Jh5+miNXdHqkszfaXPrMJqWF554DEjWIL6bRvIIEtf/zp4d2 Kg6fHvshcfnt199gclj/3ZX13rvNhlc/+TrvCqytRZ8LytEex3o1QoQTBwrmxGWevJaz hvq7Sqkn5j0+s651hkGbvqYY6OWyYw62F0Z86ylMYowsW7WciCFk9p/l/gHzkXOvNQuV TawQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eVoBr/yo"; 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 ap13-20020a17090735cd00b0072af3c24981si9868954ejc.425.2022.07.11.14.31.55; Mon, 11 Jul 2022 14:32:20 -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="eVoBr/yo"; 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 S231949AbiGKVQ0 (ORCPT + 99 others); Mon, 11 Jul 2022 17:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231858AbiGKVQY (ORCPT ); Mon, 11 Jul 2022 17:16:24 -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 8C45F80511 for ; Mon, 11 Jul 2022 14:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657574182; 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=B17g9wAT+9shoXVHnJnHIlRvD72JVpKr/HdI9ugSZ80=; b=eVoBr/yoiV9Q9RvfxupDNxu9tGbVFK6wzolPkTCfKWcS8u1I1wfzOqshhdoHedHONfGwmZ +R/MHvphbzSwosyV0tiN+Kib+c3E75h8IsbYIw1e07/PcN1R67v5ant4upXYX/GziZHNo9 YFfOy58XCzkBlY+auV5YSRZpcA4Hnk0= 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-675-BymDG5gsMMiVt8p7M54asw-1; Mon, 11 Jul 2022 17:16:21 -0400 X-MC-Unique: BymDG5gsMMiVt8p7M54asw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0D6F8032EA; Mon, 11 Jul 2022 21:16:20 +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 7F5212166B26; Mon, 11 Jul 2022 21:16:20 +0000 (UTC) From: Phil Auld To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Valentin Schneider Subject: [PATCH v3 1/2] cpuhp: make target_store() a nop when target == state Date: Mon, 11 Jul 2022 17:16:18 -0400 Message-Id: <20220711211619.112854-2-pauld@redhat.com> In-Reply-To: <20220711211619.112854-1-pauld@redhat.com> References: <20220711211619.112854-1-pauld@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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 --- 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) + st->target = target; out: unlock_device_hotplug(); return ret ? ret : count; -- 2.31.1