From patchwork Fri Dec 2 11:51:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 28879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp791012wrr; Fri, 2 Dec 2022 03:55:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf67ZpBlet2sppx96QIFLrIA3ohlWe6+nLjdjFDdWMB+9z2nxQdBJsdw2QOWpk2gygqPN9rb X-Received: by 2002:a17:906:5a8b:b0:7c0:bf7c:a56b with SMTP id l11-20020a1709065a8b00b007c0bf7ca56bmr2976178ejq.306.1669982114522; Fri, 02 Dec 2022 03:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669982114; cv=none; d=google.com; s=arc-20160816; b=02OKsJeq4SRNimHsSWzbFCRspWi3q4P54xOGnnC4+odNnf3bE0ZGHE2GXwBMVvmiKL 3Hy9ze9JMYwtrmvTm2k3D8f850DcHWDWaF4kJuFwsWTCF/nyYTeFAh4gTNTWTAsxinm5 KlmTe2k1N/CtBHPuEV2cqfJTPDO9h2jMk4/IwYUGARMHZ1VRH3+nOvZfPt7+PAJ0ihUy 5QLoQqp6LgeFgF0H7ZEtng1PeF9Px0Que6iboL5+IdWaJPteMnA0ohYofOQgbakqQjT+ 1VkkL3Gfo+1fv4QNOxRoI3MLTlzqAaHgObrWMIWy7VpqwDUsnGztFaEmTxPdno2KCM8I WF2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=PYx/N7VkLi9cbwQkwAJUfl0UrZSPQe3r5BCoHYTbRH8=; b=f1tXju+F+FJsX+vr8bdgY1sz1ERzDDpDdJOwWuuTdWx4rAL0gwZxdWR/nkhllKv9b7 U+FYeWr9usAMHTLXKvQDQG4n0VZTuAqO7r3LljsmP3U//WD0wy+pIed1iUAC5oCwcp2S 3eh25eU/g8oy5V0Tgmuld2niRyO//mhsQ+wlXIsd2IHEZQnjQTdTDV+PQi4G0wk68qK8 tMAMcBDJRXxvxpzy+P8I3rDoA0l2Jk9YlHi5ZK7EkUn8SiYwCZ18DTZxhSphVstLkJs8 FuSewAgc97WAOxtwpiuAwGnec7gp3aF4ZlE8sFQD0eR/JE8JBhsJmqLiFkrZwu7WwkKO 3mVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KpafTXJX; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go31-20020a1709070d9f00b0078dee0fce23si6831292ejc.123.2022.12.02.03.54.51; Fri, 02 Dec 2022 03:55:14 -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=@linutronix.de header.s=2020 header.b=KpafTXJX; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232862AbiLBLvL (ORCPT + 99 others); Fri, 2 Dec 2022 06:51:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbiLBLvE (ORCPT ); Fri, 2 Dec 2022 06:51:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2597C1263D; Fri, 2 Dec 2022 03:51:04 -0800 (PST) Date: Fri, 02 Dec 2022 11:51:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669981862; h=from:from:sender:sender:reply-to: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=PYx/N7VkLi9cbwQkwAJUfl0UrZSPQe3r5BCoHYTbRH8=; b=KpafTXJXaztJBJbDl9tnm1/AT6mTWHf4Fnqu+kjhE4fnt8oNV3EkiUHL7Qf2OwcYrd8A6F h4rlldWZFUzLXQs1A1O15WNNQmAYjpMiWYyAbw4pW+DKKvv3W8faqTowC0pGjKMXJFuMV1 qr9FW/ZuMKl/lVaNbVQOTkVSuyTltAVJyq+HziqHAo+d/ozrjoXMGtW/SkGD6+PtpZLFG+ yHBrBqzxbPG21ooA4SMKavOztlKmvK2xZ2SWHNyGL3raHcLtewZ1DZAWB+tdtSTzMWPuBf j+JUjVIp53XNFmf/j5nwhDVbPq1o0HXeUGxXX85+LhyLwo3VjQgT/jzCsz8EcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669981862; h=from:from:sender:sender:reply-to: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=PYx/N7VkLi9cbwQkwAJUfl0UrZSPQe3r5BCoHYTbRH8=; b=3isjQppUJqNrN9+T3eb93rnSU/gPzhzIy6zjMcxcLoohe2uafWkfMixPJ3hM8ZvzV4tgqT 5h8jPlCldzupdxBg== From: "tip-bot2 for Phil Auld" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Make target_store() a nop when target == state Cc: Phil Auld , Thomas Gleixner , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221117162329.3164999-2-pauld@redhat.com> References: <20221117162329.3164999-2-pauld@redhat.com> MIME-Version: 1.0 Message-ID: <166998186154.4906.2993867265971193970.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751103165499796807?= X-GMAIL-MSGID: =?utf-8?q?1751103165499796807?= The following commit has been merged into the smp/core branch of tip: Commit-ID: 64ea6e44f85b9b75925ebe1ba0e6e8430cc4e06f Gitweb: https://git.kernel.org/tip/64ea6e44f85b9b75925ebe1ba0e6e8430cc4e06f Author: Phil Auld AuthorDate: Thu, 17 Nov 2022 11:23:28 -05:00 Committer: Thomas Gleixner CommitterDate: Fri, 02 Dec 2022 12:43:02 +01:00 cpu/hotplug: Make target_store() a nop when target == state 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. Fixes: 757c989b9994 ("cpu/hotplug: Make target state writeable") Signed-off-by: Phil Auld Signed-off-by: Thomas Gleixner Reviewed-by: Valentin Schneider Link: https://lore.kernel.org/r/20221117162329.3164999-2-pauld@redhat.com --- kernel/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index bbad5e3..979de99 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;