Notes about guest halt polling feature.

前提: 需要对intel的hlt指令有一定的了解。

The cpuidle_haltpoll driver, with the haltpoll governor, allows the guest vcpus to poll for a specified amount of time before halting.

This provides the following benefits to host side polling:

  1. The POLL flag is set while polling is performed, which allows a remote vCPU to avoid sending an IPI (and the associated cost of handling the IPI) when performing a wakeup.
  2. The VM-exit cost can be avoided.

The downside of guest side polling is that polling is performed even with other runnable tasks in the host.

The basic logic as follows: A global value, guest_halt_poll_ns, is configured by the user, indicating the maximum amount of time polling is allowed. This value is fixed.

Each vcpu has an adjustable guest_halt_poll_ns (“per-cpu guest_halt_poll_ns”), which is adjusted by the algorithm in response to events.

The module parameters can be set from the debugfs files in:

1
/sys/module/haltpoll/parameters/

源码实现建议参考kvm performance optimization technologies, part two“Host/Guest halt poll”一节。


参考资料:

  1. Guest halt polling
  2. cpuidle haltpoll driver and governor