blob: 870e35fdc44079d48505835c9f94c15236a0debf [file] [log] [blame]
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -07001#include <uapi/linux/ptrace.h>
2#include <linux/sched.h>
3
4struct key_t {
5 u32 prev_pid;
6 u32 curr_pid;
7};
8// map_type, key_type, leaf_type, table_name, num_entry
9BPF_TABLE("hash", struct key_t, u64, stats, 1024);
Brenden Blancob711d452015-07-01 15:23:18 -070010int count_sched(struct pt_regs *ctx, struct task_struct *prev) {
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -070011 struct key_t key = {};
12 u64 zero = 0, *val;
13
14 key.curr_pid = bpf_get_current_pid_tgid();
Brenden Blancob711d452015-07-01 15:23:18 -070015 key.prev_pid = prev->pid;
Alexei Starovoitovb6e43a22015-06-18 14:41:17 -070016
17 val = stats.lookup_or_init(&key, &zero);
18 (*val)++;
19 return 0;
20}
21