Message ID | 20200727053230.19753-11-srikar@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Coregroup support on Powerpc | expand |
Srikar Dronamraju <srikar@linux.vnet.ibm.com> writes: > Lookup the coregroup id from the associativity array. It's slightly strange that this is called in patch 9, but only properly implemented here in patch 10. I'm not saying you have to squash them together, but it would be good if the change log for patch 9 mentioned that a subsequent commit will complete the implementation and how that affects the behaviour. cheers > 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@lists.ozlabs.org> > Cc: LKML <linux-kernel@vger.kernel.org> > Cc: Michael Ellerman <mpe@ellerman.id.au> > Cc: Nicholas Piggin <npiggin@gmail.com> > Cc: Anton Blanchard <anton@ozlabs.org> > Cc: Oliver O'Halloran <oohall@gmail.com> > Cc: Nathan Lynch <nathanl@linux.ibm.com> > Cc: Michael Neuling <mikey@neuling.org> > Cc: Gautham R Shenoy <ego@linux.vnet.ibm.com> > Cc: Ingo Molnar <mingo@kernel.org> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Valentin Schneider <valentin.schneider@arm.com> > Cc: Jordan Niethe <jniethe5@gmail.com> > Reviewed-by : Gautham R. Shenoy <ego@linux.vnet.ibm.com> > Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> > --- > Changelog v1 -> v2: > Move coregroup_enabled before getting associativity (Gautham) > > arch/powerpc/mm/numa.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c > index 0d57779e7942..8b3b3ec7fcc4 100644 > --- a/arch/powerpc/mm/numa.c > +++ b/arch/powerpc/mm/numa.c > @@ -1218,6 +1218,26 @@ int find_and_online_cpu_nid(int cpu) > > 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 (!coregroup_enabled) > + goto out; > + > + 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) > + return of_read_number(&associativity[index - 1], 1); > + > +out: > return cpu_to_core_id(cpu); > } > > -- > 2.17.1
* Michael Ellerman <mpe@ellerman.id.au> [2020-07-31 18:02:21]: > Srikar Dronamraju <srikar@linux.vnet.ibm.com> writes: > > Lookup the coregroup id from the associativity array. > Thanks Michael for all your comments and inputs. > It's slightly strange that this is called in patch 9, but only properly > implemented here in patch 10. > > I'm not saying you have to squash them together, but it would be good if > the change log for patch 9 mentioned that a subsequent commit will > complete the implementation and how that affects the behaviour. > I probably got influenced by few LKML community members who always add a stub and implement the gory details in a subsequent patch. I will surely add the change log in patch 9 about the subsequent patches. > cheers >
Srikar Dronamraju <srikar@linux.vnet.ibm.com> writes: > * Michael Ellerman <mpe@ellerman.id.au> [2020-07-31 18:02:21]: > >> Srikar Dronamraju <srikar@linux.vnet.ibm.com> writes: >> > Lookup the coregroup id from the associativity array. > > Thanks Michael for all your comments and inputs. > >> It's slightly strange that this is called in patch 9, but only properly >> implemented here in patch 10. >> >> I'm not saying you have to squash them together, but it would be good if >> the change log for patch 9 mentioned that a subsequent commit will >> complete the implementation and how that affects the behaviour. > > I probably got influenced by few LKML community members who always add a > stub and implement the gory details in a subsequent patch. I will surely add > the change log in patch 9 about the subsequent patches. That's OK, it's a valid way to do things, and can be good for keeping the size of individual patches down to make them easier to review. But yeah a mention in the change log of the preceeding patch is helpful for anyone looking at that commit on its own in the future. cheers
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 0d57779e7942..8b3b3ec7fcc4 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -1218,6 +1218,26 @@ int find_and_online_cpu_nid(int cpu) 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 (!coregroup_enabled) + goto out; + + 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) + return of_read_number(&associativity[index - 1], 1); + +out: return cpu_to_core_id(cpu); }
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@lists.ozlabs.org> Cc: LKML <linux-kernel@vger.kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Anton Blanchard <anton@ozlabs.org> Cc: Oliver O'Halloran <oohall@gmail.com> Cc: Nathan Lynch <nathanl@linux.ibm.com> Cc: Michael Neuling <mikey@neuling.org> Cc: Gautham R Shenoy <ego@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Jordan Niethe <jniethe5@gmail.com> Reviewed-by : Gautham R. Shenoy <ego@linux.vnet.ibm.com> Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> --- Changelog v1 -> v2: Move coregroup_enabled before getting associativity (Gautham) arch/powerpc/mm/numa.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)