hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/samples/bpf/lathist_kern.c
....@@ -8,7 +8,7 @@
88 #include <linux/version.h>
99 #include <linux/ptrace.h>
1010 #include <uapi/linux/bpf.h>
11
-#include "bpf_helpers.h"
11
+#include <bpf/bpf_helpers.h>
1212
1313 #define MAX_ENTRIES 20
1414 #define MAX_CPU 4
....@@ -18,12 +18,12 @@
1818 * trace_preempt_[on|off] tracepoints hooks is not supported.
1919 */
2020
21
-struct bpf_map_def SEC("maps") my_map = {
22
- .type = BPF_MAP_TYPE_ARRAY,
23
- .key_size = sizeof(int),
24
- .value_size = sizeof(u64),
25
- .max_entries = MAX_CPU,
26
-};
21
+struct {
22
+ __uint(type, BPF_MAP_TYPE_ARRAY);
23
+ __type(key, int);
24
+ __type(value, u64);
25
+ __uint(max_entries, MAX_CPU);
26
+} my_map SEC(".maps");
2727
2828 SEC("kprobe/trace_preempt_off")
2929 int bpf_prog1(struct pt_regs *ctx)
....@@ -61,12 +61,12 @@
6161 return log2(v);
6262 }
6363
64
-struct bpf_map_def SEC("maps") my_lat = {
65
- .type = BPF_MAP_TYPE_ARRAY,
66
- .key_size = sizeof(int),
67
- .value_size = sizeof(long),
68
- .max_entries = MAX_CPU * MAX_ENTRIES,
69
-};
64
+struct {
65
+ __uint(type, BPF_MAP_TYPE_ARRAY);
66
+ __type(key, int);
67
+ __type(value, long);
68
+ __uint(max_entries, MAX_CPU * MAX_ENTRIES);
69
+} my_lat SEC(".maps");
7070
7171 SEC("kprobe/trace_preempt_on")
7272 int bpf_prog2(struct pt_regs *ctx)