mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyle Meyer <kyle.meyer@hpe.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org, tglx@kernel.org, linux-kernel@vger.kernel.org,
	tim.c.chen@linux.intel.com, yu.c.chen@intel.com,
	vinicius.gomes@intel.com, brgerst@gmail.com, hpa@zytor.com,
	kprateek.nayak@amd.com, patryk.wlazlyn@linux.intel.com,
	rafael.j.wysocki@intel.com, russ.anderson@hpe.com,
	zhao1.liu@intel.com, tony.luck@intel.com
Subject: Re: [RFC][PATCH 3/6] x86/topo: Add __num_nodes_per_package
Date: Thu, 26 Feb 2026 11:46:15 -0600	[thread overview]
Message-ID: <aaCG5zN0XvnJf5wB@hpe.com> (raw)
In-Reply-To: <20260226105052.472660569@infradead.org>

On Thu, Feb 26, 2026 at 11:49:12AM +0100, Peter Zijlstra wrote:
> Use the MADT and SRAT table data to compute __num_nodes_per_package.
> 
> This number is useful to divinate the various Intel CoD/SNC modes,
> since the platforms are failing to provide this otherwise.
> 
> Doing it this way is independent of the number of online CPUs and
> other such shenanigans.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  arch/x86/include/asm/topology.h |    1 +
>  arch/x86/kernel/cpu/common.c    |    3 +++
>  arch/x86/kernel/cpu/topology.c  |    9 ++++++++-
>  3 files changed, 12 insertions(+), 1 deletion(-)
> 
> --- a/arch/x86/include/asm/topology.h
> +++ b/arch/x86/include/asm/topology.h
> @@ -158,6 +158,7 @@ extern unsigned int __max_logical_packag
>  extern unsigned int __max_threads_per_core;
>  extern unsigned int __num_threads_per_package;
>  extern unsigned int __num_cores_per_package;
> +extern unsigned int __num_nodes_per_package;
>  
>  const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
>  enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -95,6 +95,9 @@ EXPORT_SYMBOL(__max_dies_per_package);
>  unsigned int __max_logical_packages __ro_after_init = 1;
>  EXPORT_SYMBOL(__max_logical_packages);
>  
> +unsigned int __num_nodes_per_package __ro_after_init = 1;
> +EXPORT_SYMBOL(__num_nodes_per_package);
> +
>  unsigned int __num_cores_per_package __ro_after_init = 1;
>  EXPORT_SYMBOL(__num_cores_per_package);
>  
> --- a/arch/x86/kernel/cpu/topology.c
> +++ b/arch/x86/kernel/cpu/topology.c
> @@ -497,11 +497,18 @@ void __init topology_init_possible_cpus(
>  	set_nr_cpu_ids(allowed);
>  
>  	cnta = domain_weight(TOPO_PKG_DOMAIN);
> +	cntb = domain_weight(TOPO_NUMA_DOMAIN);

We'll need to check CONFIG_NUMA here.

TOPO_NUMA_DOMAIN is undeclared when CONFIG_NUMA is not set.

> +
> +	__num_nodes_per_package = DIV_ROUND_UP(cntb, cnta);
> +
> +	pr_info("Max. logical packages: %3u\n", cnta);
> +	pr_info("Max. logical nodes:    %3u\n", cntb);
> +	pr_info("Num. nodes per package:%3u\n", __num_nodes_per_package);
> +
>  	cntb = domain_weight(TOPO_DIE_DOMAIN);
>  	__max_logical_packages = cnta;
>  	__max_dies_per_package = 1U << (get_count_order(cntb) - get_count_order(cnta));
>  
> -	pr_info("Max. logical packages: %3u\n", cnta);
>  	pr_info("Max. logical dies:     %3u\n", cntb);
>  	pr_info("Max. dies per package: %3u\n", __max_dies_per_package);
>  
> 
> 

  reply	other threads:[~2026-02-26 17:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 10:49 [RFC][PATCH 0/6] x86/topo: SNC Divination Peter Zijlstra
2026-02-26 10:49 ` [RFC][PATCH 1/6] x86/topo: Store extra copy of SRAT table Peter Zijlstra
2026-02-26 10:49 ` [RFC][PATCH 2/6] x86/topo: Add TOPO_NUMA_DOMAIN Peter Zijlstra
2026-02-27 13:19   ` K Prateek Nayak
2026-02-27 14:06     ` Peter Zijlstra
2026-03-02  4:16       ` K Prateek Nayak
2026-03-02 15:10         ` Peter Zijlstra
2026-03-02 15:35           ` K Prateek Nayak
2026-03-02 16:28             ` Peter Zijlstra
2026-02-26 10:49 ` [RFC][PATCH 3/6] x86/topo: Add __num_nodes_per_package Peter Zijlstra
2026-02-26 17:46   ` Kyle Meyer [this message]
2026-02-27 11:57     ` Peter Zijlstra
2026-02-26 10:49 ` [RFC][PATCH 4/6] x86/topo: Replace x86_has_numa_in_package Peter Zijlstra
2026-02-26 10:49 ` [RFC][PATCH 5/6] x86/topo: Fix SNC topology mess Peter Zijlstra
2026-02-26 17:07   ` Chen, Yu C
2026-02-26 19:00     ` Tim Chen
2026-02-26 22:11       ` Tim Chen
2026-02-26 22:25         ` Tim Chen
2026-02-27 13:01       ` Peter Zijlstra
2026-02-27 19:23         ` Tim Chen
2026-02-28  7:35           ` Chen, Yu C
2026-03-02 16:43             ` Peter Zijlstra
2026-03-03  6:31               ` Zhang Rui
2026-03-03  6:39                 ` Chen, Yu C
2026-03-03  8:44                 ` Peter Zijlstra
2026-02-27 11:56     ` Peter Zijlstra
2026-02-26 10:49 ` [RFC][PATCH 6/6] x86/resctrl: Fix SNC detection Peter Zijlstra
2026-02-26 19:42   ` Luck, Tony
2026-02-26 20:47     ` Luck, Tony
2026-02-27  9:26       ` Peter Zijlstra
2026-02-26 19:16 ` [RFC][PATCH 0/6] x86/topo: SNC Divination Luck, Tony
2026-03-02 18:21 ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aaCG5zN0XvnJf5wB@hpe.com \
    --to=kyle.meyer@hpe.com \
    --cc=brgerst@gmail.com \
    --cc=hpa@zytor.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patryk.wlazlyn@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=russ.anderson@hpe.com \
    --cc=tglx@kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=tony.luck@intel.com \
    --cc=vinicius.gomes@intel.com \
    --cc=x86@kernel.org \
    --cc=yu.c.chen@intel.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome