Skip to content

Commit

Permalink
Merge pull request iovisor#2568 from TristanCacqueray/master
Browse files Browse the repository at this point in the history
cpudist: create sufficiently large hash table to avoid missing tasks
  • Loading branch information
brendangregg authored Nov 1, 2019
2 parents 58ff1b3 + 9b433f2 commit d8381fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/cpudist.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
} pid_key_t;
BPF_HASH(start, u32, u64);
BPF_HASH(start, u32, u64, MAX_PID);
STORAGE
static inline void store_start(u32 tgid, u32 pid, u64 ts)
Expand Down Expand Up @@ -142,7 +142,7 @@
pid = "pid"
section = "tid"
bpf_text = bpf_text.replace('STORAGE',
'BPF_HISTOGRAM(dist, pid_key_t);')
'BPF_HISTOGRAM(dist, pid_key_t, MAX_PID);')
bpf_text = bpf_text.replace('STORE',
'pid_key_t key = {.id = ' + pid + ', .slot = bpf_log2l(delta)}; ' +
'dist.increment(key);')
Expand All @@ -156,7 +156,9 @@
if args.ebpf:
exit()

b = BPF(text=bpf_text)
max_pid = int(open("/proc/sys/kernel/pid_max").read())

b = BPF(text=bpf_text, cflags=["-DMAX_PID=%d" % max_pid])
b.attach_kprobe(event="finish_task_switch", fn_name="sched_switch")

print("Tracing %s-CPU time... Hit Ctrl-C to end." %
Expand Down

0 comments on commit d8381fb

Please sign in to comment.