Minor change to task_switch example syntax
authorBrenden Blanco <bblanco@plumgrid.com>
Sat, 29 Aug 2015 06:15:19 +0000 (23:15 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Sat, 29 Aug 2015 06:15:19 +0000 (23:15 -0700)
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
README.md
examples/task_switch.py

index 29c74d0..6345134 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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)
index 9eb4811..c42d637 100755 (executable)
@@ -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))