Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2326806rwb; Thu, 17 Nov 2022 09:17:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ofDuHcyHKVgFhLeJSCkbCOajeJVC44zy+23mtjsYn+SQHQ88H6WiguAzvA1FuXrK4rYM+ X-Received: by 2002:a17:906:3a10:b0:7a4:22c4:ade7 with SMTP id z16-20020a1709063a1000b007a422c4ade7mr2987216eje.722.1668705442993; Thu, 17 Nov 2022 09:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668705442; cv=none; d=google.com; s=arc-20160816; b=TYbfONEsKJjFlwEPNr1lf6loxxJxqPxeqe/P2T1BvZytkC3HyeLrsTBEBJpZTG4ZuQ X0Sh625j4Fe7emcPd6f898gip5ZjG8rBsw54rkxM0TEIxUrBFoVNbLxF9R90WPvknvzv Nw3YyZSRyT/8jspldVb7W5HlbvmkTBBruuHnDbrSaV7l3zSCrUqfe05zq8pdpL7QZsDu 7QlBDWOqljfvyVl4LduwrBbl0XU1/om6kNIPPB6x6X/l+x7U15G2OCcookLdxqdXHod1 ViYLjcBCbwdKPVgSJyk6ErPzi1EctV2/QftNfS1fBWk5nRwrDEYAud/B1xmYDKhyhlEV 7O0A== 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=GXoqsn/bnF/+v01p/YrE+6QGhTzDYbDEdVNXy7Olx1g=; b=SqGGjbExfqdES6u62fjlKukxjdxMdDee9UyifMVW7E7+Jfm3reMKd3Lz6uoMZ5g1Fk 0jOwDpIyfTlzuv22hNVwT3BlF1se+iYKUSuj/WFwE64MY3guB0MfRBdBcBnC7kNK5tJx Jk1Di1jKa0PI5VviWNjVfROZ+K9qK6OqesUB8NgPe/4qlviawsULoOCM9pN0Z1dM37Go 3Di0px2RpzIfKKQK+Lk2bw/R/eKE0zRaopQHuxtJyBmE2HSzyWtg0wZu/7ne18g1zBr2 53SL2b1R0ktNTB9PSCnrAWzlGOmyk/96I6vutZj6yUdNgAlwlZ8JieLyOmDFcalGGwUo BxOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="W/yNaNQ1"; 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 s11-20020a170906a18b00b007aac98ec3dfsi797228ejy.303.2022.11.17.09.16.59; Thu, 17 Nov 2022 09:17:22 -0800 (PST) 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="W/yNaNQ1"; 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 S239886AbiKQQ1g (ORCPT + 92 others); Thu, 17 Nov 2022 11:27:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240438AbiKQQ0j (ORCPT ); Thu, 17 Nov 2022 11:26:39 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D35A17060 for ; Thu, 17 Nov 2022 08:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668702214; 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=GXoqsn/bnF/+v01p/YrE+6QGhTzDYbDEdVNXy7Olx1g=; b=W/yNaNQ1jMF1LLe8p0foPjTJLSURW4d3ZtValbFE/khH1OCngC5uDbA5/pymQtAX6oJ++W MDPn3LkmfOGlzvsxLl4ZnLjbTDTV8s4xmV/Q/2hVFlTNE7rifpvT4UZqO/5PV8fv2n0yBh zsiOw/55wo/lI4mI8MxRIEdBEgU22kw= 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-259-ZSn0Yo_-NkCmpcH1TDBZdQ-1; Thu, 17 Nov 2022 11:23:33 -0500 X-MC-Unique: ZSn0Yo_-NkCmpcH1TDBZdQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 135D888434C; Thu, 17 Nov 2022 16:23:31 +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 D046135429; Thu, 17 Nov 2022 16:23:30 +0000 (UTC) From: Phil Auld To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Valentin Schneider , Steven Price , Mark Rutland , Frederic Weisbecker , pauld@redhat.com Subject: [PATCH v5 1/2] cpuhp: Make target_store() a nop when target == state Date: Thu, 17 Nov 2022 11:23:28 -0500 Message-Id: <20221117162329.3164999-2-pauld@redhat.com> In-Reply-To: <20221117162329.3164999-1-pauld@redhat.com> References: <20221117162329.3164999-1-pauld@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 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 Reviewed-by: Valentin Schneider Fixes: 757c989b9994 ("cpu/hotplug: Make target state writeable") Cc: Thomas Gleixner Cc: "Peter Zijlstra (Intel)" Cc: Steven Price Cc: Mark Rutland Cc: Frederic Weisbecker --- 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, 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 (WARN_ON(st->target != target)) + st->target = target; out: unlock_device_hotplug(); return ret ? ret : count; -- 2.31.1