kvmexit(8)
π kvmexit(8) π
kvmexit(8) is from the System Manager's Manual, and it's giving main character energy π β¨
β¨ NAME β¨
kvmexit - Display the exit_reason and its statistics of each vm exit. π¦
π SYNOPSIS π
kvmexit [-h] [-p PID [-v VCPU | -a] ] [-t TID | -T 'TID1,TID2']
[duration]
πΈ DESCRIPTION πΈ
okay so bestie, frequent VM exits can absolutely tank performance π This tool helps you figure out which exit reasons are showing up the most, so you can go hunting for fixes that reduce or even avoid them. It shows the detailed exit reasons and the count of each VM exit for every VM running on one physical machine π
Under the hood, it uses a PERCPU_ARRAY called pcpuArrayA and a percpu_hash called hashA to team up and store each kvm exit reason along with its count. Here's the tea: when a vcpu exits and then re-enters, it usually keeps running on the same physical cpu it used last cycle. That's called a 'cache hit' π§ So the PERCPU_ARRAY tracks the 'cache hit' situation to keep things speedy, and everything else goes into the percpu_hash π₯
RAW_TRACEPOINT_PROBE(kvm_exit) uses fewer cpu cycles, so when you run this tool it tries raw tracepoints in modules first. If that fails, it falls back to a regular tracepoint π
β οΈ Limitation: Every architecture has its own hardware-assisted virtualization tech, so right now this only works with vmx on Intel. Not for everyone yet, bestie π«Ά
π Since this uses BPF, only the root user can use this tool. No root, no tool, no cap.
π REQUIREMENTS π
CONFIG_BPFand bcc. π- Linux 4.7+ (
BPF_PROG_TYPE_TRACEPOINTsupport) is also required. β¨
β¨ OPTIONS β¨
-hβ Prints the usage message. π-p PIDβ Shows only the process with this PID, collapses all tids together, and sorts the exit reasons in descending order. π-v VCPUβ Shows only this VCPU for this PID. π¦-a ALLTIDSβ Shows all TIDS for this PID. πΈ-t TIDβ Shows only the thread with this TID, with exit reasons sorted in descending order. π§-T 'TID1,TID2'β Shows threads for a union like{395490, 395491}. π- duration β How long to display, after sleeping for several seconds. β
π EXAMPLES π
Display kvm exit reasons and statistics for all threads. Hit Ctrl-C to end it, bestie π
# kvmexit
Display kvm exit reasons and statistics for all threads after sleeping 6 secs:
# kvmexit 6
Display kvm exit reasons and statistics for PID 1273795 after sleeping 5 secs:
# kvmexit -p 1273795 5
Display kvm exit reasons and statistics for PID 1273795 and all of its threads after sleeping 5 secs:
# kvmexit -p 1273795 5 -a
Display kvm exit reasons and statistics for PID 1273795 VCPU 0. Hit Ctrl-C to end it π«Ά
# kvmexit -p 1273795 -v 0
Display kvm exit reasons and statistics for PID 1273795 VCPU 0 after sleeping 4 secs:
# kvmexit -p 1273795 -v 0 4
Display kvm exit reasons and statistics for TID 1273819 after sleeping 10 secs:
# kvmexit -t 1273819 10
Display kvm exit reasons and statistics for TIDS ['1273820', '1273819']. Hit Ctrl-C to end it π
# kvmexit -T '1273820,1273819'
π₯ OVERHEAD π₯
This traces the "kvm_exit" kernel function, records the exit reason, and calculates its counts. Compared to filling in more vm-exit reason debug entries, this one is way easier and more flexible π§ The bcc python logic gives you nice kernel aggregation and custom output, and the bpf in-kernel percpu_array and percpu_cache make it even faster π
The impact on the host should be negligible β¨ This tool is super efficient, but it does affect the guest virtual machine itself. Here are the average test results on the guest vm:
| cpu cycles
no TP | 1127
regular TP | 1277 (13% downgrade)
RAW TP | 1187 (5% downgrade)
Host setup: echo 1 > /proc/sys/net/core/bpf_jit_enable π
π SOURCE π
This is from bcc. π¦
https://github.com/iovisor/bcc
Also check the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool π
π» OS π»
Linux π§
β STABILITY β
Unstable - in development. Still cooking, bestie π
π«Ά AUTHOR π«Ά
Fei Li <lifei.shirley@bytedance.com> π
And that's the whole page, bestie π It's filed under USER COMMANDS and was last updated 2021-07-08. Slay forever β¨π
π¦ where this page comes from
- debian bookworm: bpfcc-tools 0.26.0+ds-1 Β· Apache-2.0
- debian trixie: bpfcc-tools 0.31.0+ds-7 Β· Apache-2.0
- ubuntu noble: bpfcc-tools 0.29.1+ds-1ubuntu7 Β· Apache-2.0
- ubuntu questing: bpfcc-tools 0.31.0+ds-7ubuntu2 Β· Apache-2.0
- ubuntu resolute: bpfcc-tools 0.35.0+ds-1ubuntu2 Β· Apache-2.0
- ubuntu stonking: bpfcc-tools 0.35.0+ds-1ubuntu4 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms