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