[PATCH 10/11] powerpc/smp: Implement cpu_to_coregroup_id
Srikar Dronamraju
srikar at linux.vnet.ibm.com
Tue Jul 14 14:36:23 AEST 2020
Lookup the coregroup id from the associativity array.
If unable to detect the coregroup id, fallback on the core id.
This way, ensure sched_domain degenerates and an extra sched domain is
not created.
Ideally this function should have been implemented in
arch/powerpc/kernel/smp.c. However if its implemented in mm/numa.c, we
don't need to find the primary domain again.
If the device-tree mentions more than one coregroup, then kernel
implements only the last or the smallest coregroup, which currently
corresponds to the penultimate domain in the device-tree.
Cc: linuxppc-dev <linuxppc-dev at lists.ozlabs.org>
Cc: Michael Ellerman <michaele at au1.ibm.com>
Cc: Nick Piggin <npiggin at au1.ibm.com>
Cc: Oliver OHalloran <oliveroh at au1.ibm.com>
Cc: Nathan Lynch <nathanl at linux.ibm.com>
Cc: Michael Neuling <mikey at linux.ibm.com>
Cc: Anton Blanchard <anton at au1.ibm.com>
Cc: Gautham R Shenoy <ego at linux.vnet.ibm.com>
Cc: Vaidyanathan Srinivasan <svaidy at linux.ibm.com>
Signed-off-by: Srikar Dronamraju <srikar at linux.vnet.ibm.com>
---
arch/powerpc/mm/numa.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index d9ab9da85eab..4e85564ef62a 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1697,6 +1697,23 @@ static const struct proc_ops topology_proc_ops = {
int cpu_to_coregroup_id(int cpu)
{
+ __be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
+ int index;
+
+ if (cpu < 0 || cpu > nr_cpu_ids)
+ return -1;
+
+ if (!firmware_has_feature(FW_FEATURE_VPHN))
+ goto out;
+
+ if (vphn_get_associativity(cpu, associativity))
+ goto out;
+
+ index = of_read_number(associativity, 1);
+ if ((index > min_common_depth + 1) && coregroup_enabled)
+ return of_read_number(&associativity[index - 1], 1);
+
+out:
return cpu_to_core_id(cpu);
}
--
2.17.1
More information about the Linuxppc-dev
mailing list