WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_pe_preserve_elems.c
blobfb22de7c365d4c1fea8ae9cc58e2d740a7d02eaf
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
7 struct {
8 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
9 __uint(max_entries, 1);
10 __uint(key_size, sizeof(int));
11 __uint(value_size, sizeof(int));
12 } array_1 SEC(".maps");
14 struct {
15 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
16 __uint(max_entries, 1);
17 __uint(key_size, sizeof(int));
18 __uint(value_size, sizeof(int));
19 __uint(map_flags, BPF_F_PRESERVE_ELEMS);
20 } array_2 SEC(".maps");
22 SEC("raw_tp/sched_switch")
23 int BPF_PROG(read_array_1)
25 struct bpf_perf_event_value val;
27 return bpf_perf_event_read_value(&array_1, 0, &val, sizeof(val));
30 SEC("raw_tp/task_rename")
31 int BPF_PROG(read_array_2)
33 struct bpf_perf_event_value val;
35 return bpf_perf_event_read_value(&array_2, 0, &val, sizeof(val));
38 char LICENSE[] SEC("license") = "GPL";