.. | .. |
---|
5 | 5 | * License as published by the Free Software Foundation. |
---|
6 | 6 | */ |
---|
7 | 7 | #include <uapi/linux/bpf.h> |
---|
8 | | -#include "bpf_helpers.h" |
---|
9 | 8 | #include <uapi/linux/ptrace.h> |
---|
10 | 9 | #include <uapi/linux/perf_event.h> |
---|
11 | 10 | #include <linux/version.h> |
---|
12 | 11 | #include <linux/sched.h> |
---|
| 12 | +#include <bpf/bpf_helpers.h> |
---|
| 13 | +#include <bpf/bpf_tracing.h> |
---|
13 | 14 | |
---|
14 | | -#define _(P) ({typeof(P) val; bpf_probe_read(&val, sizeof(val), &P); val;}) |
---|
| 15 | +#define _(P) \ |
---|
| 16 | + ({ \ |
---|
| 17 | + typeof(P) val; \ |
---|
| 18 | + bpf_probe_read_kernel(&val, sizeof(val), &(P)); \ |
---|
| 19 | + val; \ |
---|
| 20 | + }) |
---|
15 | 21 | |
---|
16 | 22 | #define MINBLOCK_US 1 |
---|
17 | 23 | |
---|
.. | .. |
---|
22 | 28 | u32 tret; |
---|
23 | 29 | }; |
---|
24 | 30 | |
---|
25 | | -struct bpf_map_def SEC("maps") counts = { |
---|
26 | | - .type = BPF_MAP_TYPE_HASH, |
---|
27 | | - .key_size = sizeof(struct key_t), |
---|
28 | | - .value_size = sizeof(u64), |
---|
29 | | - .max_entries = 10000, |
---|
30 | | -}; |
---|
| 31 | +struct { |
---|
| 32 | + __uint(type, BPF_MAP_TYPE_HASH); |
---|
| 33 | + __type(key, struct key_t); |
---|
| 34 | + __type(value, u64); |
---|
| 35 | + __uint(max_entries, 10000); |
---|
| 36 | +} counts SEC(".maps"); |
---|
31 | 37 | |
---|
32 | | -struct bpf_map_def SEC("maps") start = { |
---|
33 | | - .type = BPF_MAP_TYPE_HASH, |
---|
34 | | - .key_size = sizeof(u32), |
---|
35 | | - .value_size = sizeof(u64), |
---|
36 | | - .max_entries = 10000, |
---|
37 | | -}; |
---|
| 38 | +struct { |
---|
| 39 | + __uint(type, BPF_MAP_TYPE_HASH); |
---|
| 40 | + __type(key, u32); |
---|
| 41 | + __type(value, u64); |
---|
| 42 | + __uint(max_entries, 10000); |
---|
| 43 | +} start SEC(".maps"); |
---|
38 | 44 | |
---|
39 | 45 | struct wokeby_t { |
---|
40 | 46 | char name[TASK_COMM_LEN]; |
---|
41 | 47 | u32 ret; |
---|
42 | 48 | }; |
---|
43 | 49 | |
---|
44 | | -struct bpf_map_def SEC("maps") wokeby = { |
---|
45 | | - .type = BPF_MAP_TYPE_HASH, |
---|
46 | | - .key_size = sizeof(u32), |
---|
47 | | - .value_size = sizeof(struct wokeby_t), |
---|
48 | | - .max_entries = 10000, |
---|
49 | | -}; |
---|
| 50 | +struct { |
---|
| 51 | + __uint(type, BPF_MAP_TYPE_HASH); |
---|
| 52 | + __type(key, u32); |
---|
| 53 | + __type(value, struct wokeby_t); |
---|
| 54 | + __uint(max_entries, 10000); |
---|
| 55 | +} wokeby SEC(".maps"); |
---|
50 | 56 | |
---|
51 | | -struct bpf_map_def SEC("maps") stackmap = { |
---|
52 | | - .type = BPF_MAP_TYPE_STACK_TRACE, |
---|
53 | | - .key_size = sizeof(u32), |
---|
54 | | - .value_size = PERF_MAX_STACK_DEPTH * sizeof(u64), |
---|
55 | | - .max_entries = 10000, |
---|
56 | | -}; |
---|
| 57 | +struct { |
---|
| 58 | + __uint(type, BPF_MAP_TYPE_STACK_TRACE); |
---|
| 59 | + __uint(key_size, sizeof(u32)); |
---|
| 60 | + __uint(value_size, PERF_MAX_STACK_DEPTH * sizeof(u64)); |
---|
| 61 | + __uint(max_entries, 10000); |
---|
| 62 | +} stackmap SEC(".maps"); |
---|
57 | 63 | |
---|
58 | 64 | #define STACKID_FLAGS (0 | BPF_F_FAST_STACK_CMP) |
---|
59 | 65 | |
---|