Update the arch_llc_mask passed for building the cache aware scheduling
data structures such as llc_id etc.

Since llc_override is kernel parameter, this helps to keep the
arch_llc_mask stable after boot which in turn keeps llc_id consistent,
since llc_id are not updated even on rebuilding the sched domains.

Signed-off-by: Shrikanth Hegde <[email protected]>
---
 arch/powerpc/include/asm/topology.h |  8 ++------
 arch/powerpc/kernel/smp.c           | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/topology.h 
b/arch/powerpc/include/asm/topology.h
index 44ec416fa489..e1ca91d9b2c2 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -135,12 +135,8 @@ struct cpumask *cpu_coregroup_mask(int cpu);
 const struct cpumask *cpu_die_mask(int cpu);
 int cpu_die_id(int cpu);
 
-/*
- * Points to where the LLC is. On power9 this will point at CACHE
- * domain, On others it will point to SMT domain. In all cases
- * cpu_l2_cache_mask points to where LLC is
- */
-#define arch_llc_mask(cpu)     cpu_l2_cache_mask(cpu)
+const struct cpumask *arch_llc_mask(int cpu);
+#define arch_llc_mask arch_llc_mask
 
 #ifdef CONFIG_PPC64
 #include <asm/smp.h>
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index ca1821dedc98..4ece21abb1c4 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1099,6 +1099,25 @@ static int __init set_llc_override(char *str)
 }
 __setup("llc_override=", set_llc_override);
 
+/*
+ * Points to where the LLC is. On power9 this will point at CACHE
+ * domain, On others it will point to SMT domain. In all cases
+ * cpu_l2_cache_mask points to where LLC is.
+ *
+ * If there is llc_override set, return the appropriate mask
+ */
+const struct cpumask *arch_llc_mask(int cpu)
+{
+       switch (READ_ONCE(llc_override)) {
+       case LLC_OVERRIDE_MC:
+               return cpu_coregroup_mask(cpu);
+       case LLC_OVERRIDE_PKG:
+               return cpu_node_mask(cpu);
+       default:
+               return cpu_l2_cache_mask(cpu);
+       }
+}
+
 static int __init init_big_cores(void)
 {
        int cpu;
-- 
2.52.0


Reply via email to