From patchwork Fri Feb 16 15:16:45 2024 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: 202172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp586225dyb; Fri, 16 Feb 2024 07:22:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUW6jFLu4Bvz5LpMNabxo53+NwXisunUsABSJznFhXgnuUscYxm2nMAL5pQ8LDekNQKzzNdYeaOQYN0B7bIsdp2+r/pYg== X-Google-Smtp-Source: AGHT+IGpsKP4a7x8z0fgZitZOhmAUaTa7unVhaBTnEL1IrYEmJw2ELDWTYiRfYmLxNigQR0PShCo X-Received: by 2002:a17:902:e849:b0:1d9:713f:6224 with SMTP id t9-20020a170902e84900b001d9713f6224mr5681048plg.11.1708096971489; Fri, 16 Feb 2024 07:22:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708096971; cv=pass; d=google.com; s=arc-20160816; b=LkUo1c80YBbRxC4TU6dBWTITvLP38dGNmDjdX/W90m7URw+Mcs0ABR+1U/72tduZIq LBFr9kpcUMDT0CcmkSgK54AU+qvmRBlSF49n68OfgMfTbpb740zGrjEpus13KME+FlRq HoVKE9sHIM+FtN+8I9ggMvB59fPRL6jSRs6Xk1P1FSwzVC75yPJdsP90W+G9NK7KQvia dfN41N3kjIZtv/JN8bXS0BN/rizLiWfZNe32ADIXmoASl55fucZOvA6qzcTX2sStDFPG Im9vm54drFCguxdDapEYeTUaEUvVRwAqyuPyuJoImBZSrfmm+BrKrAey4P/T8oJerEzQ j2ew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=UvfbQ983vsDbDkLwt4MWftilcISBcmuNDYwYREOaqhQ=; fh=HfXWoIhgCc+vt39DMIJv/Ec0aAKnw0eFA8QxuIQTUoQ=; b=Su6khlc6A0MfG+z1gQiHF9ZUKrz8oHQf1wSG2j8OKJFYtvhjQ9eSckRJSCSnHFSjCf 9aCjVxe8bDHNn3QosGHSsJRavVcW9Lp61pVpM6V7NK6vp/EImGDmV1CGhIKqpgBsH/1E y1dLGLseA+0MgKpRit0URwNH2lMMrGHbqo69TpPA8lijoHZAs4fojejkoZLF1LZgww7b eKOU/Yt39kCVMAC1ftjPWEtUPSTlvLluheRlGKJm6oXZd7RJZCwFDeFVzAuvQSS0HScM bVK3rH3Z0SisOydbQvq95q/Wm7x+KU0Xr1+XysCbp5/biYvkdJkq6SmiCPCNqs3ke+KO ekGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ENMIdNGw; 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-68791-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68791-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t11-20020a170902e84b00b001db2ad29993si14573plg.158.2024.02.16.07.22.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:22:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68791-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ENMIdNGw; 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-68791-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68791-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 17F44B23091 for ; Fri, 16 Feb 2024 15:17:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 586B812FB3E; Fri, 16 Feb 2024 15:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ENMIdNGw"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wbZSeAw6" 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 5C83D12F58E; Fri, 16 Feb 2024 15:16:47 +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=1708096610; cv=none; b=gbMw2UMgBtjPYkK/H2KYmc/AN1v7gqj7yu+3MPfLcpnzaUOhDZ3SC/UB+DUTnDwZfkOQi8RfGkI2Sqs59F0HqfVrJ5Ka1cBK6xqOZhySZyLq0WfA94kelXQOysTn9ihELGkDK4k0wmSarnFvWyvdSoyglOop4Wi9dpMwB8D1PuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096610; c=relaxed/simple; bh=87aBUH2geLqP6qWJcMgFrUxnJ6oAgwG0kK+U7lTN4vM=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=VxSAGTOs01khC/2mKTqL3Y2qM0po6camvukJmEygIM+VoysJQwnLcmqWDPbgnpaNAMeqL/lg5qaPtR2HMNWD6cFzDvruWd4h6INDVMWWKMOjpBlEWu4biTAnGGt59T2Lb04jpicXFwZuFn8XaciDknM7MYeUvo9GZ+RnszPFKBQ= 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=ENMIdNGw; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wbZSeAw6; 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 Date: Fri, 16 Feb 2024 15:16:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708096606; 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=UvfbQ983vsDbDkLwt4MWftilcISBcmuNDYwYREOaqhQ=; b=ENMIdNGwsprTzd7jbD2HEaqCKcjSlx2p4yIHsOtJV2tux4kKqwW739xbRJ4nRAeGizQwFv sscuVNolx6L8+75ONdAnasYf090jjG0g2oCScXsplU4p/yY9O5VcRi5NGfGNxdZ5PMD/oG LzYyfX+Ix+vC0SxBo6fH+KkX1Y4mf1zazy2/Ea3wG0f1F/cgRKSAqgcbl0TeSmU4Su9YxP oRzc2zUguQKerFBTY5cJjLaflsGS3K9Ct9dIQZpeICdHvLbweIS8rT9dLRD5rW3L/xIJul WxPeVlssXtqYYw533M/a8xSRTXaiELcvusN5OR/yK/OUZWqz3u6UVk5x6/0zKg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708096606; 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=UvfbQ983vsDbDkLwt4MWftilcISBcmuNDYwYREOaqhQ=; b=wbZSeAw6Ol6Q9E1ODWUGmB8KOQQyrtA/2ranfarbgkbri3cQoAN7z78b7eBhMGUeBAo4r8 0MPg+HkwnqPDi6DQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/cpu/topology: Provide __num_[cores|threads]_per_package Cc: Thomas Gleixner , Michael Kelley , Sohil Mehta , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240213210253.120958987@linutronix.de> References: <20240213210253.120958987@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170809660562.398.5308891544456323136.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790820321010439551 X-GMAIL-MSGID: 1791069490089300353 The following commit has been merged into the x86/apic branch of tip: Commit-ID: fd43b8ae76e903c76f14d06eb939449bcc3f614f Gitweb: https://git.kernel.org/tip/fd43b8ae76e903c76f14d06eb939449bcc3f614f Author: Thomas Gleixner AuthorDate: Tue, 13 Feb 2024 22:06:14 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 15 Feb 2024 22:07:45 +01:00 x86/cpu/topology: Provide __num_[cores|threads]_per_package Expose properly accounted information and accessors so the fiddling with other topology variables can be replaced. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley Tested-by: Sohil Mehta Link: https://lore.kernel.org/r/20240213210253.120958987@linutronix.de --- arch/x86/include/asm/topology.h | 12 ++++++++++++ arch/x86/kernel/cpu/common.c | 6 ++++++ arch/x86/kernel/cpu/topology.c | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index 6a71794..76b1d87 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -146,6 +146,8 @@ extern const struct cpumask *cpu_clustergroup_mask(int cpu); extern unsigned int __max_dies_per_package; extern unsigned int __max_logical_packages; extern unsigned int __max_threads_per_core; +extern unsigned int __num_threads_per_package; +extern unsigned int __num_cores_per_package; static inline unsigned int topology_max_packages(void) { @@ -157,6 +159,16 @@ static inline unsigned int topology_max_dies_per_package(void) return __max_dies_per_package; } +static inline unsigned int topology_num_cores_per_package(void) +{ + return __num_cores_per_package; +} + +static inline unsigned int topology_num_threads_per_package(void) +{ + return __num_threads_per_package; +} + #ifdef CONFIG_X86_LOCAL_APIC int topology_get_logical_id(u32 apicid, enum x86_topology_domains at_level); #else diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index cb22cb8..c9a1014 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -82,6 +82,12 @@ EXPORT_SYMBOL(__max_dies_per_package); unsigned int __max_logical_packages __ro_after_init = 1; EXPORT_SYMBOL(__max_logical_packages); +unsigned int __num_cores_per_package __ro_after_init = 1; +EXPORT_SYMBOL(__num_cores_per_package); + +unsigned int __num_threads_per_package __ro_after_init = 1; +EXPORT_SYMBOL(__num_threads_per_package); + static struct ppin_info { int feature; int msr_ppin_ctl; diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c index b078fac..41dd8e0 100644 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -392,7 +392,7 @@ void __init topology_init_possible_cpus(void) unsigned int disabled = topo_info.nr_disabled_cpus; unsigned int cnta, cntb, cpu, allowed = 1; unsigned int total = assigned + disabled; - u32 apicid; + u32 apicid, firstid; if (!restrict_to_up()) { if (WARN_ON_ONCE(assigned > nr_cpu_ids)) { @@ -432,6 +432,12 @@ void __init topology_init_possible_cpus(void) __max_threads_per_core = DIV_ROUND_UP(cntb, cnta); pr_info("Max. threads per core: %3u\n", __max_threads_per_core); + firstid = find_first_bit(apic_maps[TOPO_SMT_DOMAIN].map, MAX_LOCAL_APIC); + __num_cores_per_package = topology_unit_count(firstid, TOPO_CORE_DOMAIN, TOPO_PKG_DOMAIN); + pr_info("Num. cores per package: %3u\n", __num_cores_per_package); + __num_threads_per_package = topology_unit_count(firstid, TOPO_SMT_DOMAIN, TOPO_PKG_DOMAIN); + pr_info("Num. threads per package: %3u\n", __num_threads_per_package); + pr_info("Allowing %u present CPUs plus %u hotplug CPUs\n", assigned, disabled); if (topo_info.nr_rejected_cpus) pr_info("Rejected CPUs %u\n", topo_info.nr_rejected_cpus);