Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

softirqs: Combined CPU as part of the key is necessary to avoid amiss… #2804

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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