From patchwork Thu Nov 30 21:16:29 2023 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: 172124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp690679vqy; Thu, 30 Nov 2023 13:16:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEneFkHgmC/MmcJGAAKpd14P1baCax82BkWJXChBJp6/OrFuwVOOkwP4BmbXYwSkSj8y8Fm X-Received: by 2002:a05:6a00:35c7:b0:68e:3eab:9e18 with SMTP id dc7-20020a056a0035c700b0068e3eab9e18mr26626234pfb.12.1701379002001; Thu, 30 Nov 2023 13:16:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701379001; cv=none; d=google.com; s=arc-20160816; b=0m5gO/CYIzS4KWkzG1w5HVTkpu/KmajBaMFId2lSCyGd6eYzcgIB8W8g9qIl2KAqTs MyTdFr6AcOflcpLx286Is6TxxzwCPM7Ompoo0UrW1vdzf1Uu3WQVem/hFmBVg2jtLhAs qoArelYinFAlbjUuBZO2sc1VA4GUS85jH3RiPVc7SMtVR3IK61drViiNExlcOpQK79c6 3biR1tpvUnhV8tWbpbg5ihq1ML2VbnzXCNvG8sugA24gHdubY7UXdVd1tMuy4tXgwukp Sha5s9sM6++XCy77nhtCPoR63fp9tMt1CTUkeO8/78inscLxrgdPKDYgLmlm6R8poVKn zPHA== 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=yX3GH4Ig3zJLPcZmocLBTO3REi3Ffcp+2bdeAOPF/9I=; fh=lC3L+tLu9jMrTwLXdci/D+zTDmYl6oRylGrfIkeVy60=; b=mkAm1h2JJruoT4533opXTeUUWj/Z6vWsOX0YhKjPoN3XIGrgsxeK9zmvfBXlppOJ6E RsbikxEDHESGu8fsPzWRLGjS8wOxXTRTH80b4GR9ugymhWzjnKJCyTx7O3gNqJF3F5Kf d9mw0qc+xQDt4SEaNJBWSgH9uNLYPpE/Ev/VDXTVZ3FjpQe32CT0K7JevZ4Nyn6eSYoz Mo6D0jrueHDd2MLAfmY24CpvB7nhtrpyga3/bHnxENhgcrPk2R+2Bk088ZjQRR7XaGv0 q2ercIiOjjslVl4qmUL75Emmwk9oWqWb7biUFMpBK0iyxG0biZ4SKDv4vm6RmdRJ4Gbv 2IPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HPuNHV2r; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j191-20020a638bc8000000b005bdb6daee0dsi2070639pge.303.2023.11.30.13.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 13:16:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HPuNHV2r; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2131982B8A4D; Thu, 30 Nov 2023 13:16:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376862AbjK3VQ2 (ORCPT + 99 others); Thu, 30 Nov 2023 16:16:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376818AbjK3VQ0 (ORCPT ); Thu, 30 Nov 2023 16:16:26 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD40133; Thu, 30 Nov 2023 13:16:31 -0800 (PST) Date: Thu, 30 Nov 2023 21:16:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701378990; 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=yX3GH4Ig3zJLPcZmocLBTO3REi3Ffcp+2bdeAOPF/9I=; b=HPuNHV2rzBeMM2AcgCScPh910tiNvGRT5f3PFBwbQAgvF2hVzf0kdxz2cesg/HL9tCTpEZ BxmR1Emz1HDMMdPEtvXu2Ks5Vg4sY3Ux/ruCE5hWOQzHBVfrJxoPjyNYXokpDSJTXzPA7U Yq786qD+oZBnSefPrZF1OgYIq5dLq5fuy8NJ+oMnIs5ahJegm6TCurO/PylKS+tnHuKUh7 mQB6i+beiRUef5UyzWLPbF8UEyGv5lSrdh3YrfL4boJU463rxecW9EJJOkYvQaHDSx8hi4 YAJNHuuoWPIE3v6segHiVeaWp1Gwk9NWvxRdaxChLO0Y1BP53KdLNJztoslbdw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701378990; 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=yX3GH4Ig3zJLPcZmocLBTO3REi3Ffcp+2bdeAOPF/9I=; b=5GlV8IXEaCV43hIm2akKSs0HaL1J1S5moCBt8TQCBqrzT9IkjOTamdp8JJfA/z4XDU2YAp 5bcHKGWdLhq6UUBw== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/percpu] x86/smp: Move the call to smp_processor_id() after the early exit in native_stop_other_cpus() Cc: Uros Bizjak , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231123203605.3474745-1-ubizjak@gmail.com> References: <20231123203605.3474745-1-ubizjak@gmail.com> MIME-Version: 1.0 Message-ID: <170137898974.398.10685540680447334314.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 30 Nov 2023 13:16:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784025188621525257 X-GMAIL-MSGID: 1784025188621525257 The following commit has been merged into the x86/percpu branch of tip: Commit-ID: 9d1c8f21533729b6ead531b676fa7d327cf00819 Gitweb: https://git.kernel.org/tip/9d1c8f21533729b6ead531b676fa7d327cf00819 Author: Uros Bizjak AuthorDate: Thu, 23 Nov 2023 21:34:22 +01:00 Committer: Ingo Molnar CommitterDate: Thu, 30 Nov 2023 20:25:09 +01:00 x86/smp: Move the call to smp_processor_id() after the early exit in native_stop_other_cpus() Improve code generation in native_stop_other_cpus() a tiny bit: smp_processor_id() accesses a per-CPU variable, so the compiler is not able to move the call after the early exit on its own. Also rename the "cpu" variable to a more descriptive "this_cpu", and use 'cpu' as a separate iterator variable later in the function. No functional change intended. Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20231123203605.3474745-1-ubizjak@gmail.com --- arch/x86/kernel/smp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index 6eb06d0..65dd44e 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -148,14 +148,15 @@ static int register_stop_handler(void) static void native_stop_other_cpus(int wait) { - unsigned int cpu = smp_processor_id(); + unsigned int this_cpu; unsigned long flags, timeout; if (reboot_force) return; /* Only proceed if this is the first CPU to reach this code */ - if (atomic_cmpxchg(&stopping_cpu, -1, cpu) != -1) + this_cpu = smp_processor_id(); + if (atomic_cmpxchg(&stopping_cpu, -1, this_cpu) != -1) return; /* For kexec, ensure that offline CPUs are out of MWAIT and in HLT */ @@ -190,7 +191,7 @@ static void native_stop_other_cpus(int wait) * NMIs. */ cpumask_copy(&cpus_stop_mask, cpu_online_mask); - cpumask_clear_cpu(cpu, &cpus_stop_mask); + cpumask_clear_cpu(this_cpu, &cpus_stop_mask); if (!cpumask_empty(&cpus_stop_mask)) { apic_send_IPI_allbutself(REBOOT_VECTOR); @@ -234,6 +235,8 @@ static void native_stop_other_cpus(int wait) * CPUs to stop. */ if (!smp_no_nmi_ipi && !register_stop_handler()) { + unsigned int cpu; + pr_emerg("Shutting down cpus with NMI\n"); for_each_cpu(cpu, &cpus_stop_mask)