hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/samples/bpf/cpustat_kern.c
....@@ -3,7 +3,7 @@
33 #include <linux/version.h>
44 #include <linux/ptrace.h>
55 #include <uapi/linux/bpf.h>
6
-#include "bpf_helpers.h"
6
+#include <bpf/bpf_helpers.h>
77
88 /*
99 * The CPU number, cstate number and pstate number are based
....@@ -51,28 +51,28 @@
5151 #define MAP_OFF_PSTATE_IDX 3
5252 #define MAP_OFF_NUM 4
5353
54
-struct bpf_map_def SEC("maps") my_map = {
55
- .type = BPF_MAP_TYPE_ARRAY,
56
- .key_size = sizeof(u32),
57
- .value_size = sizeof(u64),
58
- .max_entries = MAX_CPU * MAP_OFF_NUM,
59
-};
54
+struct {
55
+ __uint(type, BPF_MAP_TYPE_ARRAY);
56
+ __type(key, u32);
57
+ __type(value, u64);
58
+ __uint(max_entries, MAX_CPU * MAP_OFF_NUM);
59
+} my_map SEC(".maps");
6060
6161 /* cstate_duration records duration time for every idle state per CPU */
62
-struct bpf_map_def SEC("maps") cstate_duration = {
63
- .type = BPF_MAP_TYPE_ARRAY,
64
- .key_size = sizeof(u32),
65
- .value_size = sizeof(u64),
66
- .max_entries = MAX_CPU * MAX_CSTATE_ENTRIES,
67
-};
62
+struct {
63
+ __uint(type, BPF_MAP_TYPE_ARRAY);
64
+ __type(key, u32);
65
+ __type(value, u64);
66
+ __uint(max_entries, MAX_CPU * MAX_CSTATE_ENTRIES);
67
+} cstate_duration SEC(".maps");
6868
6969 /* pstate_duration records duration time for every operating point per CPU */
70
-struct bpf_map_def SEC("maps") pstate_duration = {
71
- .type = BPF_MAP_TYPE_ARRAY,
72
- .key_size = sizeof(u32),
73
- .value_size = sizeof(u64),
74
- .max_entries = MAX_CPU * MAX_PSTATE_ENTRIES,
75
-};
70
+struct {
71
+ __uint(type, BPF_MAP_TYPE_ARRAY);
72
+ __type(key, u32);
73
+ __type(value, u64);
74
+ __uint(max_entries, MAX_CPU * MAX_PSTATE_ENTRIES);
75
+} pstate_duration SEC(".maps");
7676
7777 /*
7878 * The trace events for cpu_idle and cpu_frequency are taken from: