hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/samples/bpf/spintest_kern.c
....@@ -9,27 +9,28 @@
99 #include <linux/version.h>
1010 #include <uapi/linux/bpf.h>
1111 #include <uapi/linux/perf_event.h>
12
-#include "bpf_helpers.h"
12
+#include <bpf/bpf_helpers.h>
13
+#include <bpf/bpf_tracing.h>
1314
14
-struct bpf_map_def SEC("maps") my_map = {
15
- .type = BPF_MAP_TYPE_HASH,
16
- .key_size = sizeof(long),
17
- .value_size = sizeof(long),
18
- .max_entries = 1024,
19
-};
20
-struct bpf_map_def SEC("maps") my_map2 = {
21
- .type = BPF_MAP_TYPE_PERCPU_HASH,
22
- .key_size = sizeof(long),
23
- .value_size = sizeof(long),
24
- .max_entries = 1024,
25
-};
15
+struct {
16
+ __uint(type, BPF_MAP_TYPE_HASH);
17
+ __type(key, long);
18
+ __type(value, long);
19
+ __uint(max_entries, 1024);
20
+} my_map SEC(".maps");
21
+struct {
22
+ __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
23
+ __uint(key_size, sizeof(long));
24
+ __uint(value_size, sizeof(long));
25
+ __uint(max_entries, 1024);
26
+} my_map2 SEC(".maps");
2627
27
-struct bpf_map_def SEC("maps") stackmap = {
28
- .type = BPF_MAP_TYPE_STACK_TRACE,
29
- .key_size = sizeof(u32),
30
- .value_size = PERF_MAX_STACK_DEPTH * sizeof(u64),
31
- .max_entries = 10000,
32
-};
28
+struct {
29
+ __uint(type, BPF_MAP_TYPE_STACK_TRACE);
30
+ __uint(key_size, sizeof(u32));
31
+ __uint(value_size, PERF_MAX_STACK_DEPTH * sizeof(u64));
32
+ __uint(max_entries, 10000);
33
+} stackmap SEC(".maps");
3334
3435 #define PROG(foo) \
3536 int foo(struct pt_regs *ctx) \