1 /* Copyright (c) 2016 Facebook
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
8 #include <linux/version.h>
9 #include <bpf/bpf_helpers.h>
10 #include <bpf/bpf_tracing.h>
11 #include <bpf/bpf_core_read.h>
13 SEC("kprobe/__set_task_comm")
14 int prog(struct pt_regs *ctx)
16 struct signal_struct *signal;
17 struct task_struct *tsk;
18 char oldcomm[TASK_COMM_LEN] = {};
19 char newcomm[TASK_COMM_LEN] = {};
23 tsk = (void *)PT_REGS_PARM1_CORE(ctx);
25 pid = BPF_CORE_READ(tsk, pid);
26 bpf_core_read_str(oldcomm, sizeof(oldcomm), &tsk->comm);
27 bpf_core_read_str(newcomm, sizeof(newcomm),
28 (void *)PT_REGS_PARM2(ctx));
29 signal = BPF_CORE_READ(tsk, signal);
30 oom_score_adj = BPF_CORE_READ(signal, oom_score_adj);
34 SEC("kprobe/fib_table_lookup")
35 int prog2(struct pt_regs *ctx)
40 char _license[] SEC("license") = "GPL";
41 u32 _version SEC("version") = LINUX_VERSION_CODE;