.. | .. |
---|
3 | 3 | #include <linux/version.h> |
---|
4 | 4 | #include <linux/ptrace.h> |
---|
5 | 5 | #include <uapi/linux/bpf.h> |
---|
6 | | -#include "bpf_helpers.h" |
---|
| 6 | +#include <bpf/bpf_helpers.h> |
---|
7 | 7 | |
---|
8 | 8 | /* |
---|
9 | 9 | * The CPU number, cstate number and pstate number are based |
---|
.. | .. |
---|
51 | 51 | #define MAP_OFF_PSTATE_IDX 3 |
---|
52 | 52 | #define MAP_OFF_NUM 4 |
---|
53 | 53 | |
---|
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"); |
---|
60 | 60 | |
---|
61 | 61 | /* 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"); |
---|
68 | 68 | |
---|
69 | 69 | /* 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"); |
---|
76 | 76 | |
---|
77 | 77 | /* |
---|
78 | 78 | * The trace events for cpu_idle and cpu_frequency are taken from: |
---|