From patchwork Thu Dec 1 11:41:24 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: 28341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp212715wrr; Thu, 1 Dec 2022 03:44:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Wqzhj4dpeCmPYdsLcZXwGHJn2PvYc0zrXZqFvfHe3LVUWPSFQnzw8/MwEvfHPmq7duWxq X-Received: by 2002:a17:906:3810:b0:7b5:cab5:2ea8 with SMTP id v16-20020a170906381000b007b5cab52ea8mr39626642ejc.222.1669895096741; Thu, 01 Dec 2022 03:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669895096; cv=none; d=google.com; s=arc-20160816; b=EHsBkf1IMdB2U8kjb3maF3NzBGadPDy6FXjttCSLDAODFQCv6HmFgqRVWLg+0z6pnh o4+XkAC0RjEgcw3GuiRMvK+UexwnT5JLb3A+if2V8HHwmp0dMPHyurcx6vWDZ10v7hgd gUALQaxQYS11uB13/l5U05FihDXSQmS9XLUB9Em7F5TliZHBX3dAwQoW8sWkSc/9gRS/ T7PNAsFHOGlOBTOkxlF79y+FIvCUHZRXYukUt0AglgG7y23N/g6RsEYMzBGY2UTBvgrh DhwySM8J3tY9Tf5/Ju2kj4+yQSNCB3tyjcPJpvWNy3OOA+K54K5RPYI3g65si6aBTBUk zGZA== 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=VZMu+Ww/tIWv7+5nct9Y8zaEczZTGJtowfe2b2w4XBM=; b=chAv2/OzFf7qtA38epsYj4WwTmS6IOOCs3LNb3FgPDhSmbYzdn2JSp6RhpBvX5SRgE mBjCcjbtDV7ya/nVcnCfYUO0J4Nz4kMYw8Kd2jZK8+bX1NO7BAa2jC8+kolhKffbzZcp JIdbllmzdBPWXrfuAxz2gjZgHoa1q/X6khOFCp+rxWt6S+3pL04mIRq/yFqWVLzMKSe4 pJG+JgEVdv3/fW5jgqL4xOPjYx3lEBdpGtQSHMrHsvPZTR0S3ydtJnUxcoHCt0rdNOjs Nio7KKWWNnY25NTwlybWzyfmcyDpPWGySpwjd61QH9hN6s7n4/VG4Y980mxBZLrSiLgd jJUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cl33zYaB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="bb982MO/"; 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 l11-20020a056402254b00b00461d2ed78acsi3760882edb.378.2022.12.01.03.44.33; Thu, 01 Dec 2022 03:44:56 -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=cl33zYaB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="bb982MO/"; 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 S230415AbiLALli (ORCPT + 99 others); Thu, 1 Dec 2022 06:41:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbiLALl2 (ORCPT ); Thu, 1 Dec 2022 06:41:28 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 380429582D; Thu, 1 Dec 2022 03:41:27 -0800 (PST) Date: Thu, 01 Dec 2022 11:41:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669894885; 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=VZMu+Ww/tIWv7+5nct9Y8zaEczZTGJtowfe2b2w4XBM=; b=cl33zYaBw6+x2HTKq3LZVbuQ9BL+d3PIERTDStFib0yXCudGYX/8vUNEiXX18IWLl+SrmN xoflbDH2hujPJ5Ld0nQKoUreVJqlChZMdnPMq/JEp4UbrXEJt2ZhZtMjDHAygMSkINdpgk 36HRG0Zzil2VSCMa7RMRR54qRuOhERpIj+aFa+0hcArmz8z2+KXAn7nXJ7uE3yD8zQEJaR KcWwtKYMW8w01gv/Fs/NQ7e70grmvYpCm40dF9c33Aat0aFHcAwbkGeuZHu1uu5rVw463H B8w7Y1WlmNQpi/t7niTtcIKkhY5IfsOdcCrUJ5ILH8MBPggVwG0kg5sHe0N2RA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669894885; 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=VZMu+Ww/tIWv7+5nct9Y8zaEczZTGJtowfe2b2w4XBM=; b=bb982MO/MHk4b6IlgtjlobBPYW8hV7N3JziIi3RwB7Mu4lWXF7CjxSkLWxR+QJxHnDuvyV g8l9F/fd1mZNeZDg== 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] cpuhp: 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: <166989488463.4906.8715334204096231628.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?1749761551848400502?= X-GMAIL-MSGID: =?utf-8?q?1751011920623612560?= The following commit has been merged into the smp/core branch of tip: Commit-ID: 0fa5abb6b7d85bf5688b2e11113f50317fb0121c Gitweb: https://git.kernel.org/tip/0fa5abb6b7d85bf5688b2e11113f50317fb0121c Author: Phil Auld AuthorDate: Thu, 17 Nov 2022 11:23:28 -05:00 Committer: Thomas Gleixner CommitterDate: Thu, 01 Dec 2022 12:35:08 +01:00 cpuhp: 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;