Skip to contentSkip to conversation

sched: Enable preferred SMT siblings on NVIDIA Olympus

PATCH Superseded Andrea Righi 6 participants 13 messages Sep 17 – Sep 29

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover sched: Enable preferred SMT siblings on NVIDIA Olympus

NVIDIA Olympus implements SMT with two symmetric processing elements (PEs). When only one PE is active, the core operates in single-thread mode and that PE can use the full core resources. When both PEs are active, the core operates in two-thread mode and the PEs share those resources. This behavior is common to SMT implementations, but Olympus is particularly sensitive to brief sibling activations because returning from two-thread mode to single-thread mode after a sibling becomes idle is not immediate. As described by commit 293f9611ae735 ("sched/fair: Prefer fully idle cores for NOHZ balancing"):

Briefly activating an otherwise idle sibling can reduce the performance available to the other sibling and this effect does not necessarily end once the activated sibling becomes idle: after the ILB finishes and its CPU enters WFI, full single-thread performance is restored only after the sibling has remained idle for a qualification interval (10 Ki cycles on the tested Vera system).

That change prevents the NOHZ idle load balancer from unnecessarily waking a sibling of a busy PE. However, ordinary task placement can still select either sibling of an idle core. Repeatedly changing the active PE can therefore keep Olympus cores in two-thread mode despite little or no useful overlap between the siblings.

The first patch teaches the fair scheduler's idle-selection paths to honor SD_ASYM_PACKING at the shared-capacity SMT level. The scheduler first selects a candidate CPU and core according to its existing placement and capacity rules, then chooses the highest-priority available sibling within that core. This also completes the existing POWER7 SD_ASYM_PACKING behavior by applying its hardware-thread ordering during idle selection.

Olympus firmware does not currently provide an interface to describe the preferred SMT sibling. Adding such a firmware or ACPI interface will take time and will not help systems with existing firmware. At the same time, inferring this policy from MIDR would encode a platform-specific decision in the kernel and make it harder to replace with a proper firmware ABI.

The second patch therefore adds the sched_smt_asym_packing= boot option. Using sched_smt_asym_packing=on explicitly opts the SMT scheduling domain into SD_ASYM_PACKING without requiring architecture-specific detection. Priority remains defined by arch_asym_cpu_priority(). The weak default orders siblings by -cpu, consistently selecting the lowest-numbered available logical CPU. Architecture overrides remain authoritative, so siblings assigned equal priorities remain unordered. The default auto mode preserves architecture-provided topology policy, including the existing powerpc behavior, while off provides an explicit override to disable SMT asymmetric packing.

On Olympus, PE0 and PE1 have equal steady-state capacity; this preference does not identify a faster PE. The lower-numbered logical CPU is used only as a canonical choice when both siblings are available. Consistently selecting the same sibling avoids alternating the active PE across wakeups, lets the other sibling remain idle for longer, and allows more cores to remain in, or return to, full-resource single-thread mode.

The v6 series was tested on a two-node Vera system using 88-thread single-precision GEMM workloads on the 88 physical cores of NUMA node 0, with sched_smt_asym_packing=on and the workloads allowed to choose either sibling of every core. Each result covers five runs.

Two BLAS implementations were tested: OpenBLAS, an open-source BLAS library that provides a publicly reproducible benchmark, and NVIDIA Performance Libraries (NVPL), NVIDIA's optimized BLAS implementation.

OpenBLAS was evaluated using benchmark/sgemm.goto with an M=N=K=16384 single-precision GEMM. NVPL was evaluated using benchblas with the same matrix dimensions, non-transposed inputs, alpha=1 and beta=0. The numbers below are the mean and standard deviation from five runs.

OpenBLAS throughput increased from 7.11876 +/- 0.06734 TFLOP/s on the baseline kernel to 7.34669 +/- 0.01936 TFLOP/s with this series (+3.20%). NVPL throughput increased from 9.64742 +/- 0.17311 TFLOP/s to 10.29695 +/- 0.01786 TFLOP/s (+6.73%).

The lower standard deviation also shows that the results became more predictable. With the series applied, the workloads consistently settled on the lower-numbered sibling, allowing the other sibling to remain idle.

Changes in v6:
- Drop the arm64 MIDR-based enablement and arch_asym_cpu_priority() override (Will Deacon)
- Add the generic sched_smt_asym_packing={auto,on,off} boot option
- Use the default -cpu priority ordering instead of interpreting MPIDR
- Drop the SMT-specific asymmetric-packing static key and use sched_smt_active() (Vincent Guittot)
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Remove the redundant olympus_prefer_pe0 state (K Prateek Nayak)
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Honor the SMT sibling priority in the slow path (Srikar Dronamraju)
- Rename the consolidated helper to select_idle_smt_cpu()
(Srikar Dronamraju)
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Consolidate the SMT-priority adjustment in select_idle_sibling() after an idle candidate has been selected (K Prateek Nayak)
- Fold the asym SMT checks into select_idle_smt_priority() and scan the scheduling-domain span directly (K Prateek Nayak)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Clarify that the generic scheduler change also covers POWER7 (Dietmar Eggemann)
- Simplify sched_smt_asym_prefer() by inspecting the lowest scheduling domain directly (Dietmar Eggemann)
- Link to v1: https://lore.kernel.org/r/[email protected]

Andrea Righi (2):
sched/fair: Honor asymmetric SMT priority in idle selection sched/topology: Add asymmetric SMT packing override

 Documentation/admin-guide/kernel-parameters.txt | 11 ++++
 kernel/sched/fair.c                             | 85 ++++++++++++++++++++-----
 kernel/sched/topology.c                         | 49 ++++++++++++++
 3 files changed, 128 insertions(+), 17 deletions(-)
#1 lore raw

PATCH v6 1/2 sched/fair: Honor asymmetric SMT priority in idle selection

POWER7 uses SD_ASYM_PACKING at the shared-capacity SMT level to order hardware threads, and NVIDIA Olympus benefits from the same policy. Idle CPU selection does not consult that order, so a task can wake on an arbitrary sibling and remain there until load balancing corrects the placement. On these systems, that initial choice can prevent the core from entering its preferred lower-thread resource mode and cause a large and persistent performance loss.

When idle selection finds an available CPU in an SMT core, choose the highest-priority available sibling. On SMT2 Olympus this only changes selection on fully idle cores. A partially idle core has only one available CPU. On wider SMT systems such as POWER7, it also fills available siblings in priority order while the core is partially busy.

Apply the preference to idle-core and idle-CPU scans, asymmetric-capacity scans, target, previous, recently-used CPU fast paths and the slow path. Inspect the lowest scheduling domain directly, but require both CPUs to share its span because isolcpus can split hardware siblings across scheduling domains.

Keep physical-core capacity selection independent from SMT sibling ordering. SD_ASYM_CPUCAPACITY first selects among cores with different maximum capacities, then SD_ASYM_PACKING selects the preferred available sibling inside the chosen core, whose siblings continue to share equal capacity.

---
 kernel/sched/fair.c | 85 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 68 insertions(+), 17 deletions(-)
kernel/sched/fair.c +68 -17
index 4d0b94465d19e..8e6dc3a657cca 100644
@@ -8598,6 +8598,35 @@ static inline bool test_idle_cores(int cpu)
 	return false;
 }
 
+/*
+ * Redirect a CPU to a higher-priority available sibling in its SMT domain,
+ * subject to task affinity.
+ */
+static inline int select_idle_smt_cpu(struct task_struct *p, int cpu)
+{
+	struct sched_domain *sd;
+	int best = cpu;
+	int sibling;
+
+	if (!sched_smt_active())
+		return cpu;
+
+	sd = rcu_dereference_all(cpu_rq(cpu)->sd);
+	if (!sd || !(sd->flags & SD_SHARE_CPUCAPACITY) ||
+	    !(sd->flags & SD_ASYM_PACKING))
+		return cpu;
+
+	for_each_cpu_and(sibling, sched_domain_span(sd), p->cpus_ptr) {
+		if (sibling == best || !choose_idle_cpu(sibling, p))
+			continue;
+
+		if (sched_asym_prefer(sibling, best))
+			best = sibling;
+	}
+
+	return best;
+}
+
 /*
  * Scans the local SMT mask to see if the entire core is idle, and records this
  * information in sd_balance_shared->has_idle_cores.
@@ -8982,7 +9011,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 
 	if (choose_idle_cpu(target, p) &&
 	    asym_fits_cpu(task_util, util_min, util_max, target))
-		return target;
+		goto select_smt_priority;
 
 	/*
 	 * If the previous CPU is cache affine and idle, don't be stupid:
@@ -8992,8 +9021,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	    asym_fits_cpu(task_util, util_min, util_max, prev)) {
 
 		if (!static_branch_unlikely(&sched_cluster_active) ||
-		    cpus_share_resources(prev, target))
-			return prev;
+		    cpus_share_resources(prev, target)) {
+			target = prev;
+			goto select_smt_priority;
+		}
 
 		prev_aff = prev;
 	}
@@ -9011,7 +9042,8 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	    prev == smp_processor_id() &&
 	    this_rq()->nr_running <= 1 &&
 	    asym_fits_cpu(task_util, util_min, util_max, prev)) {
-		return prev;
+		target = prev;
+		goto select_smt_priority;
 	}
 
 	/* Check a recently used CPU as a potential idle candidate: */
@@ -9025,8 +9057,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	    asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) {
 
 		if (!static_branch_unlikely(&sched_cluster_active) ||
-		    cpus_share_resources(recent_used_cpu, target))
-			return recent_used_cpu;
+		    cpus_share_resources(recent_used_cpu, target)) {
+			target = recent_used_cpu;
+			goto select_smt_priority;
+		}
 
 	} else {
 		recent_used_cpu = -1;
@@ -9048,7 +9082,11 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 		 */
 		if (sd) {
 			i = select_idle_capacity(p, sd, target);
-			return ((unsigned)i < nr_cpumask_bits) ? i : target;
+			if ((unsigned int)i < nr_cpumask_bits) {
+				target = i;
+				goto select_smt_priority;
+			}
+			return target;
 		}
 	}
 
@@ -9061,14 +9099,18 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 
 		if (!has_idle_core && cpus_share_cache(prev, target)) {
 			i = select_idle_smt(p, sd, prev);
-			if ((unsigned int)i < nr_cpumask_bits)
-				return i;
+			if ((unsigned int)i < nr_cpumask_bits) {
+				target = i;
+				goto select_smt_priority;
+			}
 		}
 	}
 
 	i = select_idle_cpu(p, sd, has_idle_core, target);
-	if ((unsigned)i < nr_cpumask_bits)
-		return i;
+	if ((unsigned int)i < nr_cpumask_bits) {
+		target = i;
+		goto select_smt_priority;
+	}
 
 	/*
 	 * For cluster machines which have lower sharing cache like L2 or
@@ -9076,12 +9118,19 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	 * first. But prev_cpu or recent_used_cpu may also be a good candidate,
 	 * use them if possible when no idle CPU found in select_idle_cpu().
 	 */
-	if ((unsigned int)prev_aff < nr_cpumask_bits)
-		return prev_aff;
-	if ((unsigned int)recent_used_cpu < nr_cpumask_bits)
-		return recent_used_cpu;
+	if ((unsigned int)prev_aff < nr_cpumask_bits) {
+		target = prev_aff;
+		goto select_smt_priority;
+	}
+	if ((unsigned int)recent_used_cpu < nr_cpumask_bits) {
+		target = recent_used_cpu;
+		goto select_smt_priority;
+	}
 
 	return target;
+
+select_smt_priority:
+	return select_idle_smt_cpu(p, target);
 }
 
 /**
@@ -9758,8 +9807,10 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
 	}
 
 	/* Slow path */
-	if (unlikely(sd))
-		return sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
+	if (unlikely(sd)) {
+		new_cpu = sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
+		return select_idle_smt_cpu(p, new_cpu);
+	}
 
 	/* Fast path */
 	if (wake_flags & WF_TTWU)
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH 1/2] sched/fair: Honor asymmetric SMT priority in idle selection

Hi Andrea,

Hope I ain't got anything wrong, I'm a bit sick.

Quoted 58 lines

POWER7 uses SD_ASYM_PACKING at the shared-capacity SMT level to order hardware threads, and NVIDIA Olympus benefits from the same policy. Idle CPU selection does not consult that order, so a task can wake on an arbitrary sibling and remain there until load balancing corrects the placement. On these systems, that initial choice can prevent the core from entering its preferred lower-thread resource mode and cause a large and persistent performance loss.

When idle selection finds an available CPU in an SMT core, choose the highest-priority available sibling. On SMT2 Olympus this only changes selection on fully idle cores. A partially idle core has only one available CPU. On wider SMT systems such as POWER7, it also fills available siblings in priority order while the core is partially busy.

Apply the preference to idle-core and idle-CPU scans, asymmetric-capacity scans, target, previous, recently-used CPU fast paths and the slow path. Inspect the lowest scheduling domain directly, but require both CPUs to share its span because isolcpus can split hardware siblings across scheduling domains.

Keep physical-core capacity selection independent from SMT sibling ordering. SD_ASYM_CPUCAPACITY first selects among cores with different maximum capacities, then SD_ASYM_PACKING selects the preferred available sibling inside the chosen core, whose siblings continue to share equal capacity.

kernel/sched/fair.c +28 -0
+/*
+ * Redirect a CPU to a higher-priority available sibling in its SMT domain,
+ * subject to task affinity.
+ */
+static inline int select_idle_smt_cpu(struct task_struct *p, int cpu)
+{
+	struct sched_domain *sd;
+	int best = cpu;
+	int sibling;
+
+	if (!sched_smt_active())
+		return cpu;
+
+	sd = rcu_dereference_all(cpu_rq(cpu)->sd);
+	if (!sd || !(sd->flags & SD_SHARE_CPUCAPACITY) ||
+	    !(sd->flags & SD_ASYM_PACKING))
+		return cpu;
+
+	for_each_cpu_and(sibling, sched_domain_span(sd), p->cpus_ptr) {
+		if (sibling == best || !choose_idle_cpu(sibling, p))
+			continue;
+
+		if (sched_asym_prefer(sibling, best))
+			best = sibling;
+	}
+
+	return best;
+}
@@ -9061,14 +9099,18 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 

kernel/sched/fair.c static int select_idle_sibling(struct task_struct *p, int prev, int target) · line 9107

Quoted 10 lines
kernel/sched/fair.c +4 -2
 		if (!has_idle_core && cpus_share_cache(prev, target)) {
 			i = select_idle_smt(p, sd, prev);
-			if ((unsigned int)i < nr_cpumask_bits)
-				return i;
+			if ((unsigned int)i < nr_cpumask_bits) {
+				target = i;
+				goto select_smt_priority;
+			}
 		}
 	}

The sched_smt_active() check on select_idle_smt_cpu seems to be redundant on here.

We could remove this
By moving the check on select_idle_smt_cpu() to goto block and
adding one check before the select_idle_smt_cpu() on select_task_rq_fair(). And just calling select_idle_smt_cpu() on here.

I also have a question, do we need select_idle_smt() call on here? If yes then why? I was really confused while reading.

Thanks,
Kayra :_:

Tested-by Reviewed-by
#3 lore raw

Re: [PATCH 1/2] sched/fair: Honor asymmetric SMT priority in idle selection

Quoted 13 lines

Hi Andrea,

Hope I ain't got anything wrong, I'm a bit sick.

The sched_smt_active() check on select_idle_smt_cpu seems to be redundant on here.

We could remove this
By moving the check on select_idle_smt_cpu() to goto block and
adding one check before the select_idle_smt_cpu() on select_task_rq_fair(). And just calling select_idle_smt_cpu() on here.

Quoted 4 lines

I also have a question, do we need select_idle_smt() call on here? If yes then why? I was really confused while reading.

Thanks,
Kayra :_:

After I don't know how much times of reading the same functions, I finally understand. Because of has_idle_core is false, we search if there are any idle SMP's on any of the cores.

I normally was going to send this alot earlier, but I fall asleep after realizing this.

Also now, I don't think we need to remove the checks for one place. It complicates things, when I tried.

I also booted the patch, it did not worked on me since I just have a regular SMT2. So, that was the waited behavior.

So, here's this:

Annnddddddddddddddddddddddddddddddd....

This:

Thanks,
Kayra :-)

maintainer Reviewed-by on v6 1/2
#4 lore raw

Re: [PATCH 1/2] sched/fair: Honor asymmetric SMT priority in idle selection

In reply to Andrea Righi
Quoted 27 lines · Andrea Righi

POWER7 uses SD_ASYM_PACKING at the shared-capacity SMT level to order hardware threads, and NVIDIA Olympus benefits from the same policy. Idle CPU selection does not consult that order, so a task can wake on an arbitrary sibling and remain there until load balancing corrects the placement. On these systems, that initial choice can prevent the core from entering its preferred lower-thread resource mode and cause a large and persistent performance loss.

When idle selection finds an available CPU in an SMT core, choose the highest-priority available sibling. On SMT2 Olympus this only changes selection on fully idle cores. A partially idle core has only one available CPU. On wider SMT systems such as POWER7, it also fills available siblings in priority order while the core is partially busy.

Apply the preference to idle-core and idle-CPU scans, asymmetric-capacity scans, target, previous, recently-used CPU fast paths and the slow path. Inspect the lowest scheduling domain directly, but require both CPUs to share its span because isolcpus can split hardware siblings across scheduling domains.

Keep physical-core capacity selection independent from SMT sibling ordering. SD_ASYM_CPUCAPACITY first selects among cores with different maximum capacities, then SD_ASYM_PACKING selects the preferred available sibling inside the chosen core, whose siblings continue to share equal capacity.

Quoted 4 lines
Quoted 165 lines
---
 kernel/sched/fair.c | 85 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 68 insertions(+), 17 deletions(-)
kernel/sched/fair.c +68 -18
index 4d0b94465d19e..8e6dc3a657cca 100644
@@ -8598,6 +8598,35 @@ static inline bool test_idle_cores(int cpu)
        return false;
 }
 
+/*
+ * Redirect a CPU to a higher-priority available sibling in its SMT domain,
+ * subject to task affinity.
+ */
+static inline int select_idle_smt_cpu(struct task_struct *p, int cpu)
+{
+       struct sched_domain *sd;
+       int best = cpu;
+       int sibling;
+
+       if (!sched_smt_active())
+               return cpu;
+
+       sd = rcu_dereference_all(cpu_rq(cpu)->sd);
+       if (!sd || !(sd->flags & SD_SHARE_CPUCAPACITY) ||
+           !(sd->flags & SD_ASYM_PACKING))
+               return cpu;
+
+       for_each_cpu_and(sibling, sched_domain_span(sd), p->cpus_ptr) {
+               if (sibling == best || !choose_idle_cpu(sibling, p))
+                       continue;
+
+               if (sched_asym_prefer(sibling, best))
+                       best = sibling;
+       }
+
+       return best;
+}
+
 /*
  * Scans the local SMT mask to see if the entire core is idle, and records this
  * information in sd_balance_shared->has_idle_cores.
@@ -8982,7 +9011,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 
        if (choose_idle_cpu(target, p) &&
            asym_fits_cpu(task_util, util_min, util_max, target))
-               return target;
+               goto select_smt_priority;
 
        /*
         * If the previous CPU is cache affine and idle, don't be stupid:
@@ -8992,8 +9021,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
            asym_fits_cpu(task_util, util_min, util_max, prev)) {
 
                if (!static_branch_unlikely(&sched_cluster_active) ||
-                   cpus_share_resources(prev, target))
-                       return prev;
+                   cpus_share_resources(prev, target)) {
+                       target = prev;
+                       goto select_smt_priority;
+               }
 
                prev_aff = prev;
        }
@@ -9011,7 +9042,8 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
            prev == smp_processor_id() &&
            this_rq()->nr_running <= 1 &&
            asym_fits_cpu(task_util, util_min, util_max, prev)) {
-               return prev;
+               target = prev;
+               goto select_smt_priority;
        }
 
        /* Check a recently used CPU as a potential idle candidate: */
@@ -9025,8 +9057,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
            asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) {
 
                if (!static_branch_unlikely(&sched_cluster_active) ||
-                   cpus_share_resources(recent_used_cpu, target))
-                       return recent_used_cpu;
+                   cpus_share_resources(recent_used_cpu, target)) {
+                       target = recent_used_cpu;
+                       goto select_smt_priority;
+               }
 
        } else {
                recent_used_cpu = -1;
@@ -9048,7 +9082,11 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
                 */
                if (sd) {
                        i = select_idle_capacity(p, sd, target);
-                       return ((unsigned)i < nr_cpumask_bits) ? i : target;
+                       if ((unsigned int)i < nr_cpumask_bits) {
+                               target = i;
+                               goto select_smt_priority;
+                       }
+                       return target;
                }
        }
 
@@ -9061,14 +9099,18 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 
                if (!has_idle_core && cpus_share_cache(prev, target)) {
                        i = select_idle_smt(p, sd, prev);
-                       if ((unsigned int)i < nr_cpumask_bits)
-                               return i;
+                       if ((unsigned int)i < nr_cpumask_bits) {
+                               target = i;
+                               goto select_smt_priority;
+                       }
                }
        }
 
        i = select_idle_cpu(p, sd, has_idle_core, target);
-       if ((unsigned)i < nr_cpumask_bits)
-               return i;
+       if ((unsigned int)i < nr_cpumask_bits) {
+               target = i;
+               goto select_smt_priority;
+       }
 
        /*
         * For cluster machines which have lower sharing cache like L2 or
@@ -9076,12 +9118,19 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
         * first. But prev_cpu or recent_used_cpu may also be a good candidate,
         * use them if possible when no idle CPU found in select_idle_cpu().
         */
-       if ((unsigned int)prev_aff < nr_cpumask_bits)
-               return prev_aff;
-       if ((unsigned int)recent_used_cpu < nr_cpumask_bits)
-               return recent_used_cpu;
+       if ((unsigned int)prev_aff < nr_cpumask_bits) {
+               target = prev_aff;
+               goto select_smt_priority;
+       }
+       if ((unsigned int)recent_used_cpu < nr_cpumask_bits) {
+               target = recent_used_cpu;
+               goto select_smt_priority;
+       }
 
        return target;
+
+select_smt_priority:
+       return select_idle_smt_cpu(p, target);
 }
 
 /**
@@ -9758,8 +9807,10 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
        }
 
        /* Slow path */
-       if (unlikely(sd))
-               return sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
+       if (unlikely(sd)) {
+               new_cpu = sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
+               return select_idle_smt_cpu(p, new_cpu);
+       }
 
        /* Fast path */
        if (wake_flags & WF_TTWU)
--

2.55.0

Tested-by on v6 1/2
#5 lore raw

Re: [PATCH 1/2] sched/fair: Honor asymmetric SMT priority in idle selection

In reply to Andrea Righi
Quoted 26 lines · Andrea Righi

POWER7 uses SD_ASYM_PACKING at the shared-capacity SMT level to order hardware threads, and NVIDIA Olympus benefits from the same policy. Idle CPU selection does not consult that order, so a task can wake on an arbitrary sibling and remain there until load balancing corrects the placement. On these systems, that initial choice can prevent the core from entering its preferred lower-thread resource mode and cause a large and persistent performance loss.

When idle selection finds an available CPU in an SMT core, choose the highest-priority available sibling. On SMT2 Olympus this only changes selection on fully idle cores. A partially idle core has only one available CPU. On wider SMT systems such as POWER7, it also fills available siblings in priority order while the core is partially busy.

Apply the preference to idle-core and idle-CPU scans, asymmetric-capacity scans, target, previous, recently-used CPU fast paths and the slow path. Inspect the lowest scheduling domain directly, but require both CPUs to share its span because isolcpus can split hardware siblings across scheduling domains.

Keep physical-core capacity selection independent from SMT sibling ordering. SD_ASYM_CPUCAPACITY first selects among cores with different maximum capacities, then SD_ASYM_PACKING selects the preferred available sibling inside the chosen core, whose siblings continue to share equal capacity.

Quoted 4 lines

I tested v6 on top of linux-next 20260918 with a KASAN + PROVE_LOCKING arm64 kernel and etst on my own 2-socket NVIDIA Olympus system (88 cores per socket, SMT2, 352 CPUs, 36 NUMA nodes).

With sched_smt_asym_packing=on, SD_ASYM_PACKING appears on the SMT domain only; MC and NUMA are untouched, and the override is reapplied on every domain rebuild (~400 hotplug operations, including offlining and re-onlining all 176 second siblings). A task woken on the higher-numbered sibling is redirected to the lower-numbered one on 800/800 wakeups, against 13/800 without the series. auto, off and an invalid value behave as documented. No WARN/BUG/KASAN/lockdep under stress-ng and perf bench sched.

I did not measure throughput.

#6 lore raw

PATCH v6 2/2 sched/topology: Add asymmetric SMT packing override

In reply to Andrea Righi

Architectures can use SD_ASYM_PACKING to describe preferred CPU ordering at the SMT scheduling domain. Some systems benefit from the same policy, but their firmware cannot currently describe the preference. Inferring it from the CPU model would embed a platform-specific policy in the kernel.

Add the sched_smt_asym_packing boot option to override SD_ASYM_PACKING at the SMT level. Accept auto, on and off. Auto preserves the architecture-provided topology and is also the default when the option is absent. On and off force the flag without changing asymmetric packing at higher topology levels.

Apply the override centrally to domains with SD_SHARE_CPUCAPACITY so it also covers architectures with custom SMT topology callbacks, including powerpc. When forced on, priority remains defined by arch_asym_cpu_priority(). The weak default prefers lower-numbered logical CPUs, while architecture overrides remain authoritative. Siblings with equal priorities remain unordered.

---
 .../admin-guide/kernel-parameters.txt         | 11 +++++
 kernel/sched/topology.c                       | 49 +++++++++++++++++++
 2 files changed, 60 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +11 -0
index 33cd30996e47e..36c3b2e563441 100644
@@ -6799,6 +6799,17 @@ Kernel parameters
 			solution to mutex-based priority inversion.
 			Format: <bool>
 
+	sched_smt_asym_packing= [KNL,SMP]
+			Override asymmetric packing at the SMT scheduling domain.
+			Format: { auto | on | off }
+			auto: Preserve the architecture default. This is the
+			default when the option is omitted.
+			on: Force asymmetric packing at the SMT scheduling domain.
+			Idle CPU selection prefers siblings with a higher
+			architecture-defined priority. Siblings with equal
+			priorities remain unordered.
+			off: Ignore SMT sibling priorities.
+
 	sched_verbose	[KNL,EARLY] Enables verbose scheduler debug messages.
 
 	schedstats=	[KNL,X86] Enable or disable scheduled statistics.
kernel/sched/topology.c +49 -0

61 lines not on this page · raw message

Signature · 1 line
2.55.0
#7 lore raw

Re: [PATCH 2/2] sched/topology: Add asymmetric SMT packing override

Hi Andrea,

Quoted 12 lines · Andrea Righi

Architectures can use SD_ASYM_PACKING to describe preferred CPU ordering at the SMT scheduling domain. Some systems benefit from the same policy, but their firmware cannot currently describe the preference. Inferring it from the CPU model would embed a platform-specific policy in the kernel.

Add the sched_smt_asym_packing boot option to override SD_ASYM_PACKING at the SMT level. Accept auto, on and off. Auto preserves the architecture-provided topology and is also the default when the option is absent. On and off force the flag without changing asymmetric packing at higher topology levels.

Quoted 7 lines

Apply the override centrally to domains with SD_SHARE_CPUCAPACITY so it also covers architectures with custom SMT topology callbacks, including powerpc. When forced on, priority remains defined by arch_asym_cpu_priority(). The weak default prefers lower-numbered logical CPUs, while architecture overrides remain authoritative. Siblings with equal priorities remain unordered.

Wasn't this a temporary solution you wanted until the firmware changes are sorted out? or something changed in between?

If yes, could you please capture that in changelog or in comment.

Quoted 15 lines
---
  .../admin-guide/kernel-parameters.txt         | 11 +++++
  kernel/sched/topology.c                       | 49 +++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +1 -0
index 33cd30996e47e..36c3b2e563441 100644
@@ -6799,6 +6799,17 @@ Kernel parameters
  			solution to mutex-based priority inversion.
  			Format: <bool>
 
+	sched_smt_asym_packing= [KNL,SMP]

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6812

Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10 -0
+			Override asymmetric packing at the SMT scheduling domain.
+			Format: { auto | on | off }
+			auto: Preserve the architecture default. This is the
+			default when the option is omitted.
+			on: Force asymmetric packing at the SMT scheduling domain.
+			Idle CPU selection prefers siblings with a higher
+			architecture-defined priority. Siblings with equal
+			priorities remain unordered.
+			off: Ignore SMT sibling priorities.
+

Wasn't this option/parameter to come from arch specific file?

Isn't it going to be confusing for archs which don't benefit from asym packing at SMT, but now there is kernel parameter to say on.

Quoted 70 lines
Documentation/admin-guide/kernel-parameters.txt +0 -0
  	sched_verbose	[KNL,EARLY] Enables verbose scheduler debug messages.
 
  	schedstats=	[KNL,X86] Enable or disable scheduled statistics.
kernel/sched/topology.c +49 -0
index 0248227d983a7..cdfcecf673fd7 100644
@@ -32,6 +32,46 @@ static int __init sched_debug_setup(char *str)
  }
  early_param("sched_verbose", sched_debug_setup);
 
+#ifdef CONFIG_SCHED_SMT
+enum sched_smt_asym_packing_mode {
+	SCHED_SMT_ASYM_PACKING_AUTO,
+	SCHED_SMT_ASYM_PACKING_ON,
+	SCHED_SMT_ASYM_PACKING_OFF,
+	SCHED_SMT_ASYM_PACKING_NR,
+};
+
+static enum sched_smt_asym_packing_mode sched_smt_asym_packing __read_mostly =
+	SCHED_SMT_ASYM_PACKING_AUTO;
+
+static const char * const sched_smt_asym_packing_modes[SCHED_SMT_ASYM_PACKING_NR] = {
+	[SCHED_SMT_ASYM_PACKING_AUTO]	= "auto",
+	[SCHED_SMT_ASYM_PACKING_ON]	= "on",
+	[SCHED_SMT_ASYM_PACKING_OFF]	= "off",
+};
+
+static int __init sched_smt_asym_packing_parse(const char *str)
+{
+	for (int mode = 0; mode < SCHED_SMT_ASYM_PACKING_NR; mode++) {
+		if (!strcmp(str, sched_smt_asym_packing_modes[mode]))
+			return mode;
+	}
+
+	return -EINVAL;
+}
+
+static int __init setup_sched_smt_asym_packing(char *str)
+{
+	int mode = sched_smt_asym_packing_parse(str);
+
+	if (mode < 0)
+		return 0;
+
+	sched_smt_asym_packing = mode;
+	return 1;
+}
+__setup("sched_smt_asym_packing=", setup_sched_smt_asym_packing);
+#endif
+
  static inline bool sched_debug(void)
  {
  	return sched_debug_verbose;
@@ -1950,6 +1990,15 @@ sd_init(struct sched_domain_topology_level *tl,
  	if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
  		      "wrong sd_flags in topology description\n"))
  		sd_flags &= TOPOLOGY_SD_FLAGS;
+#ifdef CONFIG_SCHED_SMT
+	if (sd_flags & SD_SHARE_CPUCAPACITY) {
+		if (sched_smt_asym_packing == SCHED_SMT_ASYM_PACKING_ON)
+			sd_flags |= SD_ASYM_PACKING;
+		else if (sched_smt_asym_packing ==
+			 SCHED_SMT_ASYM_PACKING_OFF)
+			sd_flags &= ~SD_ASYM_PACKING;
+	}
+#endif
  	sd_flags |= asym_cpu_capacity_classify(sd_span, cpu_map);
 
  	*sd = (struct sched_domain){
maintainer
#8 lore raw

Re: [PATCH 2/2] sched/topology: Add asymmetric SMT packing override

Quoted 43 lines · Shrikanth Hegde

Hi Andrea,

Quoted 12 lines · Andrea Righi

Architectures can use SD_ASYM_PACKING to describe preferred CPU ordering at the SMT scheduling domain. Some systems benefit from the same policy, but their firmware cannot currently describe the preference. Inferring it from the CPU model would embed a platform-specific policy in the kernel.

Add the sched_smt_asym_packing boot option to override SD_ASYM_PACKING at the SMT level. Accept auto, on and off. Auto preserves the architecture-provided topology and is also the default when the option is absent. On and off force the flag without changing asymmetric packing at higher topology levels.

Quoted 7 lines

Apply the override centrally to domains with SD_SHARE_CPUCAPACITY so it also covers architectures with custom SMT topology callbacks, including powerpc. When forced on, priority remains defined by arch_asym_cpu_priority(). The weak default prefers lower-numbered logical CPUs, while architecture overrides remain authoritative. Siblings with equal priorities remain unordered.

Wasn't this a temporary solution you wanted until the firmware changes are sorted out? or something changed in between?

If yes, could you please capture that in changelog or in comment.

Quoted 14 lines
---
  .../admin-guide/kernel-parameters.txt         | 11 +++++
  kernel/sched/topology.c                       | 49 +++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 33cd30996e47e..36c3b2e563441 100644
@@ -6799,6 +6799,17 @@ Kernel parameters
                      solution to mutex-based priority inversion.
                      Format: <bool>
 
Quoted 5 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6806

Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +5 -0
+     sched_smt_asym_packing= [KNL,SMP]
+                     Override asymmetric packing at the SMT scheduling domain.
+                     Format: { auto | on | off }
+                     auto: Preserve the architecture default. This is the
+                     default when the option is omitted.

AFAICT "auto" equals nothing added in the command line so why is it needed ?

Quoted 5 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6811

Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +5 -0
+                     on: Force asymmetric packing at the SMT scheduling domain.
+                     Idle CPU selection prefers siblings with a higher
+                     architecture-defined priority. Siblings with equal
+                     priorities remain unordered.
+                     off: Ignore SMT sibling priorities.

Is this for debugging purposes?

only the sched_smt_asym_packing=on is really useful to force asym_packing when firmware doesn't provide the info

Quoted 78 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6812

Quoted 1 line
Documentation/admin-guide/kernel-parameters.txt +1 -0
+

Wasn't this option/parameter to come from arch specific file?

Isn't it going to be confusing for archs which don't benefit from asym packing at SMT, but now there is kernel parameter to say on.

Quoted 70 lines
Documentation/admin-guide/kernel-parameters.txt +0 -0
      sched_verbose   [KNL,EARLY] Enables verbose scheduler debug messages.
 
      schedstats=     [KNL,X86] Enable or disable scheduled statistics.
kernel/sched/topology.c +49 -0
index 0248227d983a7..cdfcecf673fd7 100644
@@ -32,6 +32,46 @@ static int __init sched_debug_setup(char *str)
  }
  early_param("sched_verbose", sched_debug_setup);
 
+#ifdef CONFIG_SCHED_SMT
+enum sched_smt_asym_packing_mode {
+     SCHED_SMT_ASYM_PACKING_AUTO,
+     SCHED_SMT_ASYM_PACKING_ON,
+     SCHED_SMT_ASYM_PACKING_OFF,
+     SCHED_SMT_ASYM_PACKING_NR,
+};
+
+static enum sched_smt_asym_packing_mode sched_smt_asym_packing __read_mostly =
+     SCHED_SMT_ASYM_PACKING_AUTO;
+
+static const char * const sched_smt_asym_packing_modes[SCHED_SMT_ASYM_PACKING_NR] = {
+     [SCHED_SMT_ASYM_PACKING_AUTO]   = "auto",
+     [SCHED_SMT_ASYM_PACKING_ON]     = "on",
+     [SCHED_SMT_ASYM_PACKING_OFF]    = "off",
+};
+
+static int __init sched_smt_asym_packing_parse(const char *str)
+{
+     for (int mode = 0; mode < SCHED_SMT_ASYM_PACKING_NR; mode++) {
+             if (!strcmp(str, sched_smt_asym_packing_modes[mode]))
+                     return mode;
+     }
+
+     return -EINVAL;
+}
+
+static int __init setup_sched_smt_asym_packing(char *str)
+{
+     int mode = sched_smt_asym_packing_parse(str);
+
+     if (mode < 0)
+             return 0;
+
+     sched_smt_asym_packing = mode;
+     return 1;
+}
+__setup("sched_smt_asym_packing=", setup_sched_smt_asym_packing);
+#endif
+
  static inline bool sched_debug(void)
  {
      return sched_debug_verbose;
@@ -1950,6 +1990,15 @@ sd_init(struct sched_domain_topology_level *tl,
      if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
                    "wrong sd_flags in topology description\n"))
              sd_flags &= TOPOLOGY_SD_FLAGS;
+#ifdef CONFIG_SCHED_SMT
+     if (sd_flags & SD_SHARE_CPUCAPACITY) {
+             if (sched_smt_asym_packing == SCHED_SMT_ASYM_PACKING_ON)
+                     sd_flags |= SD_ASYM_PACKING;
+             else if (sched_smt_asym_packing ==
+                      SCHED_SMT_ASYM_PACKING_OFF)
+                     sd_flags &= ~SD_ASYM_PACKING;
+     }
+#endif
      sd_flags |= asym_cpu_capacity_classify(sd_span, cpu_map);
 
      *sd = (struct sched_domain){
#9 lore raw

Re: [PATCH 2/2] sched/topology: Add asymmetric SMT packing override

Hi Vincent,

On Fri, Sep 18, 2026 at 06:03:53PM +0200, Vincent Guittot wrote:
...

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 33cd30996e47e..36c3b2e563441 100644
@@ -6799,6 +6799,17 @@ Kernel parameters
                      solution to mutex-based priority inversion.
                      Format: <bool>
 
Quoted 7 lines
Quoted 5 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6806

Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +5 -0
+     sched_smt_asym_packing= [KNL,SMP]
+                     Override asymmetric packing at the SMT scheduling domain.
+                     Format: { auto | on | off }
+                     auto: Preserve the architecture default. This is the
+                     default when the option is omitted.

AFAICT "auto" equals nothing added in the command line so why is it needed ?

Right, auto is redundant. Omitting the parameter already preserves the topology provided by the architecture or firmware.

Quoted 8 lines
Quoted 6 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6811

Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt +5 -0
+                     on: Force asymmetric packing at the SMT scheduling domain.
+                     Idle CPU selection prefers siblings with a higher
+                     architecture-defined priority. Siblings with equal
+                     priorities remain unordered.
+                     off: Ignore SMT sibling priorities.

Is this for debugging purposes?

Yes, that was the intent, but I don't have a concrete use case that justifies exposing it.

Quoted 3 lines

only the sched_smt_asym_packing=on is really useful to force asym_packing when firmware doesn't provide the info

Agreed. I'll simplify the interface to an explicit force option for systems whose firmware can't describe the SMT preference.

Thanks,
-Andrea

Quoted 79 lines
Quoted 79 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6812

Quoted 2 lines
Documentation/admin-guide/kernel-parameters.txt +1 -0
+

Wasn't this option/parameter to come from arch specific file?

Isn't it going to be confusing for archs which don't benefit from asym packing at SMT, but now there is kernel parameter to say on.

Quoted 70 lines
Documentation/admin-guide/kernel-parameters.txt +0 -0
      sched_verbose   [KNL,EARLY] Enables verbose scheduler debug messages.
 
      schedstats=     [KNL,X86] Enable or disable scheduled statistics.
kernel/sched/topology.c +49 -0
index 0248227d983a7..cdfcecf673fd7 100644
@@ -32,6 +32,46 @@ static int __init sched_debug_setup(char *str)
  }
  early_param("sched_verbose", sched_debug_setup);
 
+#ifdef CONFIG_SCHED_SMT
+enum sched_smt_asym_packing_mode {
+     SCHED_SMT_ASYM_PACKING_AUTO,
+     SCHED_SMT_ASYM_PACKING_ON,
+     SCHED_SMT_ASYM_PACKING_OFF,
+     SCHED_SMT_ASYM_PACKING_NR,
+};
+
+static enum sched_smt_asym_packing_mode sched_smt_asym_packing __read_mostly =
+     SCHED_SMT_ASYM_PACKING_AUTO;
+
+static const char * const sched_smt_asym_packing_modes[SCHED_SMT_ASYM_PACKING_NR] = {
+     [SCHED_SMT_ASYM_PACKING_AUTO]   = "auto",
+     [SCHED_SMT_ASYM_PACKING_ON]     = "on",
+     [SCHED_SMT_ASYM_PACKING_OFF]    = "off",
+};
+
+static int __init sched_smt_asym_packing_parse(const char *str)
+{
+     for (int mode = 0; mode < SCHED_SMT_ASYM_PACKING_NR; mode++) {
+             if (!strcmp(str, sched_smt_asym_packing_modes[mode]))
+                     return mode;
+     }
+
+     return -EINVAL;
+}
+
+static int __init setup_sched_smt_asym_packing(char *str)
+{
+     int mode = sched_smt_asym_packing_parse(str);
+
+     if (mode < 0)
+             return 0;
+
+     sched_smt_asym_packing = mode;
+     return 1;
+}
+__setup("sched_smt_asym_packing=", setup_sched_smt_asym_packing);
+#endif
+
  static inline bool sched_debug(void)
  {
      return sched_debug_verbose;
@@ -1950,6 +1990,15 @@ sd_init(struct sched_domain_topology_level *tl,
      if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
                    "wrong sd_flags in topology description\n"))
              sd_flags &= TOPOLOGY_SD_FLAGS;
+#ifdef CONFIG_SCHED_SMT
+     if (sd_flags & SD_SHARE_CPUCAPACITY) {
+             if (sched_smt_asym_packing == SCHED_SMT_ASYM_PACKING_ON)
+                     sd_flags |= SD_ASYM_PACKING;
+             else if (sched_smt_asym_packing ==
+                      SCHED_SMT_ASYM_PACKING_OFF)
+                     sd_flags &= ~SD_ASYM_PACKING;
+     }
+#endif
      sd_flags |= asym_cpu_capacity_classify(sd_span, cpu_map);
 
      *sd = (struct sched_domain){
#10 lore raw

Re: [PATCH 2/2] sched/topology: Add asymmetric SMT packing override

In reply to Shrikanth Hegde

Hi Shrikanth,

Quoted 23 lines · Shrikanth Hegde

Hi Andrea,

Quoted 12 lines · Andrea Righi

Architectures can use SD_ASYM_PACKING to describe preferred CPU ordering at the SMT scheduling domain. Some systems benefit from the same policy, but their firmware cannot currently describe the preference. Inferring it from the CPU model would embed a platform-specific policy in the kernel.

Add the sched_smt_asym_packing boot option to override SD_ASYM_PACKING at the SMT level. Accept auto, on and off. Auto preserves the architecture-provided topology and is also the default when the option is absent. On and off force the flag without changing asymmetric packing at higher topology levels.

Quoted 7 lines

Apply the override centrally to domains with SD_SHARE_CPUCAPACITY so it also covers architectures with custom SMT topology callbacks, including powerpc. When forced on, priority remains defined by arch_asym_cpu_priority(). The weak default prefers lower-numbered logical CPUs, while architecture overrides remain authoritative. Siblings with equal priorities remain unordered.

Quoted 4 lines

Wasn't this a temporary solution you wanted until the firmware changes are sorted out? or something changed in between?

If yes, could you please capture that in changelog or in comment.

The firmware-described ACPI property remains the preferred long-term solution. However, defining and validating the interface across firmware, Linux, and other operating systems, as well as completing the ACPI standardization process, will take some time.

The command-line option is intended as an interim workaround and as a fallback for deployed systems whose firmware cannot be updated. It allows users to enable the optimization independently of their firmware version. I agree that this should be explained more clearly in the changelog.

Quoted 19 lines
Quoted 19 lines
---
  .../admin-guide/kernel-parameters.txt         | 11 +++++
  kernel/sched/topology.c                       | 49 +++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index 33cd30996e47e..36c3b2e563441 100644
@@ -6799,6 +6799,17 @@ Kernel parameters
  			solution to mutex-based priority inversion.
  			Format: <bool>
+	sched_smt_asym_packing= [KNL,SMP]
+			Override asymmetric packing at the SMT scheduling domain.
+			Format: { auto | on | off }
+			auto: Preserve the architecture default. This is the
+			default when the option is omitted.
Quoted 8 lines

Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 6812

Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt +6 -0
+			on: Force asymmetric packing at the SMT scheduling domain.
+			Idle CPU selection prefers siblings with a higher
+			architecture-defined priority. Siblings with equal
+			priorities remain unordered.
+			off: Ignore SMT sibling priorities.
+

Wasn't this option/parameter to come from arch specific file?

Will didn't like very much the idea of detecting this through an Olympus CPU quirk and requested a firmware-described property instead. Therefore, we moved to a boot-time override that avoids any Arm- or CPU-specific detection for now.

Quoted 3 lines

Isn't it going to be confusing for archs which don't benefit from asym packing at SMT, but now there is kernel parameter to say on.

That's a fair concern. Following Vincent's suggestion, I can drop the auto and off values and retain only an explicit force option. Without the option, the existing architecture-/firmware-provided topology is left unchanged.

Thanks,
-Andrea

Quoted 69 lines
Quoted 68 lines
Documentation/admin-guide/kernel-parameters.txt +0 -0
  	sched_verbose	[KNL,EARLY] Enables verbose scheduler debug messages.
  	schedstats=	[KNL,X86] Enable or disable scheduled statistics.
kernel/sched/topology.c +49 -0
index 0248227d983a7..cdfcecf673fd7 100644
@@ -32,6 +32,46 @@ static int __init sched_debug_setup(char *str)
  }
  early_param("sched_verbose", sched_debug_setup);
+#ifdef CONFIG_SCHED_SMT
+enum sched_smt_asym_packing_mode {
+	SCHED_SMT_ASYM_PACKING_AUTO,
+	SCHED_SMT_ASYM_PACKING_ON,
+	SCHED_SMT_ASYM_PACKING_OFF,
+	SCHED_SMT_ASYM_PACKING_NR,
+};
+
+static enum sched_smt_asym_packing_mode sched_smt_asym_packing __read_mostly =
+	SCHED_SMT_ASYM_PACKING_AUTO;
+
+static const char * const sched_smt_asym_packing_modes[SCHED_SMT_ASYM_PACKING_NR] = {
+	[SCHED_SMT_ASYM_PACKING_AUTO]	= "auto",
+	[SCHED_SMT_ASYM_PACKING_ON]	= "on",
+	[SCHED_SMT_ASYM_PACKING_OFF]	= "off",
+};
+
+static int __init sched_smt_asym_packing_parse(const char *str)
+{
+	for (int mode = 0; mode < SCHED_SMT_ASYM_PACKING_NR; mode++) {
+		if (!strcmp(str, sched_smt_asym_packing_modes[mode]))
+			return mode;
+	}
+
+	return -EINVAL;
+}
+
+static int __init setup_sched_smt_asym_packing(char *str)
+{
+	int mode = sched_smt_asym_packing_parse(str);
+
+	if (mode < 0)
+		return 0;
+
+	sched_smt_asym_packing = mode;
+	return 1;
+}
+__setup("sched_smt_asym_packing=", setup_sched_smt_asym_packing);
+#endif
+
  static inline bool sched_debug(void)
  {
  	return sched_debug_verbose;
@@ -1950,6 +1990,15 @@ sd_init(struct sched_domain_topology_level *tl,
  	if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
  		      "wrong sd_flags in topology description\n"))
  		sd_flags &= TOPOLOGY_SD_FLAGS;
+#ifdef CONFIG_SCHED_SMT
+	if (sd_flags & SD_SHARE_CPUCAPACITY) {
+		if (sched_smt_asym_packing == SCHED_SMT_ASYM_PACKING_ON)
+			sd_flags |= SD_ASYM_PACKING;
+		else if (sched_smt_asym_packing ==
+			 SCHED_SMT_ASYM_PACKING_OFF)
+			sd_flags &= ~SD_ASYM_PACKING;
+	}
+#endif
  	sd_flags |= asym_cpu_capacity_classify(sd_span, cpu_map);
  	*sd = (struct sched_domain){
#11 lore raw
In reply to Andrea Righi

On 17.09.26 16:05, Andrea Righi wrote:

[...]

Quoted 23 lines

The first patch teaches the fair scheduler's idle-selection paths to honor SD_ASYM_PACKING at the shared-capacity SMT level. The scheduler first selects a candidate CPU and core according to its existing placement and capacity rules, then chooses the highest-priority available sibling within that core. This also completes the existing POWER7 SD_ASYM_PACKING behavior by applying its hardware-thread ordering during idle selection.

Olympus firmware does not currently provide an interface to describe the preferred SMT sibling. Adding such a firmware or ACPI interface will take time and will not help systems with existing firmware. At the same time, inferring this policy from MIDR would encode a platform-specific decision in the kernel and make it harder to replace with a proper firmware ABI.

The second patch therefore adds the sched_smt_asym_packing= boot option. Using sched_smt_asym_packing=on explicitly opts the SMT scheduling domain into SD_ASYM_PACKING without requiring architecture-specific detection. Priority remains defined by arch_asym_cpu_priority(). The weak default orders siblings by -cpu, consistently selecting the lowest-numbered available logical CPU. Architecture overrides remain authoritative, so siblings assigned equal priorities remain unordered. The default auto mode preserves architecture-provided topology policy, including the existing powerpc behavior, while off provides an explicit override to disable SMT asymmetric packing.

Quoted 6 lines

On Olympus, PE0 and PE1 have equal steady-state capacity; this preference does not identify a faster PE. The lower-numbered logical CPU is used only as a canonical choice when both siblings are available. Consistently selecting the same sibling avoids alternating the active PE across wakeups, lets the other sibling remain idle for longer, and allows more cores to remain in, or return to, full-resource single-thread mode.

So I think that Power7 and other SMT machines won't ever turn 'sched_smt_asym_packing' on then.
As we have seen in https://lore.kernel.org/r/aqSEB2N_NQbBVab6@gpd4 this code will only benefit NVIDIAs Spatial SMT, i.e. dynamically partitioning a physical core, rather than conventional SMT where two threads opportunistically compete for most of the same machinery.

IIUC on Spatial SMT, placing the workload on PE0 is beneficial because even if interrupts and other per-CPU housekeeping activities have to be handled by PE0 next to the benchmark tasks, the main thing is that PE0 stays in full-resource single-thread mode (PE1 stays idle).

Quoted 6 lines

The v6 series was tested on a two-node Vera system using 88-thread single-precision GEMM workloads on the 88 physical cores of NUMA node 0, with sched_smt_asym_packing=on and the workloads allowed to choose either sibling of every core. Each result covers five runs.

Quoted 8 lines

Two BLAS implementations were tested: OpenBLAS, an open-source BLAS library that provides a publicly reproducible benchmark, and NVIDIA Performance Libraries (NVPL), NVIDIA's optimized BLAS implementation.

OpenBLAS was evaluated using benchmark/sgemm.goto with an M=N=K=16384 single-precision GEMM. NVPL was evaluated using benchblas with the same matrix dimensions, non-transposed inputs, alpha=1 and beta=0. The numbers below are the mean and standard deviation from five runs.

So I assume that you have 88 consistently running benchmark threads and in case your new code let them run more likely on PE0 instead PE1 you see this throughput increase.

Quoted 4 lines

OpenBLAS throughput increased from 7.11876 +/- 0.06734 TFLOP/s on the baseline kernel to 7.34669 +/- 0.01936 TFLOP/s with this series (+3.20%). NVPL throughput increased from 9.64742 +/- 0.17311 TFLOP/s to 10.29695 +/- 0.01786 TFLOP/s (+6.73%).

I assume further that NVPL has the same benchmark task model, maybe with a couple of sleep/wakeups in between?

[...]

#12 lore raw

Hi Dietmar,

Quoted 34 lines · Dietmar Eggemann

On 17.09.26 16:05, Andrea Righi wrote:

[...]

Quoted 23 lines

The first patch teaches the fair scheduler's idle-selection paths to honor SD_ASYM_PACKING at the shared-capacity SMT level. The scheduler first selects a candidate CPU and core according to its existing placement and capacity rules, then chooses the highest-priority available sibling within that core. This also completes the existing POWER7 SD_ASYM_PACKING behavior by applying its hardware-thread ordering during idle selection.

Olympus firmware does not currently provide an interface to describe the preferred SMT sibling. Adding such a firmware or ACPI interface will take time and will not help systems with existing firmware. At the same time, inferring this policy from MIDR would encode a platform-specific decision in the kernel and make it harder to replace with a proper firmware ABI.

The second patch therefore adds the sched_smt_asym_packing= boot option. Using sched_smt_asym_packing=on explicitly opts the SMT scheduling domain into SD_ASYM_PACKING without requiring architecture-specific detection. Priority remains defined by arch_asym_cpu_priority(). The weak default orders siblings by -cpu, consistently selecting the lowest-numbered available logical CPU. Architecture overrides remain authoritative, so siblings assigned equal priorities remain unordered. The default auto mode preserves architecture-provided topology policy, including the existing powerpc behavior, while off provides an explicit override to disable SMT asymmetric packing.

Quoted 6 lines

On Olympus, PE0 and PE1 have equal steady-state capacity; this preference does not identify a faster PE. The lower-numbered logical CPU is used only as a canonical choice when both siblings are available. Consistently selecting the same sibling avoids alternating the active PE across wakeups, lets the other sibling remain idle for longer, and allows more cores to remain in, or return to, full-resource single-thread mode.

Quoted 2 lines

So I think that Power7 and other SMT machines won't ever turn 'sched_smt_asym_packing' on then.

Right, POWER7 already sets SD_ASYM_PACKING on its SMT domain (recognized through processor version register), so it doesn't need the boot option.

The boot option is only for systems such as Olympus whose firmware doesn't currently describe a sibling preference.

Quoted 4 lines

As we have seen in https://lore.kernel.org/r/aqSEB2N_NQbBVab6@gpd4 this code will only benefit NVIDIAs Spatial SMT, i.e. dynamically partitioning a physical core, rather than conventional SMT where two threads opportunistically compete for most of the same machinery.

Right, on conventional SMT systems with symmetric siblings and no architecture-defined priority, I don't expect any performance benefit enabling this option.

Quoted 5 lines

IIUC on Spatial SMT, placing the workload on PE0 is beneficial because even if interrupts and other per-CPU housekeeping activities have to be handled by PE0 next to the benchmark tasks, the main thing is that PE0 stays in full-resource single-thread mode (PE1 stays idle).

Correct. On Olympus the lower-numbered logical sibling is PE0, prioritizing it consistently reduces the activations of both PEs, so PE0 stays in full-resource mode.

Quoted 10 lines
Quoted 10 lines

The v6 series was tested on a two-node Vera system using 88-thread single-precision GEMM workloads on the 88 physical cores of NUMA node 0, with sched_smt_asym_packing=on and the workloads allowed to choose either sibling of every core. Each result covers five runs.

Two BLAS implementations were tested: OpenBLAS, an open-source BLAS library that provides a publicly reproducible benchmark, and NVIDIA Performance Libraries (NVPL), NVIDIA's optimized BLAS implementation.

Quoted 8 lines
Quoted 4 lines

OpenBLAS was evaluated using benchmark/sgemm.goto with an M=N=K=16384 single-precision GEMM. NVPL was evaluated using benchblas with the same matrix dimensions, non-transposed inputs, alpha=1 and beta=0. The numbers below are the mean and standard deviation from five runs.

So I assume that you have 88 consistently running benchmark threads and in case your new code let them run more likely on PE0 instead PE1 you see this throughput increase.

Yes, both benchmarks used 88 threads across 88 physical cores, with both siblings eligible. I captured per-thread scheduler traces and perf counters, with PE prioritization, placement favored PE0 and single-thread/two-thread mode transitions fell consistently. In the earlier five-run comparison the ST/SMT transitions fell by about ~80%.

Quoted 8 lines
Quoted 5 lines

OpenBLAS throughput increased from 7.11876 +/- 0.06734 TFLOP/s on the baseline kernel to 7.34669 +/- 0.01936 TFLOP/s with this series (+3.20%). NVPL throughput increased from 9.64742 +/- 0.17311 TFLOP/s to 10.29695 +/- 0.01786 TFLOP/s (+6.73%).

I assume further that NVPL has the same benchmark task model, maybe with a couple of sleep/wakeups in between?

Correct, I just checked the sleep/wakeup pattern: across 88 threads, the NVPL run shows ~2.6K interruptible sleeps/wakeups and ~3K futex waits. The GEMM OpenBLAS run shows only ~250 sleeps/wakeups and futex waits. All those repeated wakeups give the scheduler more opportunities to choose a sibling and are likely the reason of NVPL's bigger improvement.

Thanks,
-Andrea