Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvm_vmexit_slower python syntax error #1

Open
hrgstephen opened this issue Mar 6, 2020 · 1 comment
Open

kvm_vmexit_slower python syntax error #1

hrgstephen opened this issue Mar 6, 2020 · 1 comment

Comments

@hrgstephen
Copy link

hrgstephen commented Mar 6, 2020

Hi, I encounterd two problems

linux kernel is 4.9
Python 2.7.5 (default, Sep 5 2018, 11:36:03)

problem1:

$sudo ./kvm_vmexit_slower.py
bpf: Failed to load program: Permission denied
0: (bf) r6 = r1
1: (85) call 14
2: (7b) *(u64 *)(r10 -8) = r0
3: (18) r1 = 0xffff886792397b00
5: (bf) r2 = r10
6: (07) r2 += -8
7: (85) call 1
8: (bf) r7 = r0
9: (15) if r7 == 0x0 goto pc+14
R0=map_value(ks=8,vs=16,id=0),min_value=0,max_value=0 R6=ctx R7=map_value(ks=8,vs=16,id=0),min_value=0,max_value=0 R10=fp
10: (85) call 5
11: (79) r1 = *(u64 *)(r7 +0)
12: (1f) r0 -= r1
13: (7b) *(u64 *)(r7 +0) = r0
14: (b7) r1 = 10000000
15: (2d) if r1 > r0 goto pc+8
R0=inv,min_value=10000000 R1=imm10000000,min_value=10000000,max_value=10000000 R6=ctx R7=map_value(ks=8,vs=16,id=0),min_value=0,max_value=0 R10=fp
16: (18) r2 = 0xffff884e22741800
18: (bf) r1 = r6
19: (18) r3 = 0xffffffff
21: (bf) r4 = r7
22: (b7) r5 = 16
23: (85) call 25
R4 type=map_value expected=fp

Traceback (most recent call last):
File "./kvm_vmexit_slower.py", line 88, in
fire.Fire(main)
File "/usr/lib/python2.7/site-packages/fire/core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/usr/lib/python2.7/site-packages/fire/core.py", line 471, in _Fire
target=component.name)
File "/usr/lib/python2.7/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "./kvm_vmexit_slower.py", line 75, in main
b = BPF(text=text)
File "/usr/lib/python2.7/site-packages/bcc/init.py", line 355, in init
self._trace_autoload()
File "/usr/lib/python2.7/site-packages/bcc/init.py", line 1118, in _trace_autoload
fn = self.load_func(func_name, BPF.TRACEPOINT)
File "/usr/lib/python2.7/site-packages/bcc/init.py", line 395, in load_func
(func_name, errstr))
Exception: Failed to load BPF program tracepoint__kvm__kvm_entry: Permission denied

problem2:

$sudo ./kvm_vmexit_slower.py 10 --excludes=12
Traceback (most recent call last):
File "./kvm_vmexit_slower.py", line 88, in
fire.Fire(main)
File "/usr/lib/python2.7/site-packages/fire/core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/usr/lib/python2.7/site-packages/fire/core.py", line 471, in _Fire
target=component.name)
File "/usr/lib/python2.7/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "./kvm_vmexit_slower.py", line 61, in main
if len(excludes) > 0:
TypeError: object of type 'int' has no len()

@mmisono
Copy link
Owner

mmisono commented Mar 6, 2020

Hi,
As of problem2, it is fixed for now (05f8c0c).
As of problem1, the error reason is bpf_perf_event_output() does not accept a bpf map value as an argument. This is changed since Linux 4.11.
So, the solution is upgrading the kernel, or, I don't try it but the following might work:

diff --git a/kvm_vmexit_slower.py b/kvm_vmexit_slower.py
index 5c9fad9..7ad30b9 100755
--- a/kvm_vmexit_slower.py
+++ b/kvm_vmexit_slower.py
@@ -47,7 +47,8 @@ TRACEPOINT_PROBE(kvm, kvm_entry) {
     if (st != 0){
         st->time = bpf_ktime_get_ns() - st->time;
         if(st->time >= THRESH){
-            events.perf_submit(args, st, sizeof(struct data));
+            struct data st2 = *st;
+            events.perf_submit(args, &st2, sizeof(struct data));
         }
     }
     return 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants