Skip to content

Commit 8f3b2db

Browse files
chenhengqiyonghong-song
authored andcommitted
kvmexit: Don't use raw tracepoint
The kvm_exit tracepoint has the following proto ([0]): TP_PROTO(struct kvm_vcpu *vcpu, u32 isa) So for raw tracepoint, the first arg is a pointer to kvm_vcpu, not exit_reason. The exit_reason is hidden inside struct vcpu_vmx for Intel CPU (or struct vcpu_svm for AMD CPU). Both structs are not part of the UAPI, so it's hard to extract exit_reason. Let's always use the kvm_exit tracepoint instead. [0]: https://github.com/torvalds/linux/blob/1ef6663a587b/arch/x86/kvm/trace.h#L296 Signed-off-by: Hengqi Chen <[email protected]>
1 parent 02daf8d commit 8f3b2db

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

tools/kvmexit.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def valid_args_list(args):
9696
};
9797
BPF_PERCPU_ARRAY(pcpu_cache, struct cache_info, 1);
9898
99-
FUNC_ENTRY {
99+
TRACEPOINT_PROBE(kvm, kvm_exit) {
100100
int cache_miss = 0;
101101
int zero = 0;
102-
u32 er = GET_ER;
102+
u32 er = args->exit_reason;
103103
if (er >= REASON_NUM) {
104104
return 0;
105105
}
@@ -256,19 +256,6 @@ def valid_args_list(args):
256256
except Exception as e:
257257
raise Exception("Failed to do precondition check, due to: %s." % e)
258258

259-
try:
260-
if BPF.support_raw_tracepoint_in_module():
261-
# Let's firstly try raw_tracepoint_in_module
262-
func_entry = "RAW_TRACEPOINT_PROBE(kvm_exit)"
263-
get_er = "ctx->args[0]"
264-
else:
265-
# If raw_tp_in_module is not supported, fall back to regular tp
266-
func_entry = "TRACEPOINT_PROBE(kvm, kvm_exit)"
267-
get_er = "args->exit_reason"
268-
except Exception as e:
269-
raise Exception("Failed to catch kvm exit reasons due to: %s" % e)
270-
271-
272259
def find_tid(tgt_dir, tgt_vcpu):
273260
for tid in os.listdir(tgt_dir):
274261
path = tgt_dir + "/" + tid + "/comm"
@@ -309,10 +296,6 @@ def find_tid(tgt_dir, tgt_vcpu):
309296
thread_filter = '0'
310297
header_format = "PID TID "
311298
bpf_text = bpf_text.replace('THREAD_FILTER', thread_filter)
312-
313-
# For kernel >= 5.0, use RAW_TRACEPOINT_MODULE for performance consideration
314-
bpf_text = bpf_text.replace('FUNC_ENTRY', func_entry)
315-
bpf_text = bpf_text.replace('GET_ER', get_er)
316299
b = BPF(text=bpf_text)
317300

318301

0 commit comments

Comments
 (0)