Skip to content

Commit

Permalink
removed two bpf_hash args_pid/sig
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaleavya committed Feb 19, 2016
1 parent 053ce87 commit 6262f5d
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions tools/killsnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
struct val_t {
u64 pid;
u64 ts;
int sig;
int tpid;
char comm[TASK_COMM_LEN];
};
Expand All @@ -58,8 +60,6 @@
char comm[TASK_COMM_LEN];
};
BPF_HASH(args_pid, u32, int);
BPF_HASH(args_sig, u32, int);
BPF_HASH(infotmp, u32, struct val_t);
BPF_PERF_OUTPUT(events);
Expand All @@ -72,10 +72,10 @@
if (bpf_get_current_comm(&val.comm, sizeof(val.comm)) == 0) {
val.pid = bpf_get_current_pid_tgid();
val.ts = bpf_ktime_get_ns();
val.tpid = tpid;
val.sig = sig;
infotmp.update(&pid, &val);
}
args_pid.update(&pid, &tpid);
args_sig.update(&pid, &sig);
return 0;
};
Expand All @@ -84,16 +84,9 @@
{
struct data_t data = {};
struct val_t *valp;
int *tpidp, *sigp;
u32 pid = bpf_get_current_pid_tgid();
u64 tsp = bpf_ktime_get_ns();
tpidp = args_pid.lookup(&pid);
sigp = args_sig.lookup(&pid);
if (tpidp == 0 || sigp == 0) {
return 0; // missed entry
}
valp = infotmp.lookup(&pid);
if (valp == 0) {
// missed entry
Expand All @@ -104,14 +97,12 @@
data.pid = pid;
data.delta = tsp - valp->ts;
data.ts = tsp / 1000;
data.tpid = *tpidp;
data.tpid = valp->tpid;
data.ret = ctx->ax;
data.sig = *sigp;
data.sig = valp->sig;
events.perf_submit(ctx, &data, sizeof(data));
infotmp.delete(&pid);
args_pid.delete(&pid);
args_sig.delete(&pid);
return 0;
}
Expand Down

0 comments on commit 6262f5d

Please sign in to comment.