Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp467145rdb; Tue, 23 Jan 2024 05:22:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTlGzKUvtLrDaPX7Yb8jeeL6ipCULbKcNDG09EvVWq9uxZipo8WkuyH9nj/76s/D1jq45r X-Received: by 2002:a17:907:2917:b0:a2e:d563:175a with SMTP id eq23-20020a170907291700b00a2ed563175amr100815ejc.151.1706016173879; Tue, 23 Jan 2024 05:22:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706016173; cv=pass; d=google.com; s=arc-20160816; b=VzyZqAxshFKkRnBGX3RmQJjzzn5eggtyIJAEV20fBozvaM/HhfbVi2lzmJobZwNSdP a0aazOdO474a4H/mRTDkfDDuM428+am++qOKrATTp55TNhuYqPsjN116jIJvWpfQXkWl jMs4I8ZrnDN5N6JAANR7LPEVRCJnayX79t6m6Bb50BWd2YKweHxbSt3iKXVoU68Kk3+B jK5hcz7Lkjg1sPECHGg1787dB+LcxwTVIqRNqIa/Fv+h+U0iJ2vLotaKvImiHB6e2Exb iXcjQkflMLOyB7G8V83e5VZqK7b0VpuKwiV4GyZBt/lj//RBlaLx24+fKuY0ZwI0Ltgi 3UEA== 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=MpTsqbRm/7LUvkcxZ0AyD5uJRHhE5ALqrQ6PV/OvYUc=; fh=Te0fDPJ/sd+7p881M6fa/oF213lBbJvGdEFWr/TLqNA=; b=y+T14tWbfzlndYS9M2u/pnVywB50Y9nsXv0AXOZHpWRnYZcD7WZOjUd5zdp218mfzS vbqiMKGLlFFR0j4fcCmj0cWL09AnzvBGNO5Cj0r2p0dPplZJTiVOIwYphZkHDvKIlcy6 /DL/hMnNAxgPhskZMbcUXVpjtmEDkK9yHhHxFmWnu5sP+2eEaZZ8YiS1SXR1bzIOC2wX PjXyHBI6cf3m9fu0kwDxiNfTwSwIfTUWxzztx4fxWI6KFD3Kb1pErqPlXGodxUlsybzV 9qbNovvX8JkCn3mz6PIaNLXwA7lVrzf15u1fraEHlTJFYKezrm+9b6ENs2Qbi/G8UjqD NHjQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=S+qILiHH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Rqc5v9+z; 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-35365-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35365-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h12-20020a1709066d8c00b00a2c467ec739si11963178ejt.357.2024.01.23.05.22.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 05:22:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35365-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=S+qILiHH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Rqc5v9+z; 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-35365-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35365-linux.lists.archive=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 2636E1F22DD6 for ; Tue, 23 Jan 2024 13:22:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 535AA664C1; Tue, 23 Jan 2024 13:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="S+qILiHH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Rqc5v9+z" 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 2C6EC65BDF for ; Tue, 23 Jan 2024 13:11:28 +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=1706015490; cv=none; b=QB/uXZ8B3WQ54sP7S34gob0hcwah2nvnLHu4G4BIi5vTr9DARVC78W2Z5Rnr3ZNYZFVU/OZOy0H1WqyRwgs2ZPsRsIZQjPV4JLlv7MPrJyIWJMU7Kc+I80tATSpAHmGAYU6d5xIp7GWIBAWtQCvPT+sCi36z/DbPuKpnI7dQAJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706015490; c=relaxed/simple; bh=g6J2asPgFD0LMsaQKbG6sg+BTdgOsXYI9ZSt8dfSSUM=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=cN8Vct+mJMr4f6YRPtQUhRMwIPxUsXtmfyCBByDNEgMZkvlkiNzdBufcbRHeiFsHVQYi5ShloQ/S4YcwDA1FgDMRuHONdCXXDFVPbqTydstMLJZQGdwFr2qKt6iMS5IWjBjJAyzdaYeJDgrXDv5g/39gBiLK9EpoiV0wb50zjEo= 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=S+qILiHH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Rqc5v9+z; 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: <20240118123649.804004114@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706015487; 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=MpTsqbRm/7LUvkcxZ0AyD5uJRHhE5ALqrQ6PV/OvYUc=; b=S+qILiHHXkAV2EyV12l6SUzg4bOrkeMeqfcxYTq2fGIK9ysa6UCP1cTi7jEqLBzGOuNulh +z+uCDx02XhhNOiSvVd7fNoCKVit55iWZuOemkBdVdCOjY3XcNNGeYy+hqI1jF0rn9U75a 0lMtRAOavZgJQz8sjuMJ6yoyjahHdk1KIH9XOUkTE1wP5jsuiYTWiCtk0MrMLHHBagH8YO 2FNVh7FaFy9o9uA9pCcJ0bBfQDAM7I8w4QgWXleUr4nDdZhumt9FWtLgBM2TtjZk+ixyW7 80mhVnWwaMwv2uy/luEbbeb+sFK2haxI/Yh3liGimhxpX4fA1NUYo/Bykm0lOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706015487; 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=MpTsqbRm/7LUvkcxZ0AyD5uJRHhE5ALqrQ6PV/OvYUc=; b=Rqc5v9+zUQ+oABH3eVS3CDpEx390ImF/uMcW41yMzYE6744komWHBhxtLZ2WoumUxO5ViX nB9JP7YfNF+lv8CQ== 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 v2 22/30] x86/cpu/topology: Mop up primary thread mask handling References: <20240118123127.055361964@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 23 Jan 2024 14:11:26 +0100 (CET) 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)); } }