[PATCH] powerpc/smp: Expose die_id and die_cpumask
Shrikanth Hegde
sshegde at linux.ibm.com
Tue Nov 11 04:02:48 AEDT 2025
>
> Without this change.
> $ grep . /sys/devices/system/cpu/cpu8/topology/{die*,package*} 2> /dev/null
> /sys/devices/system/cpu/cpu8/topology/package_cpus:0000,ffffff00
> /sys/devices/system/cpu/cpu8/topology/package_cpus_list:8-31
>
> With this change.
> $ grep . /sys/devices/system/cpu/cpu8/topology/{die*,package*} 2> /dev/null
> /sys/devices/system/cpu/cpu8/topology/die_cpus:0000,0000ff00
> /sys/devices/system/cpu/cpu8/topology/die_cpus_list:8-15
> /sys/devices/system/cpu/cpu8/topology/die_id:4
> /sys/devices/system/cpu/cpu8/topology/package_cpus:0000,ffffff00
> /sys/devices/system/cpu/cpu8/topology/package_cpus_list:8-31
>
> snipped lstopo-no-graphics o/p
> Group0 L#0
> Package L#1
> NUMANode L#1 (P#2 8135MB)
> Die L#0 + Core L#1
Die L#0 -> Here L# indicates logical die number.
One should run --verbose to see theactual die_id.
For example:
Die L#8 (P#25) --> die_id is 25.
Maybe you could the same CPU's (CPU8) info of lstopo here?
> L3 L#2 (4096KB) + L2 L#2 (1024KB) + L1d L#2 (32KB) + L1i L#2 (48KB)
> PU L#8 (P#8)
>
> Signed-off-by: Srikar Dronamraju <srikar at linux.ibm.com>
> ---
> arch/powerpc/include/asm/topology.h | 4 ++++
> arch/powerpc/kernel/smp.c | 18 ++++++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
> index f19ca44512d1..c6ad1eb7e44a 100644
> --- a/arch/powerpc/include/asm/topology.h
> +++ b/arch/powerpc/include/asm/topology.h
> @@ -132,6 +132,8 @@ static inline int cpu_to_coregroup_id(int cpu)
> #include <asm/cputable.h>
>
> struct cpumask *cpu_coregroup_mask(int cpu);
> +const struct cpumask *cpu_die_mask(int cpu);
> +int cpu_die_id(int cpu);
>
> #ifdef CONFIG_PPC64
> #include <asm/smp.h>
> @@ -141,6 +143,8 @@ struct cpumask *cpu_coregroup_mask(int cpu);
> #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
> #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
> #define topology_core_id(cpu) (cpu_to_core_id(cpu))
> +#define topology_die_id(cpu) (cpu_die_id(cpu))
> +#define topology_die_cpumask(cpu) (cpu_die_mask(cpu))
>
nit:
can we fix the tab spacing here please? Maybe like below?
+#define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
+#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
+#define topology_core_id(cpu) (cpu_to_core_id(cpu))
+#define topology_die_id(cpu) (cpu_die_id(cpu))
+#define topology_die_cpumask(cpu) (cpu_die_mask(cpu))
> #endif
> #endif
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 68edb66c2964..a0b0b46b78e3 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -1085,6 +1085,24 @@ static int __init init_big_cores(void)
> return 0;
> }
>
As you have mentioned in the changelog, could you add a comment here
explaining on which systems we see this information correctly.
> +const struct cpumask *cpu_die_mask(int cpu)
> +{
> + if (has_coregroup_support())
> + return per_cpu(cpu_coregroup_map, cpu);
> + else
> + return cpu_node_mask(cpu);
> +}
> +EXPORT_SYMBOL_GPL(cpu_die_mask);
> +
> +int cpu_die_id(int cpu)
> +{
> + if (has_coregroup_support())
> + return cpu_to_coregroup_id(cpu);
> + else
> + return -1;
> +}
> +EXPORT_SYMBOL_GPL(cpu_die_id);
> +
> void __init smp_prepare_cpus(unsigned int max_cpus)
> {
> unsigned int cpu, num_threads;
Other than above:
Reviewed-by: Shrikanth Hegde <sshegde at linux.ibm.com>
More information about the Linuxppc-dev
mailing list