Skip to content

Steal time based dynamic CPU resource management

Srikar Dronamraju linuxppc-dev lkml virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest17 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17sched/fair: Enable group_asym_packing in find_idlest_groupkernel/sched/fair.c+28 -50 replies
2/17powerpc/lpar: Reorder steal accounting calculationarch/powerpc/platforms/pseries/lpar.c+9 -40 replies
3/17pseries/lpar: Process steal metricsarch/powerpc/platforms/pseries/lpar.c arch/powerpc/platforms/pseries/pseries.h+54 -00 replies
4/17powerpc/smp: Add num_available_cores callback for smp_opsarch/powerpc/include/asm/smp.h arch/powerpc/kernel/smp.c+8 -00 replies
5/17pseries/smp: Query and set entitlementsarch/powerpc/platforms/pseries/smp.c+38 -00 replies
6/17powerpc/smp: Delay processing steal time at bootarch/powerpc/kernel/smp.c arch/powerpc/platforms/pseries/lpar.c+12 -00 replies
7/17sched/core: Set balance_callback only if CPU is dyingkernel/sched/core.c+5 -50 replies
8/17sched/core: Implement CPU soft offline/onlineinclude/linux/sched/topology.h kernel/sched/core.c+40 -54 replies
9/17powerpc/smp: Implement arch_scale_cpu_capacity for shared LPARsarch/powerpc/include/asm/topology.h arch/powerpc/kernel/smp.c+22 -00 replies
10/17powerpc/smp: Define arch_update_cpu_topology for shared LPARsarch/powerpc/include/asm/smp.h arch/powerpc/kernel/smp.c+11 -00 replies
11/17pseries/smp: Create soft offline infrastructure for Powerpc shared LPARs.arch/powerpc/platforms/pseries/smp.c+39 -00 replies
12/17pseries/smp: Trigger softoffline based on steal metricsarch/powerpc/platforms/pseries/lpar.c arch/powerpc/platforms/pseries/pseries.h arch/powerpc/platforms/pseries/smp.c+60 -30 replies
13/17pseries/smp: Account cores when triggering softofflinearch/powerpc/platforms/pseries/smp.c+25 -20 replies
14/17powerpc/smp: Assume preempt if CPU is inactive.arch/powerpc/include/asm/paravirt.h+9 -530 replies
15/17pseries/hotplug: Update available_cores on a dlpar eventarch/powerpc/platforms/pseries/hotplug-cpu.c arch/powerpc/platforms/pseries/pseries.h arch/powerpc/platforms/pseries/smp.c+8 -10 replies
16/17pseries/smp: Allow users to override steal thresholdsarch/powerpc/platforms/pseries/smp.c+23 -70 replies
17/17pseries/lpar: Add debug interface to set steal intervalarch/powerpc/platforms/pseries/lpar.c+11 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/17] Steal time based dynamic CPU resource management

VMs or Shared LPARs provide flexibility, better and efficient use of system resources. To achieve this most of these setups (VMs or LPARs) will have guaranteed or entitled share of resources. However they will be allotted more resources so that a VM can get to use unused share of free/unused VMs Hence most of these VMs are configured to be overcommitted i.e each VM can exceed its guaranteed share of resources. Here we are mostly looking at CPU/cores as a resource. The other option is pinning, which does provide flexibility but not better use of system resources.

However each VM thinks that it has access to all the allotted resources. Hence each VM will spread the workload to as many CPUs/cores as possible. This leads to resource contention causing performance impact. Hence the clear goal of better system utilization is actually not met.

To overcome this problem, a hint could be provided to the VMs so that Linux scheduler knows how many CPUs/cores have to be used. In this series, steal time is used as a hint so that Linux scheduler uses to know how and which CPUs/cores are to be used. Typically if the resources are over-utilized by one or more of the VMs, the steal time will spike. If the resources are underutilized, the steal time will be low. Currently this series implements this steal based dynamic CPU resource management on PowerVM Shared LPARs. However since steal is a pretty generic VM attribute, this can be extended to any architecture that has some form of steal accounting.

If in the future, there is a better hinting mechanism/strategy, the infrastructure could be modified to work with it.

There have been similar work on these lines. The most recent reference being
https://lore.kernel.org/all/[email protected]/

Here is the broad outline of this patch series.
- If the steal time is high identify CPUs that not be should be used, reduce their CPU capacity and mark them as inactive. This will make unpinned tasks to be migrated out. Pinned tasks that cant be migrated out will still continue to run over there.
- If the steal time is low identify CPUs that were marked as inactive, reset their CPU capacity, mark them as active and available for the scheduler to use.

For our experiment we have 2 shared LPARs both having 72 cores/576 CPUs each entitled to 24 cores/192 CPUs and both sharing 64 cores/512 CPUs running 10 iterations of ebizzy. (Higher is better)

nonoise case, i.e only ebizzy is running on 1 LPAR and the other LPAR is free

threads  base  cores-used  +patchset  cores-used
8        1     4.82        1.01958    5.025
12       1     6.855       1.01761    7.09
16       1     8.86        0.977243   8.475
24       1     13.47       0.996121   13.085
36       1     20.1        1.01447    19.79
64       1     33.2        0.976135   29.105
72       1     36.05       1.01956    35.775
144      1     55.14       1.01805    54.74
288      1     56.005      1.06081    56.575
576      1     54.945      1.07684    42.42
1152     1     54.65       1.06421    41.625

noise case, i.e both LPARS running similar ebizzy workload.
In the noise case, if one LPAR runs x threads, ebizzy, noise/other lpar also runs x threads where x is 8,12,16,24..

threads  base  cores-used  +patchset  cores-used
8        1     4.805       0.982148   5.32
12       1     6.865       1.00572    7.405
16       1     8.975       0.972395   9.33
24       1     13.44       0.999339   13.525
36       1     19.95       1.00277    19.24
64       1     26.615      1.05265    26.73
72       1     27.055      0.968465   26.05
144      1     32.84       0.917759   33.23
288      1     30.365      0.957132   29.18
576      1     29.14       0.870245   23.325
1152     1     29.135      0.897712   24.36

While there are some regressions, its certainly using less number of cores. Also on an average cache-misses, cycles, instructions, context-switches reduced by 3x with the patchset both in the noise and nonoise case. (Lower is better)

nonoise

         cache-misses    cs              cycles          instructions
threads  base  +patched  base  +patched  base  +patched  base  +patched
8        1     0.26      1     0.34      1     0.28      1     0.32
12       1     0.42      1     0.50      1     0.41      1     0.51
16       1     0.27      1     0.33      1     0.29      1     0.31
24       1     0.43      1     0.51      1     0.44      1     0.49
36       1     0.29      1     0.33      1     0.31      1     0.32
64       1     0.43      1     0.50      1     0.46      1     0.47
72       1     0.19      1     0.20      1     0.19      1     0.19
144      1     0.48      1     0.50      1     0.47      1     0.48
288      1     0.24      1     0.25      1     0.24      1     0.25
576      1     0.13      1     0.25      1     0.22      1     0.25
1152     1     0.35      1     0.34      1     0.37      1     0.33

noise

         cache-misses    cs              cycles          instructions
threads  base  +patched  base  +patched  base  +patched  base  +patched
8        1     0.26      1     0.33      1     0.28      1     0.33
12       1     0.39      1     0.52      1     0.41      1     0.48
16       1     0.27      1     0.33      1     0.29      1     0.32
24       1     0.42      1     0.51      1     0.44      1     0.48
36       1     0.35      1     0.34      1     0.32      1     0.32
64       1     0.43      1     0.50      1     0.46      1     0.48
72       1     0.20      1     0.19      1     0.19      1     0.19
144      1     0.49      1     0.51      1     0.46      1     0.45
288      1     0.23      1     0.25      1     0.21      1     0.21
576      1     0.26      1     0.25      1     0.21      1     0.20
1152     1     0.29      1     0.34      1     0.35      1     0.26

However there is still more work to be done.
Please let me know your valuable inputs/feedback about these changes. Should apply cleanly on v6.18

Cc "Ben Segall <[email protected]>"
Cc "Christophe Leroy <[email protected]>"
Cc "Dietmar Eggemann <[email protected]>"
Cc "Ingo Molnar <[email protected]>"
Cc "Juri Lelli <[email protected]>"
Cc "K Prateek Nayak <[email protected]>"
Cc "Madhavan Srinivasan <[email protected]>"
Cc "Mel Gorman <[email protected]>"
Cc "Michael Ellerman <[email protected]>"
Cc "Nicholas Piggin <[email protected]>"
Cc "Peter Zijlstra <[email protected]>"
Cc "Shrikanth Hegde <[email protected]>"
Cc "Steven Rostedt <[email protected]>"
Cc "Swapnil Sapkal <[email protected]>"
Cc "Thomas Huth <[email protected]>"
Cc "Valentin Schneider <[email protected]>"
Cc "Vincent Guittot <[email protected]>"
Cc "Yicong Yang <[email protected]>"
Cc "Ilya Leoshkevich <[email protected]>"

Srikar Dronamraju (17):
sched/fair: Enable group_asym_packing in find_idlest_group powerpc/lpar: Reorder steal accounting calculation pseries/lpar: Process steal metrics
powerpc/smp: Add num_available_cores callback for smp_ops pseries/smp: Query and set entitlements
powerpc/smp: Delay processing steal time at boot sched/core: Set balance_callback only if CPU is dying sched/core: Implement CPU soft offline/online powerpc/smp: Implement arch_scale_cpu_capacity for shared LPARs powerpc/smp: Define arch_update_cpu_topology for shared LPARs pseries/smp: Create soft offline infrastructure for Powerpc shared
LPARs.
pseries/smp: Trigger softoffline based on steal metrics pseries/smp: Account cores when triggering softoffline powerpc/smp: Assume preempt if CPU is inactive. pseries/hotplug: Update available_cores on a dlpar event pseries/smp: Allow users to override steal thresholds pseries/lpar: Add debug interface to set steal interval

 arch/powerpc/include/asm/paravirt.h          |  62 +------
 arch/powerpc/include/asm/smp.h               |   6 +
 arch/powerpc/include/asm/topology.h          |   5 +
 arch/powerpc/kernel/smp.c                    |  38 ++++
 arch/powerpc/platforms/pseries/hotplug-cpu.c |   6 +
 arch/powerpc/platforms/pseries/lpar.c        |  71 +++++++-
 arch/powerpc/platforms/pseries/pseries.h     |   8 +
 arch/powerpc/platforms/pseries/smp.c         | 173 +++++++++++++++++++
 include/linux/sched/topology.h               |   1 +
 kernel/sched/core.c                          |  50 +++++-
 kernel/sched/fair.c                          |  33 +++-
 11 files changed, 383 insertions(+), 70 deletions(-)
Signature · 1 line
2.43.7