powerpc/numa: Enable coregroup support on PowerNV
v2 cover powerpc/numa: Enable coregroup support on PowerNV
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 v1: https://lkml.kernel.org/r/[email protected]
- 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(-)
Signature · 1 line
2.43.0
PATCH v2 1/3 powerpc/numa: Simplify find_primary_domain_index
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.
---
Changelog from v1:
- Handle comments from Christophe Leroy
arch/powerpc/mm/numa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
arch/powerpc/mm/numa.c +2 -5
@@ -432,7 +432,7 @@ static void __init initialize_form2_numa_distance_lookup_table(void)static int __init find_primary_domain_index (void ) { -int index; +int index =-1 ;struct device_node *root;/*
@@ -502,12 +502,9 @@ static int __init find_primary_domain_index(void) distance_ref_points_depth =MAX_DISTANCE_REF_POINTS ; } -of_node_put (root); -return index; - err:of_node_put (root); -return -1 ; +return index; }static void __init get_n_mem_cells (int *n_addr_cells,int *n_size_cells)
Signature · 1 line
2.43.0
Re: [PATCH v2 1/3] powerpc/numa: Simplify find_primary_domain_index
Quoted 7 lines · Srikar Dronamraju
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 <[email protected]>
Cleanup LGTM. Feel free to add:
PATCH v2 2/3 powerpc/numa: Allow cpu_to_coregroup_id without PPC_SPLPAR
In reply to Srikar DronamrajuMake 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.
---
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, 23 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/topology.h +7 -8
@@ -71,6 +71,7 @@ extern void map_cpu_to_node(int cpu, int node);extern void unmap_cpu_from_node (unsigned long cpu);#endif /* CONFIG_HOTPLUG_CPU */ +int cpu_to_coregroup_id (int cpu);#else static inline int early_cpu_to_node (int cpu) {return 0 ; }
@@ -107,14 +108,6 @@ static inline void map_cpu_to_node(int cpu, int node) {}static inline void unmap_cpu_from_node (unsigned long cpu) {}#endif /* CONFIG_HOTPLUG_CPU */ #endif /* CONFIG_SMP */ - -#endif /* CONFIG_NUMA */ - -#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR ) -void find_and_update_cpu_nid (int cpu); -extern int cpu_to_coregroup_id (int cpu); -#else -static inline void find_and_update_cpu_nid (int cpu) {}static inline int cpu_to_coregroup_id (int cpu) {#ifdef CONFIG_SMP
@@ -124,6 +117,12 @@ static inline int cpu_to_coregroup_id(int cpu) #endif } +#endif /* CONFIG_NUMA */ + +#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR ) +void find_and_update_cpu_nid (int cpu); +#else +static inline void find_and_update_cpu_nid (int cpu) {}#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ #include <asm-generic/topology.h>
arch/powerpc/mm/numa.c +16 -6
@@ -1428,6 +1428,21 @@ void find_and_update_cpu_nid(int cpu) pr_debug("%s:%d cpu %d nid %d\n", __func__, __LINE__, cpu, new_nid); } +static int topology_update_init (void ) +{ + topology_inited =1 ; +return 0 ; +} +device_initcall (topology_update_init); + +#else +static long vphn_get_associativity (unsigned long cpu, +__be32 *associativity) +{ +return -1 ; +} +#endif /* CONFIG_PPC_SPLPAR */ +int cpu_to_coregroup_id (int cpu) {__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 };
@@ -1453,10 +1468,5 @@ int cpu_to_coregroup_id(int cpu)return cpu_to_core_id (cpu); } -static int topology_update_init (void ) -{ - topology_inited =1 ; -return 0 ; +return coregroup_id; } -device_initcall (topology_update_init); -#endif /* CONFIG_PPC_SPLPAR */
Signature · 1 line
2.43.0
Ritesh Harjani (IBM)
reviewerRe: [PATCH v2 2/3] powerpc/numa: Allow cpu_to_coregroup_id without PPC_SPLPAR
Quoted 6 lines · Srikar Dronamraju
Make
cpu_to_coregroup_id()available outsidePPC_SPLPARso 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.
Looks like this mainly brings the cpu_to_coregroup_id() outside of CONFIG_PPC_SPLPAR gate.
Quoted 77 lines
Signed-off-by Srikar Dronamraju <[email protected]>---
Changelog from v1:
- Handle comments from Christophe Leroy; Remove extern key word in declarationarch/powerpc/include/asm/topology.h | 15 +++++++-------- arch/powerpc/mm/numa.c | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 14 deletions(-)arch/powerpc/include/asm/topology.h +7
-8@@ -71,6 +71,7 @@ extern void map_cpu_to_node(int cpu, int node);extern void unmap_cpu_from_node (unsigned long cpu);#endif /* CONFIG_HOTPLUG_CPU */ +int cpu_to_coregroup_id (int cpu);#else static inline int early_cpu_to_node (int cpu) {return 0 ; }@@ -107,14 +108,6 @@ static inline void map_cpu_to_node(int cpu, int node) {}static inline void unmap_cpu_from_node (unsigned long cpu) {}#endif /* CONFIG_HOTPLUG_CPU */ #endif /* CONFIG_SMP */ - -#endif /* CONFIG_NUMA */ - -#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR ) -void find_and_update_cpu_nid (int cpu); -extern int cpu_to_coregroup_id (int cpu); -#else -static inline void find_and_update_cpu_nid (int cpu) {}static inline int cpu_to_coregroup_id (int cpu) {#ifdef CONFIG_SMP @@ -124,6 +117,12 @@ static inline int cpu_to_coregroup_id(int cpu) #endif } +#endif /* CONFIG_NUMA */ + +#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR ) +void find_and_update_cpu_nid (int cpu); +#else +static inline void find_and_update_cpu_nid (int cpu) {}#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ #include <asm-generic/topology.h> arch/powerpc/mm/numa.c +15
-0@@ -1428,6 +1428,21 @@ void find_and_update_cpu_nid(int cpu) pr_debug("%s:%d cpu %d nid %d\n", __func__, __LINE__, cpu, new_nid); } +static int topology_update_init (void ) +{ + topology_inited =1 ; +return 0 ; +} +device_initcall (topology_update_init); + +#else +static long vphn_get_associativity (unsigned long cpu, +__be32 *associativity) +{ +return -1 ; +} +#endif /* CONFIG_PPC_SPLPAR */ +int cpu_to_coregroup_id (int cpu) {__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 };
arch/powerpc/mm/numa.c int cpu_to_coregroup_id(int cpu) · line 1472
Quoted 9 lines
arch/powerpc/mm/numa.c +1
-4@@ -1453,10 +1468,5 @@ int cpu_to_coregroup_id(int cpu)return cpu_to_core_id (cpu); } -static int topology_update_init (void ) -{ - topology_inited =1 ; -return 0 ; +return coregroup_id; }
These above two lines seems to be out of any function scope. So applying only patch-1 & patch-2 will give a compile error. This needs fixing.
-ritesh
Quoted 4 lines
arch/powerpc/mm/numa.c +0
-2-device_initcall (topology_update_init); -#endif /* CONFIG_PPC_SPLPAR */ Signature · 1 line
2.43.0
Re: [PATCH v2 2/3] powerpc/numa: Allow cpu_to_coregroup_id without PPC_SPLPAR
Quoted 5 lines · Ritesh Harjani
Quoted 3 lines · Srikar Dronamraju
Make
cpu_to_coregroup_id()available outsidePPC_SPLPARso it can be used by platforms that do not rely on the SPLPAR-specific VPHN path.
Quoted 7 lines
Quoted 3 lines
Keep the existing fallback behavior by returning the core ID when coregroup information is unavailable.
Looks like this mainly brings the
cpu_to_coregroup_id()outside ofCONFIG_PPC_SPLPARgate.
Yes, thats the intent of the patch
Quoted 80 lines
Quoted 80 lines
Signed-off-by Srikar Dronamraju <[email protected]>---
Changelog from v1:
- Handle comments from Christophe Leroy; Remove extern key word in declarationarch/powerpc/include/asm/topology.h | 15 +++++++-------- arch/powerpc/mm/numa.c | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 14 deletions(-)arch/powerpc/include/asm/topology.h +7
-8@@ -71,6 +71,7 @@ extern void map_cpu_to_node(int cpu, int node);extern void unmap_cpu_from_node (unsigned long cpu);#endif /* CONFIG_HOTPLUG_CPU */ +int cpu_to_coregroup_id (int cpu);#else static inline int early_cpu_to_node (int cpu) {return 0 ; }@@ -107,14 +108,6 @@ static inline void map_cpu_to_node(int cpu, int node) {}static inline void unmap_cpu_from_node (unsigned long cpu) {}#endif /* CONFIG_HOTPLUG_CPU */ #endif /* CONFIG_SMP */ - -#endif /* CONFIG_NUMA */ - -#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR ) -void find_and_update_cpu_nid (int cpu); -extern int cpu_to_coregroup_id (int cpu); -#else -static inline void find_and_update_cpu_nid (int cpu) {}static inline int cpu_to_coregroup_id (int cpu) {#ifdef CONFIG_SMP @@ -124,6 +117,12 @@ static inline int cpu_to_coregroup_id(int cpu) #endif } +#endif /* CONFIG_NUMA */ + +#if defined(CONFIG_NUMA ) && defined(CONFIG_PPC_SPLPAR ) +void find_and_update_cpu_nid (int cpu); +#else +static inline void find_and_update_cpu_nid (int cpu) {}#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ #include <asm-generic/topology.h> arch/powerpc/mm/numa.c +15
-0@@ -1428,6 +1428,21 @@ void find_and_update_cpu_nid(int cpu) pr_debug("%s:%d cpu %d nid %d\n", __func__, __LINE__, cpu, new_nid); } +static int topology_update_init (void ) +{ + topology_inited =1 ; +return 0 ; +} +device_initcall (topology_update_init); + +#else +static long vphn_get_associativity (unsigned long cpu, +__be32 *associativity) +{ +return -1 ; +} +#endif /* CONFIG_PPC_SPLPAR */ +int cpu_to_coregroup_id (int cpu) {__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 };@@ -1453,10 +1468,5 @@ int cpu_to_coregroup_id(int cpu)return cpu_to_core_id (cpu); }
Quoted 10 lines
arch/powerpc/mm/numa.c int cpu_to_coregroup_id(int cpu) · line 1472
Quoted 6 lines
arch/powerpc/mm/numa.c +1
-4-static int topology_update_init (void ) -{ - topology_inited =1 ; -return 0 ; +return coregroup_id; }These above two lines seems to be out of any function scope. So applying only patch-1 & patch-2 will give a compile error. This needs fixing.
Yes, will fix this
Quoted 6 lines
-ritesh
Quoted 4 lines
arch/powerpc/mm/numa.c +0
-2-device_initcall (topology_update_init); -#endif /* CONFIG_PPC_SPLPAR */ Signature · 1 line
2.43.0
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
PATCH v2 3/3 powerpc/numa: Support coregroup on PowerNV
In reply to Srikar DronamrajuCoregroup 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.
---
Changelog from v1: https://lkml.kernel.org/r/[email protected]
- Handle comments from Christophe Leroy; make code more flat
arch/powerpc/mm/numa.c | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)
arch/powerpc/mm/numa.c +46 -10
@@ -889,12 +889,32 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,return 0 ; } +/* +* If hierarchy extends beyond primary_domain_index + 1, then next +* level corresponds to coregroup. +*/ +static int detect_and_enable_coregroup (const __be32 *associativity,int index) +{ +if (!associativity || index ==-1 ) + goto out; + + index =of_read_number (associativity,1 ); + +if (index > primary_domain_index +1 ) { + coregroup_enabled =1 ; +return index; + } +out: + coregroup_enabled =0 ; +return -1 ; +} +static int __init parse_numa_properties (void ) {struct device_node *memory, *pci; -int default_nid =0 ; -unsigned long i; +int default_nid =0 , index =0 ;const __be32 *associativity; +unsigned long i;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) {__be32 vphn_assoc[VPHN_ASSOC_BUFSIZE ]; -struct device_node *cpu;int nid =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 { +struct device_node *cpu;/* * Don't fall back to default_nid yet -- we will plug
@@ -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,int cpu_to_coregroup_id (int cpu) { -__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 }; +int coregroup_id =cpu_to_core_id (cpu); +struct device_node *cpunode =NULL ; +const __be32 *associativity;int index;if (cpu <0 || cpu > nr_cpu_ids)
@@ -1454,19 +1478,31 @@ int cpu_to_coregroup_id(int cpu)if (!coregroup_enabled) goto out; -if (!firmware_has_feature (FW_FEATURE_VPHN )) - goto out; +if (firmware_has_feature (FW_FEATURE_VPHN )) { +__be32 tmp[VPHN_ASSOC_BUFSIZE ] = {0 }; -if (vphn_get_associativity (cpu, associativity)) +if (vphn_get_associativity (cpu, tmp)) + goto out; + + associativity = tmp; + + }else { + cpunode =of_get_cpu_node (cpu,NULL ); +if (!cpunode) + goto out; + + associativity =of_get_associativity (cpunode); + } +if (!associativity) goto out; index =of_read_number (associativity,1 );if (index > primary_domain_index +1 ) -return of_read_number (&associativity[index -1 ],1 ); + coregroup_id =of_read_number (&associativity[index -1 ],1 ); out: -return cpu_to_core_id (cpu); -} +if (cpunode) +of_node_put (cpunode);return coregroup_id; }
Signature · 1 line
2.43.0
Ritesh Harjani (IBM)
reviewerRe: [PATCH v2 3/3] powerpc/numa: Support coregroup on PowerNV
Quoted 26 lines · Srikar Dronamraju
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_indexis the penultimate domain in the CPU node's ibm,associativity property. On PowerNV, a non-penultimateprimary_domain_indexindicates that firmware provides an additional level for coregroup information.This keeps the logic compatible with PowerVM systems, where
primary_domain_indexis likewise not the penultimate associativity domain.Signed-off-by Srikar Dronamraju <[email protected]>---
Changelog from v1: https://lkml.kernel.org/r/[email protected]
- Handle comments from Christophe Leroy; make code more flatarch/powerpc/mm/numa.c | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)arch/powerpc/mm/numa.c +0
-0
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 896
Quoted 8 lines
arch/powerpc/mm/numa.c +5
-0@@ -889,12 +889,32 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,return 0 ; } +/* +* If hierarchy extends beyond primary_domain_index + 1, then next +* level corresponds to coregroup. +*/ +static int detect_and_enable_coregroup (const __be32 *associativity,int index)
Do we care about it's return value? We are not reading that in the patch.
this function is mainly only needed in __init, can we mark it so.
Quoted 4 lines
arch/powerpc/mm/numa.c +4
-0+{ +if (!associativity || index ==-1 ) + goto out; +
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 910
Quoted 10 lines
arch/powerpc/mm/numa.c +10
-0+ index =of_read_number (associativity,1 ); + +if (index > primary_domain_index +1 ) { + coregroup_enabled =1 ; +return index; + } +out: + coregroup_enabled =0 ; +return -1 ; +}
For PowerVM, we now have two places which will enable coregroup_enabled during mem_topology_setup(). Is there some way we can unify that?
This also means we enable coregroup in case of PowerVM with SPLPAR when per-cpu VPHN associativity index > primary_domain_index+1. But this isn't reflected in your commit msg. The commit msg only says this affects PowerNV.
setup_arch
mem_topology_setup
parse_numa_properties
detect_and_enable_coregroup() {...
// coregroup_enabled = 0/1
index = of_read_number(associativity, 1);
if (index > primary_domain_index + 1) {
coregroup_enabled = 1;
return index;
}
}
<...>
find_possible_nodes() {...
prop_length /= sizeof(int);
if (prop_length > primary_domain_index + 2)
coregroup_enabled = 1;
}Quoted 72 lines
arch/powerpc/mm/numa.c +24
-7+static int __init parse_numa_properties (void ) {struct device_node *memory, *pci; -int default_nid =0 ; -unsigned long i; +int default_nid =0 , index =0 ;const __be32 *associativity; +unsigned long i;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) {__be32 vphn_assoc[VPHN_ASSOC_BUFSIZE ]; -struct device_node *cpu;int nid =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 { +struct device_node *cpu;/* * Don't fall back to default_nid yet -- we will plug @@ -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,int cpu_to_coregroup_id (int cpu) { -__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 }; +int coregroup_id =cpu_to_core_id (cpu); +struct device_node *cpunode =NULL ; +const __be32 *associativity;int index;if (cpu <0 || cpu > nr_cpu_ids)@@ -1454,19 +1478,31 @@ int cpu_to_coregroup_id(int cpu)if (!coregroup_enabled) goto out; -if (!firmware_has_feature (FW_FEATURE_VPHN )) - goto out; +if (firmware_has_feature (FW_FEATURE_VPHN )) { +__be32 tmp[VPHN_ASSOC_BUFSIZE ] = {0 }; -if (vphn_get_associativity (cpu, associativity)) +if (vphn_get_associativity (cpu, tmp)) + goto out; + + associativity = tmp; + + }else { + cpunode =of_get_cpu_node (cpu,NULL ); +if (!cpunode) + goto out; + + associativity =of_get_associativity (cpunode); + } +if (!associativity)
arch/powerpc/mm/numa.c int cpu_to_coregroup_id(int cpu) · line 1469
Quoted 10 lines
arch/powerpc/mm/numa.c +1
-3goto out; index =of_read_number (associativity,1 );if (index > primary_domain_index +1 ) -return of_read_number (&associativity[index -1 ],1 ); + coregroup_id =of_read_number (&associativity[index -1 ],1 ); out: -return cpu_to_core_id (cpu); -}
Looks like leftover removed from previous patch. This change should be fixed in patch-2 itself.
Quoted 7 lines
arch/powerpc/mm/numa.c +2
-0+if (cpunode) +of_node_put (cpunode);return coregroup_id; }Signature · 1 line
2.43.0
-ritesh
Re: [PATCH v2 3/3] powerpc/numa: Support coregroup on PowerNV
Quoted 23 lines · Ritesh Harjani
Quoted 21 lines · Srikar Dronamraju
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_indexis the penultimate domain in the CPU node's ibm,associativity property. On PowerNV, a non-penultimateprimary_domain_indexindicates that firmware provides an additional level for coregroup information.This keeps the logic compatible with PowerVM systems, where
primary_domain_indexis likewise not the penultimate associativity domain.Signed-off-by Srikar Dronamraju <[email protected]>---
Changelog from v1: https://lkml.kernel.org/r/[email protected]
- Handle comments from Christophe Leroy; make code more flatarch/powerpc/mm/numa.c | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)
Quoted 7 lines
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 890
Quoted 7 lines
arch/powerpc/mm/numa.c +0
-0@@ -889,12 +889,32 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,return 0 ; }
Hi Ritesh,
Thanks for the review.
Quoted 9 lines
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 896
Quoted 6 lines
arch/powerpc/mm/numa.c +5
-0+/* +* If hierarchy extends beyond primary_domain_index + 1, then next +* level corresponds to coregroup. +*/ +static int detect_and_enable_coregroup (const __be32 *associativity,int index)Do we care about it's return value? We are not reading that in the patch.
Yes, We do care about the return value. If the index is set to -1, we don't retry enabling the coregroup.
Quoted 1 line
this function is mainly only needed in
__init, can we mark it so.
Yes, this will be done.
Quoted 10 lines
Quoted 10 lines
arch/powerpc/mm/numa.c +9
-0+{ +if (!associativity || index ==-1 ) + goto out; + + index =of_read_number (associativity,1 ); + +if (index > primary_domain_index +1 ) { + coregroup_enabled =1 ; +return index;
Quoted 9 lines
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 910
Quoted 5 lines
arch/powerpc/mm/numa.c +5
-0+ } +out: + coregroup_enabled =0 ; +return -1 ; +}For PowerVM, we now have two places which will enable
coregroup_enabledduringmem_topology_setup(). Is there some way we can unify that?
For PowerVM, we have two extra associativity properties ibm,ibm,current-associativity-domains and ibm,max-associativity-domains. On PowerNV, these two properties are not used/exported.
All we depend is the layout of these properties to determine if coregroup is enabled. If the layout tells us that there is place after primary_domain_index for coregroup, we assume coregroup is enabled.
So in this patch, we hook at the place we look at each of the CPU associativity. This should work for both PowerVM and PowerNV.
So, I can think of two options.
1. Remove the previous logic of depending on PowerVM specific code.
2. Allow the previous logic to be around. Since its not going to hurt functionally or performance wise.
Quoted 4 lines
This also means we enable coregroup in case of PowerVM with SPLPAR when per-cpu VPHN associativity index > primary_domain_index+1. But this isn't reflected in your commit msg. The commit msg only says this affects PowerNV.
I don't think, I said this affects PowerNV only. But I still don't think the logic would change. The logic to enable coregroup remains the same. Just that we may now be depending on the 1st CPU associativity instead of the PowerVM specific properties.
Quoted 100 lines
setup_arch
mem_topology_setupparse_numa_properties detect_and_enable_coregroup() {... // coregroup_enabled = 0/1 index = of_read_number(associativity, 1); if (index > primary_domain_index + 1) { coregroup_enabled = 1; return index; } } <...> find_possible_nodes() {... prop_length /= sizeof(int); if (prop_length > primary_domain_index + 2) coregroup_enabled = 1; }Quoted 79 lines
arch/powerpc/mm/numa.c +25
-8+static int __init parse_numa_properties (void ) {struct device_node *memory, *pci; -int default_nid =0 ; -unsigned long i; +int default_nid =0 , index =0 ;const __be32 *associativity; +unsigned long i;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) {__be32 vphn_assoc[VPHN_ASSOC_BUFSIZE ]; -struct device_node *cpu;int nid =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 { +struct device_node *cpu;/* * Don't fall back to default_nid yet -- we will plug @@ -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,int cpu_to_coregroup_id (int cpu) { -__be32 associativity[VPHN_ASSOC_BUFSIZE ] = {0 }; +int coregroup_id =cpu_to_core_id (cpu); +struct device_node *cpunode =NULL ; +const __be32 *associativity;int index;if (cpu <0 || cpu > nr_cpu_ids)@@ -1454,19 +1478,31 @@ int cpu_to_coregroup_id(int cpu)if (!coregroup_enabled) goto out; -if (!firmware_has_feature (FW_FEATURE_VPHN )) - goto out; +if (firmware_has_feature (FW_FEATURE_VPHN )) { +__be32 tmp[VPHN_ASSOC_BUFSIZE ] = {0 }; -if (vphn_get_associativity (cpu, associativity)) +if (vphn_get_associativity (cpu, tmp)) + goto out; + + associativity = tmp; + + }else { + cpunode =of_get_cpu_node (cpu,NULL ); +if (!cpunode) + goto out; + + associativity =of_get_associativity (cpunode); + } +if (!associativity) goto out; index =of_read_number (associativity,1 );if (index > primary_domain_index +1 ) -return of_read_number (&associativity[index -1 ],1 ); + coregroup_id =of_read_number (&associativity[index -1 ],1 );
Quoted 6 lines
arch/powerpc/mm/numa.c int cpu_to_coregroup_id(int cpu) · line 1469
Quoted 3 lines
arch/powerpc/mm/numa.c +0
-2out: -return cpu_to_core_id (cpu); -}Looks like leftover removed from previous patch. This change should be fixed in patch-2 itself.
True, will do the needful.
Quoted 10 lines
Quoted 8 lines
arch/powerpc/mm/numa.c +2
-0+if (cpunode) +of_node_put (cpunode);return coregroup_id; }Signature · 1 line
2.43.0-ritesh
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Ritesh Harjani (IBM)
reviewerRe: [PATCH v2 3/3] powerpc/numa: Support coregroup on PowerNV
Quoted 47 lines · Srikar Dronamraju
Quoted 23 lines · Ritesh Harjani
Quoted 21 lines · Srikar Dronamraju
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_indexis the penultimate domain in the CPU node's ibm,associativity property. On PowerNV, a non-penultimateprimary_domain_indexindicates that firmware provides an additional level for coregroup information.This keeps the logic compatible with PowerVM systems, where
primary_domain_indexis likewise not the penultimate associativity domain.Signed-off-by Srikar Dronamraju <[email protected]>---
Changelog from v1: https://lkml.kernel.org/r/[email protected]
- Handle comments from Christophe Leroy; make code more flatarch/powerpc/mm/numa.c | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)Quoted 7 lines
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 890
Quoted 7 lines
arch/powerpc/mm/numa.c +0
-0@@ -889,12 +889,32 @@ static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,return 0 ; }Hi Ritesh,
Thanks for the review.
Quoted 9 lines
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 896
Quoted 6 lines
arch/powerpc/mm/numa.c +5
-0+/* +* If hierarchy extends beyond primary_domain_index + 1, then next +* level corresponds to coregroup. +*/ +static int detect_and_enable_coregroup (const __be32 *associativity,int index)Do we care about it's return value? We are not reading that in the patch.
Quoted 3 lines
Yes, We do care about the return value. If the index is set to -1, we don't retry enabling the coregroup.
yes, my bad. Agreed it is being used.
Quoted 45 lines
Quoted 1 line
this function is mainly only needed in
__init, can we mark it so.Yes, this will be done.
Quoted 10 lines
Quoted 10 lines
arch/powerpc/mm/numa.c +9
-0+{ +if (!associativity || index ==-1 ) + goto out; + + index =of_read_number (associativity,1 ); + +if (index > primary_domain_index +1 ) { + coregroup_enabled =1 ; +return index;Quoted 9 lines
arch/powerpc/mm/numa.c static int __init numa_setup_drmem_lmb(struct drmem_lmb *lmb, · line 910
Quoted 5 lines
arch/powerpc/mm/numa.c +5
-0+ } +out: + coregroup_enabled =0 ; +return -1 ; +}For PowerVM, we now have two places which will enable
coregroup_enabledduringmem_topology_setup(). Is there some way we can unify that?For PowerVM, we have two extra associativity properties ibm,ibm,current-associativity-domains and ibm,max-associativity-domains. On PowerNV, these two properties are not used/exported.
All we depend is the layout of these properties to determine if coregroup is enabled. If the layout tells us that there is place after
primary_domain_indexfor coregroup, we assume coregroup is enabled.So in this patch, we hook at the place we look at each of the CPU associativity. This should work for both PowerVM and PowerNV.
So, I can think of two options.
1. Remove the previous logic of depending on PowerVM specific code.
2. Allow the previous logic to be around. Since its not going to hurt functionally or performance wise.Quoted 4 lines
This also means we enable coregroup in case of PowerVM with SPLPAR when per-cpu VPHN associativity index > primary_domain_index+1. But this isn't reflected in your commit msg. The commit msg only says this affects PowerNV.
Quoted 5 lines
I don't think, I said this affects PowerNV only. But I still don't think the logic would change. The logic to enable coregroup remains the same. Just that we may now be depending on the 1st CPU associativity instead of the PowerVM specific properties.
So let's just add this info in the commit msg please. Because it was not clear otherwise.
-ritesh