Skip to content

Commit

Permalink
Merge pull request iovisor#2804 from netedwardwu/master
Browse files Browse the repository at this point in the history
softirqs: Combined CPU as part of the key is necessary to avoid amiss…
  • Loading branch information
yonghong-song committed Mar 9, 2020
2 parents 8b6a7db + 9465f8c commit 57e7af7
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tools/softirqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
bpf_text = """
#include <uapi/linux/ptrace.h>
typedef struct entry_key {
u32 pid;
u32 cpu;
} entry_key_t;
typedef struct irq_key {
u32 vec;
u64 slot;
Expand All @@ -64,30 +69,38 @@
u32 vec;
} account_val_t;
BPF_HASH(start, u32, account_val_t);
BPF_HASH(start, entry_key_t, account_val_t);
BPF_HASH(iptr, u32);
BPF_HISTOGRAM(dist, irq_key_t);
TRACEPOINT_PROBE(irq, softirq_entry)
{
u32 pid = bpf_get_current_pid_tgid();
account_val_t val = {};
entry_key_t key = {};
key.pid = bpf_get_current_pid_tgid();
key.cpu = bpf_get_smp_processor_id();
val.ts = bpf_ktime_get_ns();
val.vec = args->vec;
start.update(&pid, &val);
start.update(&key, &val);
return 0;
}
TRACEPOINT_PROBE(irq, softirq_exit)
{
u64 delta;
u32 vec;
u32 pid = bpf_get_current_pid_tgid();
account_val_t *valp;
irq_key_t key = {0};
entry_key_t entry_key = {};
entry_key.pid = bpf_get_current_pid_tgid();
entry_key.cpu = bpf_get_smp_processor_id();
// fetch timestamp and calculate delta
valp = start.lookup(&pid);
valp = start.lookup(&entry_key);
if (valp == 0) {
return 0; // missed start
}
Expand All @@ -97,7 +110,7 @@
// store as sum or histogram
STORE
start.delete(&pid);
start.delete(&entry_key);
return 0;
}
"""
Expand Down

0 comments on commit 57e7af7

Please sign in to comment.