mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/4] powerpc/topology: Introduce llc_override kernel parameter
@ 2026-11-23 12:47 Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 1/4] " Shrikanth Hegde
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2026-11-23 12:47 UTC (permalink / raw)
  To: maddy, linuxppc-dev, peterz, tim.c.chen
  Cc: sshegde, christophe.leroy, linux-kernel, ritesh.list,
	kprateek.nayak, yu.c.chen, vineethr, vincent.guittot, srikar,
	npiggin, mpe

Depends on generic cacheinfo series[1] to be applied,
[1]: https://lore.kernel.org/all/20261118163639.890546-1-sshegde@linux.ibm.com/
That patch is under discussion and likely need some changes specially
for DLPAR related stuff. Meanwhile, sending this updated series out.

Provide an option for users to enable cache aware scheduling on powerpc
via a command line parameter.

Verified that cache aware scheduling is taking effecting by observing that
llc_balance happens and mm_sched_llc is pointing to the right llc id after
running threads and size checks succeed.

More details of the problem and context is in cover-letter of v1.
v1: https://lore.kernel.org/all/20261012102037.2477378-1-sshegde@linux.ibm.com/
v2: https://lore.kernel.org/all/20261023131646.2907938-1-sshegde@linux.ibm.com/

v2->v3:
- Move to generic cacheinfo so that get_effective_llc_bytes populates
  the right value. Thanks to Chen Yu, Tim Chen for pointing out that
  llc_bytes was 0.
- Make llc_override __ro_after_init and remove READ/WRITE_ONCE
  (Chen Yu, Tim Chen)
- Merge patches around domain flags and arch_llc_mask (Tim Chen)
- Ensure parameter is of nop on shared processor LPAR (New patch)

v1->v2:
- Move to kernel parameters from debugfs. This helps to keep
  llc_id consistent which doesn't change across sched domain
  rebuilds. (Tim Chen)
- Update arch_llc_mask to reflect the override (Tim Chen)
- Limit only to mc, pkg (Srikar Dronamraju)

PS: Selftests related to Cache aware Scheduling will be taken up
subsequently, as that is more complicated.

Shrikanth Hegde (4):
  powerpc/topology: Introduce llc_override kernel parameter
  powerpc/topology: Update flags and llc_mask based on llc_override
  Documentation/powerpc: Add details about llc_override
  powerpc: Skip llc_override on SPLPAR

 .../admin-guide/kernel-parameters.txt         | 15 ++++
 arch/powerpc/include/asm/topology.h           |  8 +-
 arch/powerpc/kernel/smp.c                     | 74 +++++++++++++++++--
 3 files changed, 86 insertions(+), 11 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/4] powerpc/topology: Introduce llc_override kernel parameter
  2026-11-23 12:47 [PATCH v3 0/4] powerpc/topology: Introduce llc_override kernel parameter Shrikanth Hegde
@ 2026-11-23 12:47 ` Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 2/4] powerpc/topology: Update flags and llc_mask based on llc_override Shrikanth Hegde
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2026-11-23 12:47 UTC (permalink / raw)
  To: maddy, linuxppc-dev, peterz, tim.c.chen
  Cc: sshegde, christophe.leroy, linux-kernel, ritesh.list,
	kprateek.nayak, yu.c.chen, vineethr, vincent.guittot, srikar,
	npiggin, mpe

There is a new feature in scheduler called as Cache Aware Scheduling.
It tries to keep related tasks within the same LLC domain while
keeping the system reasonably balanced.

Cache Aware Scheduling assumes that the scheduler LLC domain is large
enough to be a useful placement target. This is true on many systems
where an LLC spans several cores, but not on PowerPC systems where the
scheduler-visible LLC is at the SMT level.
In that case, sd_llc_size is effectively the SMT width.

This becomes visible in the capacity check:

  !fits_capacity((mm->sc_stat.nr_running_avg * cpu_smt_num_threads),
                  scale * per_cpu(sd_llc_size, cpu));

As a result, it may be enabled but has no room to operate.
Hence provide a kernel parameter so that one can try experiment
their workload with cache aware scheduling. This also provides ways to
explore it on system with SMT=4 to see if there are any opportunities
to improve or uncover bugs if there is any.

This does not change the hardware cache topology. It only changes the
sched-domain level at which SD_SHARE_LLC is set.

There is no point in setting NUMA as the LLC domain. So give option
until pkg to experiment with.

Actual flag manipulations for sched domain flags and llc mask is updated
in the subsequent patches.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 arch/powerpc/kernel/smp.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 7a25eaa59e62..446127ace589 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1059,6 +1059,29 @@ static bool has_coregroup_support(void)
 	return coregroup_enabled;
 }
 
+enum llc_override_values {
+	LLC_OVERRIDE_MC		= 1,
+	LLC_OVERRIDE_PKG	= 2,
+};
+
+static int llc_override __ro_after_init;
+
+static int __init set_llc_override(char *str)
+{
+	if (!strcasecmp(str, "mc") && has_coregroup_support())
+		llc_override = LLC_OVERRIDE_MC;
+	else if (!strcasecmp(str, "pkg"))
+		llc_override = LLC_OVERRIDE_PKG;
+	else {
+		pr_warn("Unsupported llc_override=%s\n", str);
+		return 1;
+	}
+
+	pr_info("llc_override set at domain: %s\n", str);
+	return 1;
+}
+__setup("llc_override=", set_llc_override);
+
 static int __init init_big_cores(void)
 {
 	int cpu;
-- 
2.52.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 2/4] powerpc/topology: Update flags and llc_mask based on llc_override
  2026-11-23 12:47 [PATCH v3 0/4] powerpc/topology: Introduce llc_override kernel parameter Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 1/4] " Shrikanth Hegde
@ 2026-11-23 12:47 ` Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 3/4] Documentation/powerpc: Add details about llc_override Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 4/4] powerpc: Skip llc_override on SPLPAR Shrikanth Hegde
  3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2026-11-23 12:47 UTC (permalink / raw)
  To: maddy, linuxppc-dev, peterz, tim.c.chen
  Cc: sshegde, christophe.leroy, linux-kernel, ritesh.list,
	kprateek.nayak, yu.c.chen, vineethr, vincent.guittot, srikar,
	npiggin, mpe

Update the flags passed for building the scheduler topology based on
llc_override.

SD_SHARE_LLC is used to determine the highest domain where the LLC is.
Also when set at a particular domain, all the child domains are expected
to have it set as well.

Also 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 <sshegde@linux.ibm.com>
---
 arch/powerpc/include/asm/topology.h |  8 +---
 arch/powerpc/kernel/smp.c           | 58 +++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 02c3c9ab3ea9..9eb7dbacddf8 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -134,12 +134,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 446127ace589..7b9682e55c56 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1007,6 +1007,13 @@ static int powerpc_smt_flags(void)
  */
 static __ro_after_init DEFINE_STATIC_KEY_FALSE(splpar_asym_pack);
 
+enum llc_override_values {
+	LLC_OVERRIDE_MC		= 1,
+	LLC_OVERRIDE_PKG	= 2,
+};
+
+static int llc_override __ro_after_init;
+
 /*
  * P9 has a slightly odd architecture where pairs of cores share an L2 cache.
  * This topology makes it *much* cheaper to migrate tasks between adjacent cores
@@ -1021,12 +1028,29 @@ static int powerpc_shared_cache_flags(void)
 	return SD_SHARE_LLC;
 }
 
-static int powerpc_shared_proc_flags(void)
+static int powerpc_mc_flags(void)
 {
+	int flags = 0;
 	if (static_branch_unlikely(&splpar_asym_pack))
-		return SD_ASYM_PACKING;
+		flags |= SD_ASYM_PACKING;
 
-	return 0;
+	if (llc_override >= LLC_OVERRIDE_MC)
+		flags |= SD_SHARE_LLC;
+
+	return flags;
+}
+
+static int powerpc_pkg_flags(void)
+{
+	int flags = 0;
+
+	if (static_branch_unlikely(&splpar_asym_pack))
+		flags |= SD_ASYM_PACKING;
+
+	if (llc_override >= LLC_OVERRIDE_PKG)
+		flags |= SD_SHARE_LLC;
+
+	return flags;
 }
 
 /*
@@ -1059,12 +1083,24 @@ static bool has_coregroup_support(void)
 	return coregroup_enabled;
 }
 
-enum llc_override_values {
-	LLC_OVERRIDE_MC		= 1,
-	LLC_OVERRIDE_PKG	= 2,
-};
-
-static int llc_override __ro_after_init;
+/*
+ * 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 set_llc_override(char *str)
 {
@@ -1759,10 +1795,10 @@ static void __init build_sched_topology(void)
 
 	if (has_coregroup_support()) {
 		powerpc_topology[i++] =
-			SDTL_INIT(tl_mc_mask, powerpc_shared_proc_flags, MC);
+			SDTL_INIT(tl_mc_mask, powerpc_mc_flags, MC);
 	}
 
-	powerpc_topology[i++] = SDTL_INIT(tl_pkg_mask, powerpc_shared_proc_flags, PKG);
+	powerpc_topology[i++] = SDTL_INIT(tl_pkg_mask, powerpc_pkg_flags, PKG);
 
 	/* There must be one trailing NULL entry left.  */
 	BUG_ON(i >= ARRAY_SIZE(powerpc_topology) - 1);
-- 
2.52.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 3/4] Documentation/powerpc: Add details about llc_override
  2026-11-23 12:47 [PATCH v3 0/4] powerpc/topology: Introduce llc_override kernel parameter Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 1/4] " Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 2/4] powerpc/topology: Update flags and llc_mask based on llc_override Shrikanth Hegde
@ 2026-11-23 12:47 ` Shrikanth Hegde
  2026-11-23 12:47 ` [PATCH v3 4/4] powerpc: Skip llc_override on SPLPAR Shrikanth Hegde
  3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2026-11-23 12:47 UTC (permalink / raw)
  To: maddy, linuxppc-dev, peterz, tim.c.chen
  Cc: sshegde, christophe.leroy, linux-kernel, ritesh.list,
	kprateek.nayak, yu.c.chen, vineethr, vincent.guittot, srikar,
	npiggin, mpe

Provide documentation for the newly introduced llc_override kernel
parameter.

This may help one if they want to experiment with cache aware
scheduling on powerpc.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0b3c140babd9..6e5e9879f56c 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3583,6 +3583,21 @@ Kernel parameters
 			Enable Live Update Orchestrator (LUO).
 			Default: off.
 
+	llc_override=	[PPC] Override the scheduler-visible LLC domain.
+			Format: { mc | pkg }
+
+			Use the specified topology domain as the LLC domain
+			for scheduler decisions. This is intended for
+			experimenting with Cache Aware Scheduling.
+
+			mc	Use the MC domain as the LLC domain.
+			pkg	Use the package domain as the LLC domain.
+
+			If unset, use the platform-provided LLC topology.
+
+			This is a debug option only. It does not change the
+			hardware cache topology.
+
 	lockd.nlm_grace_period=P  [NFS] Assign grace period.
 			Format: <integer>
 
-- 
2.52.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 4/4] powerpc: Skip llc_override on SPLPAR
  2026-11-23 12:47 [PATCH v3 0/4] powerpc/topology: Introduce llc_override kernel parameter Shrikanth Hegde
                   ` (2 preceding siblings ...)
  2026-11-23 12:47 ` [PATCH v3 3/4] Documentation/powerpc: Add details about llc_override Shrikanth Hegde
@ 2026-11-23 12:47 ` Shrikanth Hegde
  3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2026-11-23 12:47 UTC (permalink / raw)
  To: maddy, linuxppc-dev, peterz, tim.c.chen
  Cc: sshegde, christophe.leroy, linux-kernel, ritesh.list,
	kprateek.nayak, yu.c.chen, vineethr, vincent.guittot, srikar,
	npiggin, mpe

On shared-processor LPARs, firmware exposes only the L1 cache information
to the guest. The physical L2 and L3 size and sharing information needed
to calculate the effective LLC capacity are unavailable.

Using llc_override in this configuration would leave llc_bytes at zero.
Reject the parameter on shared-processor LPARs for now.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 arch/powerpc/kernel/smp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 7b9682e55c56..9b0fc661083a 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1104,6 +1104,11 @@ const struct cpumask *arch_llc_mask(int cpu)
 
 static int __init set_llc_override(char *str)
 {
+	if (is_shared_processor()) {
+		pr_warn("llc_override is not supported on Shared Processor LPARs\n");
+		return 1;
+	}
+
 	if (!strcasecmp(str, "mc") && has_coregroup_support())
 		llc_override = LLC_OVERRIDE_MC;
 	else if (!strcasecmp(str, "pkg"))
-- 
2.52.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-23 12:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 12:47 [PATCH v3 0/4] powerpc/topology: Introduce llc_override kernel parameter Shrikanth Hegde
2026-11-23 12:47 ` [PATCH v3 1/4] " Shrikanth Hegde
2026-11-23 12:47 ` [PATCH v3 2/4] powerpc/topology: Update flags and llc_mask based on llc_override Shrikanth Hegde
2026-11-23 12:47 ` [PATCH v3 3/4] Documentation/powerpc: Add details about llc_override Shrikanth Hegde
2026-11-23 12:47 ` [PATCH v3 4/4] powerpc: Skip llc_override on SPLPAR Shrikanth Hegde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®