u32 pid;
if (!PT_REGS_RC(ctx))
return 0;
- pid = bpf_get_current_pid_tgid();
+ pid = bpf_get_current_pid_tgid() >> 32;
data.pid = pid;
bpf_probe_read_user(&data.str, sizeof(data.str), (void *)PT_REGS_RC(ctx));
u32 uid = bpf_get_current_uid_gid();
key.ip = PT_REGS_IP(ctx);
- key.pid = pid & 0xFFFFFFFF;
- key.uid = uid & 0xFFFFFFFF;
+ key.pid = pid >> 32;
+ key.uid = uid;
bpf_get_current_comm(&(key.comm), 16);
counts.increment(key);
int trace_fast(struct pt_regs *ctx, struct nameidata *nd, struct path *path)
{
- u32 pid = bpf_get_current_pid_tgid();
+ u32 pid = bpf_get_current_pid_tgid() >> 32;
submit_event(ctx, (void *)nd->last.name, LOOKUP_REFERENCE, pid);
return 1;
}
int kprobe__d_lookup(struct pt_regs *ctx, const struct dentry *parent,
const struct qstr *name)
{
- u32 pid = bpf_get_current_pid_tgid();
+ u32 tid = bpf_get_current_pid_tgid();
struct entry_t entry = {};
const char *fname = name->name;
if (fname) {
bpf_probe_read_kernel(&entry.name, sizeof(entry.name), (void *)fname);
}
- entrybypid.update(&pid, &entry);
+ entrybypid.update(&tid, &entry);
return 0;
}
int kretprobe__d_lookup(struct pt_regs *ctx)
{
- u32 pid = bpf_get_current_pid_tgid();
+ u64 pid_tgid = bpf_get_current_pid_tgid();
+ u32 pid = pid_tgid >> 32;
+ u32 tid = (u32)pid_tgid;
struct entry_t *ep;
- ep = entrybypid.lookup(&pid);
- if (ep == 0 || PT_REGS_RC(ctx) != 0) {
- return 0; // missed entry or lookup didn't fail
+
+ ep = entrybypid.lookup(&tid);
+ if (ep == 0) {
+ return 0; // missed entry
+ }
+ if (PT_REGS_RC(ctx) != 0) {
+ entrybypid.delete(&tid);
+ return 0; // lookup didn't fail
}
+
submit_event(ctx, (void *)ep->name, LOOKUP_MISS, pid);
- entrybypid.delete(&pid);
+ entrybypid.delete(&tid);
return 0;
}
"""
int syscall__kill(struct pt_regs *ctx, int tpid, int sig)
{
- u32 pid = bpf_get_current_pid_tgid();
+ u64 pid_tgid = bpf_get_current_pid_tgid();
+ u32 pid = pid_tgid >> 32;
+ u32 tid = (u32)pid_tgid;
+
PID_FILTER
SIGNAL_FILTER
if (bpf_get_current_comm(&val.comm, sizeof(val.comm)) == 0) {
val.tpid = tpid;
val.sig = sig;
- infotmp.update(&pid, &val);
+ infotmp.update(&tid, &val);
}
return 0;
{
struct data_t data = {};
struct val_t *valp;
- u32 pid = bpf_get_current_pid_tgid();
+ u64 pid_tgid = bpf_get_current_pid_tgid();
+ u32 pid = pid_tgid >> 32;
+ u32 tid = (u32)pid_tgid;
- valp = infotmp.lookup(&pid);
+ valp = infotmp.lookup(&tid);
if (valp == 0) {
// missed entry
return 0;
data.sig = valp->sig;
events.perf_submit(ctx, &data, sizeof(data));
- infotmp.delete(&pid);
+ infotmp.delete(&tid);
return 0;
}
static inline __attribute__((always_inline)) void get_key(struct key_t* key) {
key->cpu = bpf_get_smp_processor_id();
- key->pid = bpf_get_current_pid_tgid();
+ key->pid = bpf_get_current_pid_tgid() >> 32;
bpf_get_current_comm(&(key->name), sizeof(key->name));
}
int kprobe__md_flush_request(struct pt_regs *ctx, void *mddev, struct bio *bio)
{
struct data_t data = {};
- u32 pid = bpf_get_current_pid_tgid();
+ u32 pid = bpf_get_current_pid_tgid() >> 32;
data.pid = pid;
bpf_get_current_comm(&data.comm, sizeof(data.comm));
/*
BPF_PERF_OUTPUT(events);
int do_start(struct pt_regs *ctx) {
- u32 pid = bpf_get_current_pid_tgid();
+ u32 tid = bpf_get_current_pid_tgid();
struct start_t start = {};
start.ts = bpf_ktime_get_ns();
bpf_usdt_readarg(1, ctx, &start.query);
- start_tmp.update(&pid, &start);
+ start_tmp.update(&tid, &start);
return 0;
};
int do_done(struct pt_regs *ctx) {
- u32 pid = bpf_get_current_pid_tgid();
+ u64 pid_tgid = bpf_get_current_pid_tgid();
+ u32 pid = pid_tgid >> 32;
+ u32 tid = (u32)pid_tgid;
struct start_t *sp;
- sp = start_tmp.lookup(&pid);
+ sp = start_tmp.lookup(&tid);
if (sp == 0) {
// missed tracing start
return 0;
events.perf_submit(ctx, &data, sizeof(data));
}
- start_tmp.delete(&pid);
+ start_tmp.delete(&tid);
return 0;
};
BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE);
static int offcpu_sched_switch() {
- u32 pid = bpf_get_current_pid_tgid();
+ u64 pid_tgid = bpf_get_current_pid_tgid();
+ u32 pid = pid_tgid >> 32;
+ u32 tid = (u32)pid_tgid;
struct task_struct *p = (struct task_struct *) bpf_get_current_task();
u64 ts;
return 0;
ts = bpf_ktime_get_ns();
- start.update(&pid, &ts);
+ start.update(&tid, &ts);
return 0;
}
static int wakeup(ARG0, struct task_struct *p) {
- u32 pid = p->pid;
+ u32 pid = p->tgid;
+ u32 tid = p->pid;
u64 delta, *tsp, ts;
- tsp = start.lookup(&pid);
+ tsp = start.lookup(&tid);
if (tsp == 0)
return 0; // missed start
- start.delete(&pid);
+ start.delete(&tid);
if (FILTER)
return 0;