Skip to content

sched/fair: SMT-aware asymmetric CPU capacity

Andrea Righi lkml 6 versions – Applied

Status from this message: The following commit has been merged into the sched/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest5 patches 23 repliesApplied
  2. v55 patches 19 repliesSuperseded
  3. v46 patches 13 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v35 patches17 repliesSuperseded
v22 patches18 repliesSuperseded
v14 patches39 repliesSuperseded

Changes in v6 from the cover letter

- Simplify the SIS_UTIL early-exit in select_idle_capacity(): drop the best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT guard and exit once the scan budget is exhausted, matching select_idle_cpu() (Dietmar Eggemann)
- Move the sd_llc_shared -> sd_balance_shared rename in nohz_balancer_kick() from the NOHZ RCU cleanup patch into the sd_asym_cpucapacity attach patch, where it logically belongs (Dietmar Eggemann)
- Rename prefers_idle_core to has_idle_core in select_idle_capacity() (Dietmar Eggemann)
- Use ASYM_IDLE_CORE_COMPLETE_MISFIT instead of ASYM_IDLE_CORE_BIAS in the select_idle_capacity() comments (Vincent Guittot)
- Expand the asym_fits_state docstring with a per-rank table and an explanation of ASYM_IDLE_CORE_BIAS as an offset rather than a state
- Small code comment adjustments based on previous reviews
- Link to v5: https://lore.kernel.org/all/[email protected]

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/5sched/fair: Drop redundant RCU read lock in NOHZ kick pathkernel/sched/fair.c+11 -276 replies
2/5sched/fair: Attach sched_domain_shared to sd_asym_cpucapacitykernel/sched/fair.c kernel/sched/sched.h kernel/sched/topology.c+95 -2123 replies
3/5sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selectionkernel/sched/fair.c+113 -63 replies
4/5sched/fair: Reject misfit pulls onto busy SMT siblings on asym-capacitykernel/sched/fair.c+10 -13 replies
5/5sched/fair: Add SIS_UTIL support to select_idle_capacity()kernel/sched/fair.c+19 -01 reply

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchK Prateek NayakVincent GuittotShrikanth HegdePeter ZijlstraAndrea RighiBreno LeitaoDietmar Eggemann
1/5R-b R-b R-b
2/5A-b A-b R-b Originally-by T-b T-b T-b
3/5R-b R-b R-b R-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v6 thread

Cover letter [PATCH v6 0/5 RESEND] sched/fair: SMT-aware asymmetric CPU capacity

[ Re-sending due to missing subject in the previous email. ]

This series attempts to improve SD_ASYM_CPUCAPACITY scheduling by introducing SMT awareness.

= Problem =

Nominal per-logical-CPU capacity can overstate usable compute when an SMT sibling is busy, because the physical core doesn't deliver its full nominal capacity. So, several asym-cpu-capacity paths may pick high capacity idle CPUs that are not actually good destinations.

= Solution =

This patch set aligns those paths with a simple rule already used elsewhere:
when SMT is active, prefer fully idle cores and avoid treating partially idle SMT siblings as full-capacity targets where that would mislead load balance.

Patch set summary:
- Attach sched_domain_shared to sd_asym_cpucapacity in SD_ASYM_CPUCAPACITY to use has_idle_cores hint consistently in the wakeup idle scan and rename sd_llc_shared -> sd_balance_shared.
- Prefer fully-idle SMT cores in asym-capacity idle selection: in the wakeup fast path, extend select_idle_capacity() / asym_fits_cpu() so idle selection can prefer CPUs on fully idle cores.
- Reject misfit pulls onto busy SMT siblings on SD_ASYM_CPUCAPACITY.
- Add SIS_UTIL support to select_idle_capacity(): add to select_idle_capacity() the same SIS_UTIL-controlled idle-scan mechanism, already used by select_idle_cpu().

This patch set has been tested on the new NVIDIA Vera Rubin platform, where SMT is enabled and the firmware exposes small frequency variations (+/-~5%) as differences in CPU capacity, resulting in SD_ASYM_CPUCAPACITY being set.

Without these patches, performance can drop by up to ~2x with CPU-intensive workloads, because the SD_ASYM_CPUCAPACITY idle selection policy does not account for busy SMT siblings.

Alternative approaches have been evaluated, such as equalizing CPU capacities, either by exposing uniform values via firmware or normalizing them in the kernel by grouping CPUs within a small capacity window (+-5%).

However, the SMT-aware SD_ASYM_CPUCAPACITY approach has shown better results so far. Improving this policy also seems worthwhile in general, as future platforms may enable SMT with asymmetric CPU topologies.

Performance results on Vera Rubin with SD_ASYM_CPUCAPACITY (mainline) vs SD_ASYM_CPUCAPACITY + SMT

- NVBLAS benchblas (one task / SMT core):

 +---------------------------------+--------+
 | Configuration                   | gflops |
 +---------------------------------+--------+
 | ASYM (mainline) + SIS_UTIL      |  5478  |
 | ASYM (mainline) + NO_SIS_UTIL   |  5491  |
 |                                 |        |
 | NO ASYM + SIS_UTIL              |  8912  |
 | NO ASYM + NO_SIS_UTIL           |  8978  |
 |                                 |        |
 | ASYM + SMT + SIS_UTIL           |  9259  |
 | ASYM + SMT + NO_SIS_UTIL        |  9291  |
 +---------------------------------+--------+

- DCPerf MediaWiki (all CPUs):

 +---------------------------------+--------+--------+--------+--------+
 | Configuration                   |   rps  |  p50   |  p95   |  p99   |
 +---------------------------------+--------+--------+--------+--------+
 | ASYM (mainline) + SIS_UTIL      |  7994  |  0.052 |  0.223 |  0.246 |
 | ASYM (mainline) + NO_SIS_UTIL   |  7993  |  0.052 |  0.221 |  0.245 |
 |                                 |        |        |        |        |
 | NO ASYM + SIS_UTIL              |  8113  |  0.067 |  0.184 |  0.225 |
 | NO ASYM + NO_SIS_UTIL           |  8093  |  0.068 |  0.184 |  0.223 |
 |                                 |        |        |        |        |
 | ASYM + SMT + SIS_UTIL           |  8129  |  0.076 |  0.149 |  0.188 |
 | ASYM + SMT + NO_SIS_UTIL        |  8138  |  0.076 |  0.148 |  0.186 |
 +---------------------------------+--------+--------+--------+--------+

In the MediaWiki case SMT awareness is less impactful, because for the majority of the run all CPUs are used, but it still seems to provide some benefits at reducing tail latency.

Tests have also been conducted on NVIDIA Grace (which does not support SMT) to ensure that SIS_UTIL support in select_idle_capacity() does not introduce regressions and results show slight improvements under the same workloads.

See also:
- https://lore.kernel.org/lkml/[email protected]
- https://lore.kernel.org/lkml/[email protected]

Changes in v6:
- Simplify the SIS_UTIL early-exit in select_idle_capacity(): drop the best_fits == ASYM_IDLE_CORE_UCLAMP_MISFIT guard and exit once the scan budget is exhausted, matching select_idle_cpu() (Dietmar Eggemann)
- Move the sd_llc_shared -> sd_balance_shared rename in nohz_balancer_kick() from the NOHZ RCU cleanup patch into the sd_asym_cpucapacity attach patch, where it logically belongs (Dietmar Eggemann)
- Rename prefers_idle_core to has_idle_core in select_idle_capacity() (Dietmar Eggemann)
- Use ASYM_IDLE_CORE_COMPLETE_MISFIT instead of ASYM_IDLE_CORE_BIAS in the select_idle_capacity() comments (Vincent Guittot)
- Expand the asym_fits_state docstring with a per-rank table and an explanation of ASYM_IDLE_CORE_BIAS as an offset rather than a state
- Small code comment adjustments based on previous reviews
- Link to v5: https://lore.kernel.org/all/[email protected]

Changes in v5:
- Drop redundant RCU protection in nohz_balancer_kick() (Prateek Nayak)
- Do not remove CPU capacity asymmetry / SMT warning (Prateek Nayak)
- Link to v4: https://lore.kernel.org/all/[email protected]

Changes in v4:
- Rename sd_llc_shared -> sd_balance_shared
- Add preliminary cleanup patch to use guard(rcu)() for sched_domain RCU (Prateek Nayak)
- Apply SIS_UTIL scan cap only with !prefers_idle_core, matching select_idle_cpu() / has_idle_core logic (Vincent Guittot)
- Cache env->dst_cpu idle state to reduce is_core_idle() calls (Prateek Nayak)
- Remove warning about CPU capacity asymmetry not supporting SMT
- Link to v3: https://lore.kernel.org/all/[email protected]

Changes in v3:
- Add SIS_UTIL support to select_idle_capacity() (K Prateek Nayak)
- Attach sched_domain_shared to sd_asym_cpucapacity (K Prateek Nayak)
- Add enum for the different fit state (K Prateek Nayak)
- Update has_idle_cores hint (Vincent Guittot)
- Link to v2: https://lore.kernel.org/all/[email protected]

Changes in v2:
- Rework SMT awareness logic in select_idle_capacity() (K Prateek Nayak)
- Drop EAS and find_new_ilb() changes for now
- Link to v1: https://lore.kernel.org/all/[email protected]

Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git sched-asym-smt-v6

Andrea Righi (3):
sched/fair: Drop redundant RCU read lock in NOHZ kick path sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection sched/fair: Reject misfit pulls onto busy SMT siblings on asym-capacity

K Prateek Nayak (2):
sched/fair: Attach sched_domain_shared to sd_asym_cpucapacity sched/fair: Add SIS_UTIL support to select_idle_capacity()

 kernel/sched/fair.c     | 206 ++++++++++++++++++++++++++++++++++++++----------
 kernel/sched/sched.h    |   2 +-
 kernel/sched/topology.c |  95 +++++++++++++++++++---
 3 files changed, 248 insertions(+), 55 deletions(-)