Commit c8b66980 authored by Brenden Blanco's avatar Brenden Blanco

Minor change to task_switch example syntax

Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 20d41cbc
......@@ -162,14 +162,12 @@ from bpf import BPF
from time import sleep
b = BPF(src_file="task_switch.c")
fn = b.load_func("count_sched", BPF.KPROBE)
stats = b.get_table("stats")
BPF.attach_kprobe(fn, "finish_task_switch")
b.attach_kprobe(event="finish_task_switch", fn_name="count_sched")
# generate many schedule events
for i in range(0, 100): sleep(0.01)
for k, v in stats.items():
for k, v in b["stats"].items():
print("task_switch[%5d->%5d]=%u" % (k.prev_pid, k.curr_pid, v.value))
```
[Source code listing](examples/task_switch.py)
......
......@@ -6,11 +6,10 @@ from bpf import BPF
from time import sleep
b = BPF(src_file="task_switch.c")
stats = b.get_table("stats")
b.attach_kprobe(event="finish_task_switch", fn_name="count_sched")
# generate many schedule events
for i in range(0, 100): sleep(0.01)
for k, v in stats.items():
for k, v in b["stats"].items():
print("task_switch[%5d->%5d]=%u" % (k.prev_pid, k.curr_pid, v.value))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment