1kvmexit(8)                  System Manager's Manual                 kvmexit(8)
2
3
4

NAME

6       kvmexit - Display the exit_reason and its statistics of each vm exit.
7

SYNOPSIS

9       kvmexit  [-h] [-p PID [-v VCPU | -a] ] [-t TID | -T 'TID1,TID2'] [dura‐
10       tion]
11

DESCRIPTION

13       Considering virtual machines'  frequent  exits  can  cause  performance
14       problems, this tool aims to locate the frequent exited reasons and then
15       find solutions to reduce or even avoid the exit, by displaying the  de‐
16       tail exit reasons and the counts of each vm exit for all vms running on
17       one physical machine.
18
19       This tool uses a PERCPU_ARRAY: pcpuArrayA and a percpu_hash:  hashA  to
20       collaboratively store each kvm exit reason and its count. The reason is
21       there exists a rule when one vcpu exits and re-enters, it tends to con‐
22       tinue  to run on the same physical cpu as the last cycle, which is also
23       called 'cache hit'. Thus we turn to use a PERCPU_ARRAY  to  record  the
24       'cache hit' situation to speed things up; and for other cases, then use
25       a percpu_hash.
26
27       As RAW_TRACEPOINT_PROBE(kvm_exit) consumes less cpu cycles,  when  this
28       tool  is  used,  it firstly tries to employ raw tracepoints in modules,
29       and if failes, then fall back to regular tracepoint.
30
31       Limitation: In view of the hardware-assisted virtualization  technology
32       of different architectures, currently we only adapt on vmx in intel.
33
34       Since this uses BPF, only the root user can use this tool.
35

REQUIREMENTS

37       CONFIG_BPF and bcc.
38
39       This also requires Linux 4.7+ (BPF_PROG_TYPE_TRACEPOINT support).
40

OPTIONS

42       -h     Print usage message.
43
44       -p PID Display  process with this PID only, collpase all tids with exit
45              reasons sorted in descending order.
46
47       -v VCPU
48              Display this VCPU only for this PID.
49
50       -a ALLTIDS
51              Display all TIDS for this PID.
52
53       -t TID Display thread with this TID only with exit  reasons  sorted  in
54              descending order.
55
56       -T 'TID1,TID2'
57              Display threads for a union like {395490, 395491}.
58
59       duration
60              Duration of display, after sleeping several seconds.
61

EXAMPLES

63       Display  kvm  exit reasons and statistics for all threads... Hit Ctrl-C
64       to end:
65              # kvmexit
66
67       Display kvm exit reasons and statistics for all threads after  sleeping
68       6 secs:
69              # kvmexit 6
70
71       Display  kvm exit reasons and statistics for PID 1273795 after sleeping
72       5 secs:
73              # kvmexit -p 1273795 5
74
75       Display kvm exit reasons and statistics for PID  1273795  and  its  all
76       threads after sleeping 5 secs:
77              # kvmexit -p 1273795 5 -a
78
79       Display  kvm  exit reasons and statistics for PID 1273795 VCPU 0... Hit
80       Ctrl-C to end:
81              # kvmexit -p 1273795 -v 0
82
83       Display kvm exit reasons and statistics for PID 1273795  VCPU  0  after
84       sleeping 4 secs:
85              # kvmexit -p 1273795 -v 0 4
86
87       Display  kvm exit reasons and statistics for TID 1273819 after sleeping
88       10 secs:
89              # kvmexit -t 1273819 10
90
91       Display  kvm  exit  reasons  and  statistics   for   TIDS   ['1273820',
92       '1273819']... Hit Ctrl-C to end:
93              # kvmexit -T '1273820,1273819'
94

OVERHEAD

96       This traces the "kvm_exit" kernel function, records the exit reason and
97       calculates its counts. Contrast with filling more vm-exit reason  debug
98       entries,  this  tool  is more easily and flexibly: the bcc python logic
99       could provide nice kernel aggregation and custom output,  the  bpf  in-
100       kernel percpu_array and percpu_cache further improves performance.
101
102       The  impact  of using this tool on the host should be negligible. While
103       this tool is very efficient, it does affect the guest  virtual  machine
104       itself, the average test results on guest vm are as follows:
105                      | cpu cycles
106           no TP      |   1127
107           regular TP |   1277 (13% downgrade)
108           RAW TP     |   1187 (5% downgrade)
109
110       Host: echo 1 > /proc/sys/net/core/bpf_jit_enable
111

SOURCE

113       This is from bcc.
114
115              https://github.com/iovisor/bcc
116
117       Also  look  in  the bcc distribution for a companion _examples.txt file
118       containing example usage, output, and commentary for this tool.
119

OS

121       Linux
122

STABILITY

124       Unstable - in development.
125

AUTHOR

127       Fei Li <lifei.shirley@bytedance.com>
128
129
130
131USER COMMANDS                     2021-07-08                        kvmexit(8)
Impressum