Skip to content

RFC directed yield for Pause Loop Exiting

Rik van Riel kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 56 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3kvm: keep track of which task is running a KVM vcpuinclude/linux/kvm_host.h virt/kvm/kvm_main.c+3 -07 replies
2/3sched: add yield_to functioninclude/linux/sched.h kernel/sched.c kernel/sched_fair.c+78 -031 replies
3/3kvm: use yield_to instead of sleep in kvm_vcpu_on_spininclude/linux/kvm_host.h virt/kvm/kvm_main.c+45 -87 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/3] directed yield for Pause Loop Exiting

When running SMP virtual machines, it is possible for one VCPU to be spinning on a spinlock, while the VCPU that holds the spinlock is not currently running, because the host scheduler preempted it to run something else.

Both Intel and AMD CPUs have a feature that detects when a virtual CPU is spinning on a lock and will trap to the host.

The current KVM code sleeps for a bit whenever that happens, which results in eg. a 64 VCPU Windows guest taking forever and a bit to boot up. This is because the VCPU holding the lock is actually running and not sleeping, so the pause is counter-productive.

In other workloads a pause can also be counter-productive, with spinlock detection resulting in one guest giving up its CPU time to the others. Instead of spinning, it ends up simply not running much at all.

This patch series aims to fix that, by having a VCPU that spins give the remainder of its timeslice to another VCPU in the same guest before yielding the CPU - one that is runnable but got preempted, hopefully the lock holder.

Scheduler people, please flame me with anything I may have done wrong, so I can do it right for a next version :)

Signature · 1 line
All rights reversed.