I run my labs on an Ubuntu 1604 host using KVM for the hypervisor and some of the network VM images (Cisco CRS1000v, Juniper vMX, etc..) run with very high CPU. A recent thread on Twitter helped me to find a solution to this problem so I will outline it here as it may be helpful for others.

For reference the following software was used in this post.

  • Ubuntu - 1604
  • KVM - 2.5.0

The Question

Tony E @showipintbri asked the following question to the twitterverse regarding running the CSR1000v in eve-ng (which uses KVM as its hypervisor).


The Solution

@Kroupouk666 was kind enough to offer a potential solution which involves setting the KVM halt_poll_ns parameter to 0 .


I run my labs with Vagrant using the libvirt provider and I have been using Vagrant triggers to throttle the CPU of these type of hosts that run with very high CPU. This potential solution, if it works, is much more agreeable so I figured I'd give it a try. First I checked the existing value which was 200000 and apparently the default.

cat /sys/module/kvm/parameters/halt_poll_ns

# output

Next up I changed the value to 0 as suggested.

echo 0 | sudo tee /sys/module/kvm/parameters/halt_poll_ns

# output

Incredibly it worked! I found that on the vMX and CSR1000v the CPU usage went from 100% on 2x CPUs down to around 30% which is a huge improvement. Also there was no need to reboot the host which was a plus. The below illustrates the difference between the before and after CPU usage.





Apparently Cisco provided the solution to @Kroupouk666 as a result of him filing a bug.


Permanent Fix

The change will be lost on reboot, to make the change permanent add an entry to the modprobe config.

echo "options kvm halt_poll_ns=0" | sudo tee --append /etc/modprobe.d/qemu-system-x86.conf

# output
options kvm halt_poll_ns=0


The power of the community helped me to solve an issue that has been bugging me for some time. Thank you very much to @showipintbri for asking the question and @Kroupouk666 for providing the solution.

# linux