blob: f25913f147465b15e5b292b563986a87612eecf7 [file] [log] [blame]
#!/usr/bin/python
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
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")
# generate many schedule events
for i in range(0, 100): sleep(0.01)
for k, v in stats.items():
print("task_switch[%5d->%5d]=%u" % (k.prev_pid, k.curr_pid, v.value))