0001
0002
0003 #include <linux/bpf.h>
0004 #include <bpf/bpf_helpers.h>
0005 #include <bpf/bpf_tracing.h>
0006
0007 struct {
0008 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
0009 __uint(max_entries, 1);
0010 __type(key, int);
0011 __type(value, int);
0012 } array_1 SEC(".maps");
0013
0014 struct {
0015 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
0016 __uint(max_entries, 1);
0017 __type(key, int);
0018 __type(value, int);
0019 __uint(map_flags, BPF_F_PRESERVE_ELEMS);
0020 } array_2 SEC(".maps");
0021
0022 SEC("raw_tp/sched_switch")
0023 int BPF_PROG(read_array_1)
0024 {
0025 struct bpf_perf_event_value val;
0026
0027 return bpf_perf_event_read_value(&array_1, 0, &val, sizeof(val));
0028 }
0029
0030 SEC("raw_tp/task_rename")
0031 int BPF_PROG(read_array_2)
0032 {
0033 struct bpf_perf_event_value val;
0034
0035 return bpf_perf_event_read_value(&array_2, 0, &val, sizeof(val));
0036 }
0037
0038 char LICENSE[] SEC("license") = "GPL";