0001
0002
0003
0004 #include "vmlinux.h"
0005
0006 #include <bpf/bpf_helpers.h>
0007
0008 __u64 out__runqueues_addr = -1;
0009 __u64 out__bpf_prog_active_addr = -1;
0010
0011 __u32 out__rq_cpu = -1;
0012 int out__bpf_prog_active = -1;
0013
0014 __u32 out__this_rq_cpu = -1;
0015 int out__this_bpf_prog_active = -1;
0016
0017 __u32 out__cpu_0_rq_cpu = -1;
0018
0019 extern const struct rq runqueues __ksym;
0020 extern const int bpf_prog_active __ksym;
0021
0022 SEC("raw_tp/sys_enter")
0023 int handler(const void *ctx)
0024 {
0025 struct rq *rq;
0026 int *active;
0027 __u32 cpu;
0028
0029 out__runqueues_addr = (__u64)&runqueues;
0030 out__bpf_prog_active_addr = (__u64)&bpf_prog_active;
0031
0032 cpu = bpf_get_smp_processor_id();
0033
0034
0035 rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, cpu);
0036 if (rq)
0037 out__rq_cpu = rq->cpu;
0038 active = (int *)bpf_per_cpu_ptr(&bpf_prog_active, cpu);
0039 if (active)
0040 out__bpf_prog_active = *active;
0041
0042 rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, 0);
0043 if (rq)
0044 out__cpu_0_rq_cpu = rq->cpu;
0045
0046
0047 rq = (struct rq *)bpf_this_cpu_ptr(&runqueues);
0048 out__this_rq_cpu = rq->cpu;
0049 active = (int *)bpf_this_cpu_ptr(&bpf_prog_active);
0050 out__this_bpf_prog_active = *active;
0051
0052 return 0;
0053 }
0054
0055 char _license[] SEC("license") = "GPL";