Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp618297imi; Thu, 21 Jul 2022 07:43:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s3knXrgW3kO3B1EFGonl8DmrE8SIoG7XGdE08Ck5LgCuANAPRmTAGq7mqGFPrwpWP7BbnL X-Received: by 2002:a17:902:9b96:b0:16c:83f0:33f8 with SMTP id y22-20020a1709029b9600b0016c83f033f8mr42397658plp.4.1658414632833; Thu, 21 Jul 2022 07:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658414632; cv=none; d=google.com; s=arc-20160816; b=DfWigiT6kloYD8PQbaiT+Z38hPP11JKmU1XfQ+cu5KvN1xsREZ5uC+RQ4GStNBP4NR 0GeAzDlXTp3PUtcbOBA6yz1LXOZ8pioFD+woEKKD4yY4nOLk46pDcf8tujpfIjGFF+qN xW6R1Lxe/ubShffES9tpwwX9d59Wd6pAiJ6DW3EJlyvbkTUbVlwOiJ1Pc5veNDoaL4TW PJ3yF81zBTr5/Ghx8swtLPw3Rpa5qwUPiXOA7MQRjf+R94yHUP+RF+mqHgi7bA/+BSAs ZhKNGTWoC68g//r1DYJ5HzO7Uksl00kOfCFyoSVd0SOuSXnueQXTstrz+0xFKXwj7L3h ZTRA== 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=f1SjiiFwbm/IuhhOsQFJLO8wJ7hPNmr+cHkhaNf/rA4=; b=FtYAvabOYla+zQAKFJuKSTPJ/Ea64PIENdb0uO8kDS/oHB/y/ifBLfcgpWvpljOReZ rye3qm4Te6eqNT0z7UNhGbkPg1quqmOspKKjNLDcTJzGfIKwHY7GrD+fClyTfClNslcQ LtPDqZYsop5DIYl3TpNC8tNkij/SH7X2C19S6ieK3syHApr5G5wfr2YwOnJQQADV/UgL 3w9XpCUfLMvF5niUMVUVl/+nS7o8nGrnF+9PJLx5Om2ZsWOzeKyV7g6tfs10+ZSA52qP Oonnyos62GFcJRfKI6Lv5RZP7dOHlow1NTPRFPwxyUsyoBIlsEjgtoWQ51sUaDDZdHAZ x5Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ffihKDqh; 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 27-20020a63145b000000b004150ffa0459si2519645pgu.754.2022.07.21.07.43.38; Thu, 21 Jul 2022 07:43:52 -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=ffihKDqh; 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 S231975AbiGUO3B (ORCPT + 99 others); Thu, 21 Jul 2022 10:29:01 -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-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.5 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 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 --- 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