This series prepares cpu_to_coregroup_id() for broader use and enables
coregroup support on PowerNV when firmware exposes the required
associativity information.
The first patch cleans up find_primary_domain_index(). The second makes
cpu_to_coregroup_id() available outside PPC_SPLPAR while preserving the
existing fallback behavior. The final patch detects coregroup support
from the associativity hierarchy and uses it on PowerNV systems.
Changelog from v2: https://lkml.kernel.org/r/20260605055242.1757485-5-srikar@linux.ibm.com
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
patch 3 to build correctly)
Changelog from v1: https://lkml.kernel.org/r/20260524010017.140408-1-srikar@linux.ibm.com
- Split into 3 patches
- Handle comments from Christophe Leroy
Srikar Dronamraju (3):
powerpc/numa: Simplify find_primary_domain_index
powerpc/numa: Allow cpu_to_coregroup_id without PPC_SPLPAR
powerpc/numa: Support coregroup on PowerNV
arch/powerpc/include/asm/topology.h | 15 +++--
arch/powerpc/mm/numa.c | 85 ++++++++++++++++++++++-------
2 files changed, 71 insertions(+), 29 deletions(-)
--
2.43.7
Initialize the return value once and use a single exit path in
find_primary_domain_index().
This is a small cleanup that keeps the existing behavior unchanged while
making the control flow easier to follow.
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog from v1:
- Handle comments from Christophe Leroy
arch/powerpc/mm/numa.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Coregroup support on powerpc has so far been limited to PowerVM LPARs.
However, PowerNV can also support coregroups when firmware exposes the
required coregroup information through the associativity hierarchy.
Detect coregroup support by checking whether primary_domain_index is the
penultimate domain in the CPU node's ibm,associativity property. On
PowerNV, a non-penultimate primary_domain_index indicates that firmware
provides an additional level for coregroup information.
This keeps the logic compatible with PowerVM systems, where
primary_domain_index is likewise not the penultimate associativity
domain.
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog from v2:
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
patch 3 to build correctly)
Changelog from v1: https://lkml.kernel.org/r/20260524010017.140408-1-srikar@linux.ibm.com
- Handle comments from Christophe Leroy; make code more flat
arch/powerpc/mm/numa.c | 58 ++++++++++++++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 10 deletions(-)
@@ -889,12 +889,32 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,return0;}+/*+*Ifhierarchyextendsbeyondprimary_domain_index+1,thennext+*levelcorrespondstocoregroup.+*/+staticintdetect_and_enable_coregroup(const__be32*associativity,intindex)+{+if(!associativity||index==-1)+gotoout;++index=of_read_number(associativity,1);++if(index>primary_domain_index+1){+coregroup_enabled=1;+returnindex;+}+out:+coregroup_enabled=0;+return-1;+}+staticint__initparse_numa_properties(void){structdevice_node*memory,*pci;-intdefault_nid=0;-unsignedlongi;+intdefault_nid=0,index=0;const__be32*associativity;+unsignedlongi;if(numa_enabled==0){pr_warn("disabled by user\n");
@@ -927,7 +947,6 @@ static int __init parse_numa_properties(void)*/for_each_present_cpu(i){__be32vphn_assoc[VPHN_ASSOC_BUFSIZE];-structdevice_node*cpu;intnid=NUMA_NO_NODE;memset(vphn_assoc,0,VPHN_ASSOC_BUFSIZE*sizeof(__be32));
@@ -935,7 +954,9 @@ static int __init parse_numa_properties(void)if(__vphn_get_associativity(i,vphn_assoc)==0){nid=associativity_to_nid(vphn_assoc);initialize_form1_numa_distance(vphn_assoc);+index=detect_and_enable_coregroup(vphn_assoc,index);}else{+structdevice_node*cpu;/**Don'tfallbacktodefault_nidyet--wewillplug
@@ -948,6 +969,7 @@ static int __init parse_numa_properties(void)associativity=of_get_associativity(cpu);if(associativity){nid=associativity_to_nid(associativity);+index=detect_and_enable_coregroup(associativity,index);initialize_form1_numa_distance(associativity);}of_node_put(cpu);
@@ -1445,7 +1467,9 @@ static long vphn_get_associativity(unsigned long cpu,intcpu_to_coregroup_id(intcpu){-__be32associativity[VPHN_ASSOC_BUFSIZE]={0};+intcoregroup_id=cpu_to_core_id(cpu);+structdevice_node*cpunode=NULL;+const__be32*associativity;intindex;if(cpu<0||cpu>nr_cpu_ids)
@@ -1454,17 +1478,31 @@ int cpu_to_coregroup_id(int cpu)if(!coregroup_enabled)gotoout;-if(!firmware_has_feature(FW_FEATURE_VPHN))-gotoout;+if(firmware_has_feature(FW_FEATURE_VPHN)){+__be32tmp[VPHN_ASSOC_BUFSIZE]={0};-if(vphn_get_associativity(cpu,associativity))+if(vphn_get_associativity(cpu,tmp))+gotoout;++associativity=tmp;++}else{+cpunode=of_get_cpu_node(cpu,NULL);+if(!cpunode)+gotoout;++associativity=of_get_associativity(cpunode);+}+if(!associativity)gotoout;index=of_read_number(associativity,1);if(index>primary_domain_index+1)-returnof_read_number(&associativity[index-1],1);+coregroup_id=of_read_number(&associativity[index-1],1);out:-returncpu_to_core_id(cpu);-}+if(cpunode)+of_node_put(cpunode);+returncoregroup_id;+}
Make cpu_to_coregroup_id() available outside PPC_SPLPAR so it can be
used by platforms that do not rely on the SPLPAR-specific VPHN path.
Keep the existing fallback behavior by returning the core ID when
coregroup information is unavailable.
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog from v2:
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
patch 3 to build correctly)
Changelog from v1:
- Handle comments from Christophe Leroy; Remove extern key word in
declaration
arch/powerpc/include/asm/topology.h | 15 +++++++--------
arch/powerpc/mm/numa.c | 22 +++++++++++++++-------
2 files changed, 22 insertions(+), 15 deletions(-)
Make cpu_to_coregroup_id() available outside PPC_SPLPAR so it can be
used by platforms that do not rely on the SPLPAR-specific VPHN path.
Keep the existing fallback behavior by returning the core ID when
coregroup information is unavailable.
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog from v2:
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
patch 3 to build correctly)
Changelog from v1:
- Handle comments from Christophe Leroy; Remove extern key word in
declaration
arch/powerpc/include/asm/topology.h | 15 +++++++--------
arch/powerpc/mm/numa.c | 22 +++++++++++++++-------
2 files changed, 22 insertions(+), 15 deletions(-)
nit:
I prefer extern before declaration so that i can see it is defined
elsewhere.
Other than that, rest looks good to me.
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
quoted hunk
#else
static inline int early_cpu_to_node(int cpu) { return 0; }
Coregroup support on powerpc has so far been limited to PowerVM LPARs.
However, PowerNV can also support coregroups when firmware exposes the
required coregroup information through the associativity hierarchy.
Existing firmware does expose this info already?
Detect coregroup support by checking whether primary_domain_index is the
penultimate domain in the CPU node's ibm,associativity property. On
PowerNV, a non-penultimate primary_domain_index indicates that firmware
provides an additional level for coregroup information.
This keeps the logic compatible with PowerVM systems, where
primary_domain_index is likewise not the penultimate associativity
domain.
Could you please put the ibm,associativity on this powernv? as well
PowerVM's so that one understands it better?
quoted hunk
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog from v2:
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
patch 3 to build correctly)
Changelog from v1: https://lkml.kernel.org/r/20260524010017.140408-1-srikar@linux.ibm.com
- Handle comments from Christophe Leroy; make code more flat
arch/powerpc/mm/numa.c | 58 ++++++++++++++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 10 deletions(-)
Initialize the return value once and use a single exit path in
find_primary_domain_index().
This is a small cleanup that keeps the existing behavior unchanged while
making the control flow easier to follow.
* Shrikanth Hegde [off-list ref] [2026-09-04 15:34:50]:
Thanks Shrikanth for taking a look.
On 9/2/26 6:05 PM, Srikar Dronamraju wrote:
quoted
Coregroup support on powerpc has so far been limited to PowerVM LPARs.
However, PowerNV can also support coregroups when firmware exposes the
required coregroup information through the associativity hierarchy.
Existing firmware does expose this info already?
The corresponding skiboot changes were sent to the skiboot mailing list.
quoted
Detect coregroup support by checking whether primary_domain_index is the
penultimate domain in the CPU node's ibm,associativity property. On
PowerNV, a non-penultimate primary_domain_index indicates that firmware
provides an additional level for coregroup information.
This keeps the logic compatible with PowerVM systems, where
primary_domain_index is likewise not the penultimate associativity
domain.
Could you please put the ibm,associativity on this powernv? as well
PowerVM's so that one understands it better?
With this patch and the skiboot change, the ibm,associativity will look
similar.
For example on a Power10 Baremetal box with skiboot changes.
$ lsprop /proc/device-tree/cpus/PowerPC,POWER10@*/ibm,associativity |& head -n 20
PowerPC,POWER10@0/ibm,associativity
00000005 00000000 00000000 00000000 00000000 00000000
PowerPC,POWER10@100/ibm,associativity
00000005 00000000 00000001 00000001 00000002 00000000
PowerPC,POWER10@108/ibm,associativity
00000005 00000000 00000001 00000001 00000002 00000002
PowerPC,POWER10@10/ibm,associativity
00000005 00000000 00000000 00000000 00000001 00000004
PowerPC,POWER10@110/ibm,associativity
00000005 00000000 00000001 00000001 00000003 00000004
PowerPC,POWER10@118/ibm,associativity
00000005 00000000 00000001 00000001 00000003 00000006
PowerPC,POWER10@120/ibm,associativity
00000005 00000000 00000001 00000001 00000002 00000008
PowerPC,POWER10@128/ibm,associativity
00000005 00000000 00000001 00000001 00000002 0000000a
PowerPC,POWER10@130/ibm,associativity
00000005 00000000 00000001 00000001 00000003 0000000c
PowerPC,POWER10@138/ibm,associativity
00000005 00000000 00000001 00000001 00000003 0000000e
quoted
Signed-off-by: Srikar Dronamraju <redacted>
---
Changelog from v2:
- Handle comments from Ritesh (one hunk needed to be moved from patch 2 to
patch 3 to build correctly)
Changelog from v1: https://lkml.kernel.org/r/20260524010017.140408-1-srikar@linux.ibm.com
- Handle comments from Christophe Leroy; make code more flat
arch/powerpc/mm/numa.c | 58 ++++++++++++++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 10 deletions(-)