hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/samples/bpf/trace_event_kern.c
....@@ -9,7 +9,8 @@
99 #include <uapi/linux/bpf.h>
1010 #include <uapi/linux/bpf_perf_event.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
1415 struct key_t {
1516 char comm[TASK_COMM_LEN];
....@@ -17,19 +18,19 @@
1718 u32 userstack;
1819 };
1920
20
-struct bpf_map_def SEC("maps") counts = {
21
- .type = BPF_MAP_TYPE_HASH,
22
- .key_size = sizeof(struct key_t),
23
- .value_size = sizeof(u64),
24
- .max_entries = 10000,
25
-};
21
+struct {
22
+ __uint(type, BPF_MAP_TYPE_HASH);
23
+ __type(key, struct key_t);
24
+ __type(value, u64);
25
+ __uint(max_entries, 10000);
26
+} counts 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 KERN_STACKID_FLAGS (0 | BPF_F_FAST_STACK_CMP)
3536 #define USER_STACKID_FLAGS (0 | BPF_F_FAST_STACK_CMP | BPF_F_USER_STACK)