RFC: in-guest CPU tick counters

Robert Crowston crowston at protonmail.com
Wed Jan 1 16:28:40 UTC 2020


I have written a patch that exposes to a sysctl the ticks spent by each CPU executing guest code under bhyve.

This new feature differs from the existing vmm_stats code in that the existing code expresses per-vm information on a per-virtual-cpu basis. This new patch provides a per-physical-cpu counter of the aggregate number of ticks dedicated to executing guest-mode code since the vmm.ko module was loaded. Following the example of kern.cp_times, it is expressed as a new sysctl ("hw.vmm.stat.guest_ticks") rather than a system call, but I am not particularly attached to that.

The diffs may be seen here:
https://github.com/freebsd/freebsd/compare/master...RobCrowston:vmm-host-stats

I am looking for comments. If the general idea meets with this list's approval, I will submit it to phabricator.

The new data are intended to be used by utilities like htop. To that end, I have written a separate patch for htop that colours the CPU bars to express the time spent for guest execution. After re-compiling htop, enable it with F2 ("Setup") -> "Display Options" -> "Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)". Presently, htop only supports this feature for Linux hosts. If the above patch is accepted, I will submit the following patch to htop separately:
https://github.com/hishamhm/htop/compare/master...RobCrowston:freebsd-vmm-counter-1

Happy New Year,
Rob Crowston.


More information about the freebsd-virtualization mailing list