Page MenuHomeFreeBSD

vmm: Expose per-cpu guest time counters in a new sysctl
Needs ReviewPublic

Authored by on Jan 3 2020, 3:42 PM.


Group Reviewers

Many system monitoring tools, such as htop, can express the CPU time spent by the system in the execution of virtual machine guests. To facilitate such metrics on FreeBSD, I add a new performance counter in the vmm subsystem and expose it through a new sysctl, hw.vmm.stat. Access to this sysctl is restricted by a new privilege, PRIV_VMM_HOST_STAT.

(This 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.)

Test Plan

Tested over several days on my AMD64 machine. There is an accompanying patch to htop which allows these counters to be tested:

Diff Detail

Lint OK
No Unit Test Coverage
Build Status
Buildable 28465
Build 26529: arc lint + arc unit

Event Timeline edited the summary of this revision. (Show Details)Jan 3 2020, 3:44 PM edited the test plan for this revision. (Show Details) edited the summary of this revision. (Show Details)Jan 3 2020, 3:52 PM
  • vmm: Accesses to guest_counters pointer itself need not be atomic.

This was a hold-over from an earlier design where the guest counters were lazily initialized on first use.