Skip to content

RFC sched: cpu parked and push current task mechanism

Shrikanth Hegde lkml llvm oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5cpumask: Introduce cpu parked maskinclude/linux/cpumask.h kernel/cpu.c+17 -02 replies
2/5sched/core: Don't use parked cpu for selectionkernel/sched/core.c+2 -22 replies
3/5sched/fair: Don't use parked cpu for load balancingkernel/sched/fair.c+1 -00 replies
4/5sched/core: Push current task when cpu is parkedkernel/sched/core.c kernel/sched/sched.h+40 -01 reply
5/5powerpc: Use manual hint for cpu parkingarch/powerpc/kernel/smp.c+45 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC PATCH 0/5] sched: cpu parked and push current task mechanism

In a para-virtualised environment, there could be multiple overcommitted VMs. i.e sum of virtual CPUs(vCPU) > physical CPU(pCPU). When all such VMs request for cpu cycles at the same, it is not possible to serve all of them. This leads to VM level preemptions and hence the steal time.

Bring the notion of CPU parked state which implies underlying pCPU may not be available for use at this time. This means it is better to avoid this vCPU. So when a CPU is marked as parked, one should vacate it as soon as it can. So it is going to dynamic at runtime and can change often.

In general, task level preemption(driven by VM) is less expensive than VM level preemption(driven by hypervisor). So pack to less CPUs helps to improve the overall workload throughput/latency.

Architecture needs to decide which CPUs are parked. Currently we are exploring getting the hint from the stolen time and hypervisor provided statistics. There is simple powerpc debug patch which shows how one can make use of it cpu parked feature.

cpu parking and need for cpu parking has been explained here as well [1]. Much of the context explained in the cover letter there applies to this problem context as well.
[1]: https://lore.kernel.org/all/[email protected]/

While trying the above method, on large system (480 vCPUS) it was taking around 8-10 seconds for workload to move. Which is a longer time, so this approach, where workload moves within 1-2 seconds

Pros:
- Once tasks move, no load balancer overheads
- Less need for stats. minimal load balancer changes.
- Faster. Since it is based on sched_tick
- system maintains a state of parked cpus. Other subsystems may find it useful.

Cons:
- stop machine based to move the current task. So couldn't move it before it gets scheduled.
- Depends on CONFIG_HOTPLUG_CPU since it is relying on __balance_push_cpu_stop (might not be a big concern)

Sending this out to get feedback on the idea. This mechanism seems lightweight and fast. There are other push task related patches sent for EAS[2], and newidle balance[3]. Maybe it is time to come up push task framework that each one can make use of. Need to dig more into it[4]. Need to address RT, DL, IRQ, taskset concerns still. There maybe subtle races too(no warn/bugs on console while testing cfs tasks)

[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/
[4]: https://lore.kernel.org/all/[email protected]/

Based on tip/master at fa95dea97bd1 (Merge branch into tip/master: 'perf/core')

Shrikanth Hegde (5):
cpumask: Introduce cpu parked mask sched/core: Don't use parked cpu for selection sched/fair: Don't use parked cpu for load balancing sched/core: Push current task when cpu is parked
powerpc: Use manual hint for cpu parking

 arch/powerpc/kernel/smp.c | 45 +++++++++++++++++++++++++++++++++++++++
 include/linux/cpumask.h   | 14 ++++++++++++
 kernel/cpu.c              |  3 +++
 kernel/sched/core.c       | 43 +++++++++++++++++++++++++++++++++++--
 kernel/sched/fair.c       |  1 +
 kernel/sched/sched.h      |  1 +
 6 files changed, 105 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.3