1 .TH kvmexit 8 "2021-07-08" "USER COMMANDS"
3 kvmexit \- Display the exit_reason and its statistics of each vm exit.
5 .B kvmexit [\-h] [\-p PID [\-v VCPU | \-a] ] [\-t TID | \-T 'TID1,TID2'] [duration]
7 Considering virtual machines' frequent exits can cause performance problems,
8 this tool aims to locate the frequent exited reasons and then find solutions
9 to reduce or even avoid the exit, by displaying the detail exit reasons and
10 the counts of each vm exit for all vms running on one physical machine.
12 This tool uses a PERCPU_ARRAY: pcpuArrayA and a percpu_hash: hashA to
13 collaboratively store each kvm exit reason and its count. The reason is there
14 exists a rule when one vcpu exits and re-enters, it tends to continue to run on
15 the same physical cpu as the last cycle, which is also called 'cache hit'. Thus
16 we turn to use a PERCPU_ARRAY to record the 'cache hit' situation to speed
17 things up; and for other cases, then use a percpu_hash.
19 As RAW_TRACEPOINT_PROBE(kvm_exit) consumes less cpu cycles, when this tool is
20 used, it firstly tries to employ raw tracepoints in modules, and if failes,
21 then fall back to regular tracepoint.
23 Limitation: In view of the hardware-assisted virtualization technology of
24 different architectures, currently we only adapt on vmx in intel.
26 Since this uses BPF, only the root user can use this tool.
30 This also requires Linux 4.7+ (BPF_PROG_TYPE_TRACEPOINT support).
37 Display process with this PID only, collpase all tids with exit reasons sorted
41 Display this VCPU only for this PID.
44 Display all TIDS for this PID.
47 Display thread with this TID only with exit reasons sorted in descending order.
50 Display threads for a union like {395490, 395491}.
53 Duration of display, after sleeping several seconds.
56 Display kvm exit reasons and statistics for all threads... Hit Ctrl-C to end:
60 Display kvm exit reasons and statistics for all threads after sleeping 6 secs:
64 Display kvm exit reasons and statistics for PID 1273795 after sleeping 5 secs:
66 .B kvmexit -p 1273795 5
68 Display kvm exit reasons and statistics for PID 1273795 and its all threads after sleeping 5 secs:
70 .B kvmexit -p 1273795 5 -a
72 Display kvm exit reasons and statistics for PID 1273795 VCPU 0... Hit Ctrl-C to end:
74 .B kvmexit -p 1273795 -v 0
76 Display kvm exit reasons and statistics for PID 1273795 VCPU 0 after sleeping 4 secs:
78 .B kvmexit -p 1273795 -v 0 4
80 Display kvm exit reasons and statistics for TID 1273819 after sleeping 10 secs:
82 .B kvmexit -t 1273819 10
84 Display kvm exit reasons and statistics for TIDS ['1273820', '1273819']... Hit Ctrl-C to end:
86 .B kvmexit -T '1273820,1273819'
88 This traces the "kvm_exit" kernel function, records the exit reason and
89 calculates its counts. Contrast with filling more vm-exit reason debug entries,
90 this tool is more easily and flexibly: the bcc python logic could provide nice
91 kernel aggregation and custom output, the bpf in-kernel percpu_array and
92 percpu_cache further improves performance.
94 The impact of using this tool on the host should be negligible. While this
95 tool is very efficient, it does affect the guest virtual machine itself, the
96 average test results on guest vm are as follows:
99 regular TP | 1277 (13% downgrade)
100 RAW TP | 1187 (5% downgrade)
102 Host: echo 1 > /proc/sys/net/core/bpf_jit_enable
106 https://github.com/iovisor/bcc
108 Also look in the bcc distribution for a companion _examples.txt file containing
109 example usage, output, and commentary for this tool.
113 Unstable - in development.
115 Fei Li <lifei.shirley@bytedance.com>