1. background

Spin-locking code typically uses PAUSE instructions in a loop.

For more details, please refer to pause.

2. motivation

为什么需要pause loop exiting(ple)这一feature呢?

3. details

Basic Exit Reason 40

PLE_Gap - upper bound on the amount of time between two successive executions of PAUSE in a loop.
PLE_Window - upper bound on the amount of time a guest is allowed to execute in a PAUSE loop

If the time, between this execution of PAUSE and previous one, exceeds the PLE_Gap, processor consider this PAUSE belongs to a new loop. Otherwise, processor determins the the total execution time of this loop(since 1st PAUSE in this loop), and triggers a VM exit if total time exceeds the PLE_Window.

Pause-Loop Exiting can be used to detect Lock-Holder Preemption, where one VCPU is sched-out after hold a spinlock, then other VCPUs for same lock are sched-in to waste the CPU time.

个人感觉PLE_Gap与PLE_Window的设置,就是调参吧。


参考资料:

  1. riel_t_1620_kvm_performance.pdf
  2. linux-containers-hypervisor-based-vms-paper.pdf
  3. KVM: add support for Pause-Loop exit