From patchwork Tue Feb 13 21:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 200649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp814841dyb; Tue, 13 Feb 2024 13:20:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJviCb+mr2SclXEd1f9G2vrSGU+7VOJpB/J13A70FKhJfyN+tSuvFWKRgs6DMnmy0PimJ/11CvnbZA+r+eCmUXnktEOQ== X-Google-Smtp-Source: AGHT+IFFkLB//Ywgf/r6NBAfBheXLaMpdLmaq8Fyk+RmaP/G1bDpcanLkomerUBYF+f8/C0MD3Dp X-Received: by 2002:a05:6402:3d7:b0:55e:eb81:2db0 with SMTP id t23-20020a05640203d700b0055eeb812db0mr548865edw.38.1707859244441; Tue, 13 Feb 2024 13:20:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707859244; cv=pass; d=google.com; s=arc-20160816; b=cmLPTsimgkIQas2q+YqdeTMGJe7HLNZyQiB4GT63oYiK4lQr1tPs/c+ATRMubptn44 OrpX881cY2FiN0zCWc8nGb20kUuA2v+xk2avfMhsPGOJ6G+/9FCEnbZdWnQ/E2JTTyii HwdSUdE/aQ7kujoiSgEMu+M3oSouX5CWCfs6OoOUr/6P5W0Br2Yy/ENLA2mqAFPc426b 0IPVEEZYsVz5oIIFKT8CcN27oqDx22hsK/NYsSP1t4lLtTHM5+CiU5yhWAB2XqSynP0O uAiIG/a/GFp+Kd8itYz09M7lVsKWe5K+leL0FEtCrQ/TkEjNU9rGmXCAe7HEtHEECjrV yAmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=TKbUBcNH0EQ/gLK3fnpU18ylL1ck8LsuH2l84iqWPqs=; fh=SQRkLg6lnpzKPyXuArY+gNbQuWMWBFkm6GN35MpBcc0=; b=YySARXITZ8nsZhU07pc3qmuIHGbjNizJxHcl43XY06Mlj3KVO0ZlgGCz/2v1hF0jMm yUQZP2LzLm2navvK4NIIv0oOfY5YehTpvUA/E4WXaMty9x0RjcYvdOFMPpzIlgbsy7Hh NrdgVuI6xx3PH6zn+m6+L0eAQ+qOcrm/Ry35DhGj0eETtHR5szOURdxCbn8KYLytxfni 3aCdcPq9shCTR38wPpLJjWFf3MP08gM5CnHy+z+04B/vm2M99CogsbsAji9XzzGeolnJ mzYc5t6Lp/tpJybs8rg5bk9KS0wev/wNLGDsPtN8mR065frSLdCRgoyF/+o/CB1HfidQ TVdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="GY2mq/NF"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64308-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCXM16+zF//WKmw3YGlaxVlm69NDQPrbaYmGmTBQdr2r6UbWt83nYmxcePu21uwpwq9BbvVFIEPOCfvXxFpDjrseFk1k8A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eg29-20020a056402289d00b005621a670e41si235967edb.62.2024.02.13.13.20.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:20:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64308-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="GY2mq/NF"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64308-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 134351F287FD for ; Tue, 13 Feb 2024 21:20:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 072C685926; Tue, 13 Feb 2024 21:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GY2mq/NF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ISgqYSJn" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B488A84FD8 for ; Tue, 13 Feb 2024 21:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858368; cv=none; b=E87GPmvlOwNGG4O6cbBO2MaUEWD+80Ehy4KmsA31IV1cqVJCofw4ouQwg6sy2E+gt+daT4moyjMYZH1kkGyzODU6prcjRym5HX9YSLGM5jHSUolAV/Ngluw/37Ap+YFdZ8CaJzPZZGKm9nNYSwt1tv1/jz+D1rph08cSo9ulDN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858368; c=relaxed/simple; bh=f7TjAfRNJePRvBVh60Mlq3WaXOIueC9RaU3KBd5vNSQ=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ua+/FUqpGh3ENO6E1U1NyMJtDYJKDMLBIf2AVzxYlNTed53zeXoLg/+HahnCUo++WsXzGPAJG5AoOeW40SKajlZJVS3l9z+nojCCykkeh+MnTlqIPxmXEc5iuM33+Qr0ye9Fo3CQ23KGv5CMdwc5nxK52q6Y+TkklBCvGbazVB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GY2mq/NF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ISgqYSJn; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240213210252.736104257@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707858365; 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=TKbUBcNH0EQ/gLK3fnpU18ylL1ck8LsuH2l84iqWPqs=; b=GY2mq/NFSPH+GSw6gAmOmCoE9kHYCGw4vM72bnpYhTyDS3u1MHINPu/krM8Jgqc2PmZ9R9 xBxOT10RrZYSfYiZ39GK4gdvoGjd8zud5fn+Bhccf0dKSQqBwLLAHw8BU8m1VOjDmIILFS Maf4nQ7m47HrA0nNfa/zpCgBbDoRqZQNKf0mwtWSSb2NOuTVyxOwYPqjn/U0dktUFLqSgS kycW7Q2XO2FvZQpoPrbPdgMl5qjUEj7yBm8ofV2K2RJ5l1oBdi9IqqfAisbCDwxMU5d9+A mjIEDB9AT0eLmaLyWcYzMY5bXbr9rtnZyLjFZjCc7WlKSVrNqJqokvmMPWLxeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707858365; 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=TKbUBcNH0EQ/gLK3fnpU18ylL1ck8LsuH2l84iqWPqs=; b=ISgqYSJnb4ORWJzaBcbYql6oOdFC9OeW55CfrtR04MA+nvxYVpoxTfG1/Dqa+VQTCDYjUF 3CGlPAMSK89T5mAA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko , Michael Kelley , "Peter Zijlstra (Intel)" Subject: [patch 22/30] x86/cpu/topology: Mop up primary thread mask handling References: <20240213205415.307029033@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 13 Feb 2024 22:06:05 +0100 (CET) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790820215072640807 X-GMAIL-MSGID: 1790820215072640807 From: Thomas Gleixner 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 @@ -82,30 +82,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 @@ -151,9 +127,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); } static __init bool check_for_real_bsp(u32 apic_id) @@ -276,6 +249,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; } @@ -411,6 +385,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)); } }