From patchwork Mon Aug 7 13:53:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 132106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1496575vqr; Mon, 7 Aug 2023 07:37:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJEEracCfqwphm8qOClZsa/3DZpcYf/EJd14wFjz3LY7YhZIVe2xGFfyHQCV8aq/b39NCI X-Received: by 2002:a05:6a20:8f24:b0:12f:c0c1:d70 with SMTP id b36-20020a056a208f2400b0012fc0c10d70mr9419115pzk.40.1691419040589; Mon, 07 Aug 2023 07:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691419040; cv=none; d=google.com; s=arc-20160816; b=Cf/w+cy/QwahUd+ynV3bT7kBTrYeH346qpcDzj5LdVNnlnLHjXArokHTwy+2wAeOo5 ABehG638g3Z92wKpMqYazuXSFUjtfOvlTX+2yhAdKZoALce/MVoJc9tsEk99i0jOSVu+ os9RNY/CWCZHLHEFfeRlsl2fHnAvHvHyZDy2zALAn87Sg/QvY9pYL5v4lf+M6PRkFOBP +euT1aw+MwAfdglsJtosNEnEl/yih8MqGdWI9cDieHF7dOb6hU2h6Y7FZtEqr+t94AU6 se0hcrUP83e9UlOxiRuCxzjDhtGLUF0aJHxoNipZ1VI0WnSAFnNe5eOmYQubg56aFo84 Wm/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=HA0GkWkS8cpM1N2spYIG0KC2cT4EUF8chsnc8hqXNxI=; fh=/92WVKYrcN3rA268QXyKzVtm/UtxHeI2lnbU295XDiQ=; b=0cS2kyquoIkLZeL2Pt0473Z6sZ+42EE3Ywg5yBvWwKwPTCwyNCLJYWhU8Jz8rG8h5J G/BR8eAm5AzaAoshhbiOCdftauFSbzSZplpehEapBuGEjQDNY8PludmDRqMJGm1eqJzY r+xufUCHTsPAQTzY0uF7BmGhqqBvK85X1VoCWPqDOylvIxUJkEOKVIHVdGclQWF5iuXS ASUNKNVNtd2k3BLdrkOQFZGIvepj/que3exRkapaDEnbWvSkYUCBLHX0HT2kI+R0mo99 /okW8/td72+6ODaB1CLO3JJwASDlaH2+bXVPo8jFMu7DgF6ZvgDkUtLICGMkJTDu4GrF gh6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mbcBIdnU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=cMZSsmtB; 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 ca19-20020a056a00419300b00686f9327e71si5717137pfb.359.2023.08.07.07.37.07; Mon, 07 Aug 2023 07:37:20 -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=mbcBIdnU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=cMZSsmtB; 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 S234544AbjHGN4A (ORCPT + 99 others); Mon, 7 Aug 2023 09:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234551AbjHGNz1 (ORCPT ); Mon, 7 Aug 2023 09:55:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D1326BE for ; Mon, 7 Aug 2023 06:53:45 -0700 (PDT) Message-ID: <20230807135028.747059118@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691416423; 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=HA0GkWkS8cpM1N2spYIG0KC2cT4EUF8chsnc8hqXNxI=; b=mbcBIdnUQxSlwmQa6B+H/Gxl393lPsdfzT7tBvYwR3Pn3VJf+tNWgt85zxFZlKT+UExE60 ASDnC02eCyZYX7oG5pFGosDAY7wgWYXqfo7i9s4IXwE7UN8vUEKjyg70NMAgWSck1bK9Vp sq8DFONe71gmmM6A6utJkBgjTFWyvu/Y94S+hHnZVWQbEUIe2n89QtOy3IG1YHv/g6OYwt Y0Daaj5eXg7Ztf98SmbUplU62i50xj7dd1bVbHmJcYXAVc7vmzhkSvTsB20gGfqqrGaq4y 2dlTvsOe9Pi5x41DNKPfgkdFBAyGsl69fcCLCbKMt+PpcIcoisLs+YTvzKenHA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691416423; 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=HA0GkWkS8cpM1N2spYIG0KC2cT4EUF8chsnc8hqXNxI=; b=cMZSsmtB0P6xqMZ/ZMF9HG3Kk7dfRR61Hvfa0iJr5FHBerw5WEqBc+hBW+SJbcqeNUvqIs VSi+KA69RHL6wTCg== 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 44/53] x86/cpu/topology: Mop up primary thread mask handling References: <20230807130108.853357011@linutronix.de> MIME-Version: 1.0 Date: Mon, 7 Aug 2023 15:53:42 +0200 (CEST) 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: INBOX X-GMAIL-THRID: 1773581411599434271 X-GMAIL-MSGID: 1773581411599434271 The early initcall to initialize the primary thread mask is not longer required because topology_init_possible_cpus() can mark primary threads correctly when initializing the possible and present map as the number of SMT threads is already determined correctly. The XENPV workaround is not longer required because XENPV now registers fake APIC IDs which will just work like any other enumeration. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/topology.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -92,30 +92,6 @@ static void cpu_mark_primary_thread(unsi if (smp_num_siblings == 1 || !(apicid & mask)) cpumask_set_cpu(cpu, &__cpu_primary_thread_mask); } - -/* - * Due to the utter mess of CPUID evaluation smp_num_siblings is not valid - * during early boot. Initialize the primary thread mask before SMP - * bringup. - */ -static int __init smp_init_primary_thread_mask(void) -{ - unsigned int cpu; - - /* - * XEN/PV provides either none or useless topology information. - * Pretend that all vCPUs are primary threads. - */ - if (xen_pv_domain()) { - cpumask_copy(&__cpu_primary_thread_mask, cpu_possible_mask); - return 0; - } - - for (cpu = 0; cpu < topo_info.nr_assigned_cpus; cpu++) - cpu_mark_primary_thread(cpu, cpuid_to_apicid[cpu]); - return 0; -} -early_initcall(smp_init_primary_thread_mask); #else static inline void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid) { } #endif @@ -161,9 +137,6 @@ static void topo_set_cpuids(unsigned int #endif set_cpu_possible(cpu, true); set_cpu_present(cpu, true); - - if (system_state != SYSTEM_BOOTING) - cpu_mark_primary_thread(cpu, apic_id); } /** @@ -252,6 +225,7 @@ int topology_hotplug_apic(u32 apic_id, u set_bit(apic_id, phys_cpu_present_map); topo_set_cpuids(cpu, apic_id, acpi_id); + cpu_mark_primary_thread(cpu, apic_id); return cpu; } @@ -422,6 +396,7 @@ void __init topology_init_possible_cpus( if (apicid == BAD_APICID) continue; + cpu_mark_primary_thread(cpu, apicid); set_cpu_present(cpu, test_bit(apicid, phys_cpu_present_map)); } }