# load BPF program
b = BPF(src_file = "bitehist.c")
b.attach_kprobe(event="blk_start_request", fn_name="do_request")
-dist = b.get_table("dist")
dist_max = 64
# header
text = text[:-1] + "+"
return text
-def print_log2_hist(d, val_type):
+def print_log2_hist(dist, val_type):
idx_max = -1
val_max = 0
for i in range(1, dist_max + 1):
pass; do_exit = 1
print
- print_log2_hist(dist, "kbytes")
+ print_log2_hist(b["dist"], "kbytes")
if do_exit:
exit()
text = text[:-1] + "+"
return text
-def print_log2_hist(d, val_type):
+def print_log2_hist(dist, val_type):
idx_max = -1
val_max = 0
for i in range(1, dist_max + 1):
try:
- val = b["dist"][c_int(i)].value - last[i]
+ val = dist[c_int(i)].value - last[i]
if (val > 0):
idx_max = i
if (val > val_max):
if (low == high):
low -= 1
try:
- val = b["dist"][c_int(i)].value - last[i]
+ val = dist[c_int(i)].value - last[i]
print("%8d -> %-8d : %-8d |%-*s|" % (low, high, val,
stars_max, stars(val, val_max, stars_max)))
- last[i] = b["dist"][c_int(i)].value
+ last[i] = dist[c_int(i)].value
except:
break
# load BPF program
b = BPF(src_file = "pidpersec.c")
b.attach_kprobe(event="sched_fork", fn_name="do_count")
-stats = b.get_table("stats")
# stat indexes
S_COUNT = 1
pass; exit()
print("%s: PIDs/sec: %d" % (strftime("%H:%M:%S"),
- (stats[c_int(S_COUNT)].value - last)))
- last = stats[c_int(S_COUNT)].value
+ (b["stats"][c_int(S_COUNT)].value - last)))
+ last = b["stats"][c_int(S_COUNT)].value
b.attach_kprobe(event="vfs_fsync", fn_name="do_count")
b.attach_kprobe(event="vfs_open", fn_name="do_count")
b.attach_kprobe(event="vfs_create", fn_name="do_count")
-counts = b.get_table("counts")
# header
print("Tracing... Ctrl-C to end.")
pass
print("\n%-16s %-12s %8s" % ("ADDR", "FUNC", "COUNT"))
+counts = b.get_table("counts")
for k, v in sorted(counts.items(), key=lambda counts: counts[1].value):
print("%-16x %-12s %8d" % (k.ip, ksym(k.ip), v.value))
b.attach_kprobe(event="vfs_fsync", fn_name="do_fsync")
b.attach_kprobe(event="vfs_open", fn_name="do_open")
b.attach_kprobe(event="vfs_create", fn_name="do_create")
-stats = b.get_table("stats")
# stat column labels and indexes
stat_types = {
for stype in stat_types.keys():
idx = stat_types[stype]
try:
- delta = stats[c_int(idx)].value - last[idx]
+ delta = b["stats"][c_int(idx)].value - last[idx]
print(" %8d" % (delta / interval), end="")
- last[idx] = stats[c_int(idx)].value
+ last[idx] = b["stats"][c_int(idx)].value
except:
print(" %8d" % 0, end="")
print("")