KVM settings

This topic describes the KVM settings that were used for this study.

halt_poll_ns

On newer kernel releases there is a KVM module parameter /sys/module/kvm/parameters/halt_poll_ns that can be used to alter the behavior of how idle KVM guest virtual CPUs (vcpus) are handled.

When a vcpu in a KVM guest has no work to do (no threads waiting to run), QEMU traditionally halts the idle vcpus. This setting specifies a period of time (in nanoseconds) that a vcpu will wait and poll looking for new work before the vcpu is halted.

When new work arrives during the polling period (before the vcpu is halted), the vcpu is immediately ready to execute the work. If the vcpu has been halted when new work arrives, the vcpu must be brought out of the halt state before the new work can be started. The time it takes to transition the vcpu from halted to running state induces additional latency which negatively impacts latency sensitive workloads.

The introduction of the polling period can improve the responsiveness of small payload transactional network workloads.

Specifying a poll time in general is expected to have a potentially negative impact to CPU utilization. Instead of halting a vcpu immediately, the vcpu is now polling (looping) while it waits for new work. The additional poll time can increase the CPU utilization.

So this setting attempts to balance the trade-off of potentially increased CPU consumption in order to provide better responsiveness and lower latencies to improve throughput and operations/sec. The amount of polling time that is ideal for a particular network workload can vary. Users can experiment with different values to find whats optimal for their workloads.

Figure 1. halt_poll_ns improvements to transactional workloads

Experiments were conducted using the uperf workloads defined earlier. For these workload tests, a halt_poll_ns value of 80,000 ns produced the best overall results. In Figure 1, we see a number of the small payload transactional tests get up to 35% improvement with most seeing little or no negative impact to CPU efficiency.

To see what poll time value is set use the following command:
[root@kvmhost ~] # cat /sys/module/kvm/parameters/halt_poll_ns

A value of 0 means halt_poll_ns is disabled.

To enable or change the polling time, specify a non-zero value using the command:
# echo 80000 > /sys/module/kvm/parameters/halt_poll_ns

Changes to this setting are immediately available to running KVM guests with no restarts required.

In a environment where CPU resources are highly over-committed, this setting might be counterproductive.