linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Srikar Dronamraju <srikar@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
	linux-kernel@vger.kernel.org,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] powerpc/smp: Expose die_id and die_cpumask
Date: Mon, 10 Nov 2025 22:32:48 +0530	[thread overview]
Message-ID: <53fd537b-5549-427f-ad7d-28d58daaa5bd@linux.ibm.com> (raw)
In-Reply-To: <20251028105734.1894998-1-srikar@linux.ibm.com>



> 
> 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@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@linux.ibm.com>


      reply	other threads:[~2025-11-10 17:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28 10:57 [PATCH] powerpc/smp: Expose die_id and die_cpumask Srikar Dronamraju
2025-11-10 17:02 ` Shrikanth Hegde [this message]

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=53fd537b-5549-427f-ad7d-28d58daaa5bd@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.ibm.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).