From patchwork Mon Aug 7 13:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 132111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1497519vqr; Mon, 7 Aug 2023 07:38:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmNtpfeZapRwpvdDRmcd4WoKmy2yONcXUAAcpxDmN/4Xjos+oZdMB2ycEmELNXvhRCAz8Y X-Received: by 2002:a05:6a21:819d:b0:13f:aa86:804d with SMTP id pd29-20020a056a21819d00b0013faa86804dmr9975525pzb.35.1691419129550; Mon, 07 Aug 2023 07:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691419129; cv=none; d=google.com; s=arc-20160816; b=Ex+3begsyrfi+nzmO3Ucf+lFxcl4gRPAxcvWE0AZ36xPzCK0Z/4+cwhMyOXer3ebr8 ycFZVmBkIHGCYlhIF4gXgY37dDoz6RSXBu+xyUdACsNOGppjWbX0wO/NULNdJAB8aBCd lUvNygMMJIwBfMjG1Jn7ScLn8AbhA2okgpO9uiwepacvgKVQDnAxpcmM3S29CR8p2+s6 gXvjmhTilQ8RCAe6eIlLrLdS4jn+VZeU9D47N5FKqQ7B6YaPkGz7GRgMj1vZTz/wHfJz MhGg+e0QcAWPX6iCm5uEoPxbL1QmfeORMmYhHFG5qmzbi9i4BQWOF9IwPDuIpkPJ3R0o a8/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=vq2LqKgDPaDhnlrBU4urRm/zoBPsw6UyhSpMosqqfTs=; fh=/92WVKYrcN3rA268QXyKzVtm/UtxHeI2lnbU295XDiQ=; b=dM95rw+5fU3hA4fr6W7xoxVKzVTRlGSsH1YzFHyDz0ZHPW5vJRqpBrZQLWveYCZj0w gB5On0QFr/ThiTiiI6AiNJ7JmsYkoc1vj3WZp+xDSQcCHlDAuZNzkVmT1gZSB9XLn7bd QzBYhHIwa2tdacGT42PRkoEd4KpJJtLSNhbK6ujO3kPniFqURLs7n6cYnv34x6xj1uLH y9DyEl8LuhPE6XRAczXRjpuRr+gP8drW3W17tEL0HOBvoO1agZmDMaAFduZfv7492CVj pk4553HBoYLnxPxSspi0CWoPlR581bTKFbmSRd0wAw1vZToIyNXzvKEQplB/UbsIW2Ak OiKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2LMEqnSW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=iv5hFfUx; 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 m185-20020a6326c2000000b0055b43079640si6145591pgm.707.2023.08.07.07.38.36; Mon, 07 Aug 2023 07:38:49 -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=@linutronix.de header.s=2020 header.b=2LMEqnSW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=iv5hFfUx; 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 S234677AbjHGN5F (ORCPT + 99 others); Mon, 7 Aug 2023 09:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234655AbjHGN4m (ORCPT ); Mon, 7 Aug 2023 09:56:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA6FF3AB9 for ; Mon, 7 Aug 2023 06:54:21 -0700 (PDT) Message-ID: <20230807135029.061717423@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691416432; 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: references:references; bh=vq2LqKgDPaDhnlrBU4urRm/zoBPsw6UyhSpMosqqfTs=; b=2LMEqnSWJ88DG/xbwPK2/D8zRGGIDIMKG7vbcYXhn+Wb6eyTJpYCjg3Ci+25IRBstViGLd NSRdyQggrVb362Cf2Tuk3KczI8Y34GXrlLQ4LV8Pn/hz172+Cgqip//1Jcreqcotho152O e7D3L6QzosmBajJ4SklaxErB+DUC0oBESJJ/orOqVQ4MUJjzzd9/r06VncMtDd7zcd2PPR aumWruEG/huibXlfzAXznRCLI6oT68FgrcQOB3DXB1XlpHz93Q119JUUJXtu+THFY3N7lm rGzURS6OAVToStmULtTJkDohNVbK8EZF5vsQLSHpbJ9GFiKcotn3lTGE1YTEdg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691416432; 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: references:references; bh=vq2LqKgDPaDhnlrBU4urRm/zoBPsw6UyhSpMosqqfTs=; b=iv5hFfUxtG6Oze3lXxizz8BN2fAYPck3cM0RnS9YRy9x9lKZAWlY252Q15kAEabfCk7580 JIy+zgv1GLUG45AA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Michael Kelley , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko Subject: [patch 50/53] x86/cpu/topology: Rename smp_num_siblings References: <20230807130108.853357011@linutronix.de> MIME-Version: 1.0 Date: Mon, 7 Aug 2023 15:53:52 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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: INBOX X-GMAIL-THRID: 1773581505258548022 X-GMAIL-MSGID: 1773581505258548022 It's really a non-intuitive name. Rename it to __max_threads_per_core which is obvious. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/smp.h | 2 -- arch/x86/include/asm/topology.h | 6 +++++- arch/x86/kernel/cpu/common.c | 4 ++-- arch/x86/kernel/cpu/debugfs.c | 2 +- arch/x86/kernel/cpu/mce/inject.c | 2 +- arch/x86/kernel/cpu/topology.c | 6 +++--- arch/x86/kernel/smpboot.c | 8 -------- 7 files changed, 12 insertions(+), 18 deletions(-) --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -8,8 +8,6 @@ #include #include -extern unsigned int smp_num_siblings; - DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map); DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map); DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_die_map); --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -145,6 +145,7 @@ extern const struct cpumask *cpu_cluster extern unsigned int __max_dies_per_package; extern unsigned int __max_logical_packages; +extern unsigned int __max_threads_per_core; static inline unsigned int topology_max_packages(void) { @@ -178,7 +179,10 @@ static inline int topology_max_smt_threa return __max_smt_threads; } -bool topology_smt_supported(void); +static inline bool topology_smt_supported(void) +{ + return __max_threads_per_core > 1; +} extern unsigned int __amd_nodes_per_pkg; --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -72,8 +72,8 @@ u32 elf_hwcap2 __read_mostly; /* Number of siblings per CPU package */ -unsigned int smp_num_siblings __ro_after_init = 1; -EXPORT_SYMBOL(smp_num_siblings); +unsigned int __max_threads_per_core __ro_after_init = 1; +EXPORT_SYMBOL(__max_threads_per_core); unsigned int __max_dies_per_package __ro_after_init = 1; EXPORT_SYMBOL(__max_dies_per_package); --- a/arch/x86/kernel/cpu/debugfs.c +++ b/arch/x86/kernel/cpu/debugfs.c @@ -30,7 +30,7 @@ static int cpu_debug_show(struct seq_fil seq_printf(m, "amd_nodes_per_pkg: %u\n", topology_amd_nodes_per_pkg()); seq_printf(m, "max_cores: %u\n", c->x86_max_cores); seq_printf(m, "max_dies_per_pkg: %u\n", __max_dies_per_package); - seq_printf(m, "smp_num_siblings: %u\n", smp_num_siblings); + seq_printf(m, "max_threads_per_core:%u\n", __max_threads_per_core); return 0; } --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -433,7 +433,7 @@ static u32 get_nbc_for_node(int node_id) struct cpuinfo_x86 *c = &boot_cpu_data; u32 cores_per_node; - cores_per_node = (c->x86_max_cores * smp_num_siblings) / topology_amd_nodes_per_pkg(); + cores_per_node = (c->x86_max_cores * __max_threads_per_core) / topology_amd_nodes_per_pkg(); return cores_per_node * node_id; } --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -86,7 +86,7 @@ bool arch_match_cpu_phys_id(int cpu, u64 #ifdef CONFIG_SMP static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid) { - if (!(apicid & (smp_num_siblings - 1))) + if (!(apicid & (__max_threads_per_core - 1))) cpumask_set_cpu(cpu, &__cpu_primary_thread_mask); } #else @@ -427,8 +427,8 @@ void __init topology_init_possible_cpus( cnta = domain_weight(TOPO_CORE_DOMAIN); cntb = domain_weight(TOPO_SMT_DOMAIN); - smp_num_siblings = 1U << (get_count_order(cntb) - get_count_order(cnta)); - pr_info("Max. threads per core: %3u\n", smp_num_siblings); + __max_threads_per_core = 1U << (get_count_order(cntb) - get_count_order(cnta)); + pr_info("Max. threads per core: %3u\n", __max_threads_per_core); pr_info("Allowing %u present CPUs plus %u hotplug CPUs\n", assigned, disabled); if (topo_info.nr_rejected_cpus) --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -320,14 +320,6 @@ static void notrace start_secondary(void cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } -/** - * topology_smt_supported - Check whether SMT is supported by the CPUs - */ -bool topology_smt_supported(void) -{ - return smp_num_siblings > 1; -} - void __init smp_store_boot_cpu_info(void) { struct cpuinfo_x86 *c = &cpu_data(0);