|
8 | 8 | #include <linux/version.h> |
9 | 9 | #include <bpf/bpf_helpers.h> |
10 | 10 | #include <bpf/bpf_tracing.h> |
| 11 | +#include <bpf/bpf_core_read.h> |
11 | 12 |
|
12 | 13 | #ifndef PERF_MAX_STACK_DEPTH |
13 | 14 | #define PERF_MAX_STACK_DEPTH 127 |
14 | 15 | #endif |
15 | 16 |
|
16 | | -#define _(P) \ |
17 | | - ({ \ |
18 | | - typeof(P) val; \ |
19 | | - bpf_probe_read_kernel(&val, sizeof(val), &(P)); \ |
20 | | - val; \ |
21 | | - }) |
22 | | - |
23 | 17 | #define MINBLOCK_US 1 |
24 | 18 | #define MAX_ENTRIES 10000 |
25 | 19 |
|
@@ -68,11 +62,9 @@ struct { |
68 | 62 | SEC("kprobe/try_to_wake_up") |
69 | 63 | int waker(struct pt_regs *ctx) |
70 | 64 | { |
71 | | - struct task_struct *p = (void *) PT_REGS_PARM1(ctx); |
| 65 | + struct task_struct *p = (void *)PT_REGS_PARM1_CORE(ctx); |
| 66 | + u32 pid = BPF_CORE_READ(p, pid); |
72 | 67 | struct wokeby_t woke; |
73 | | - u32 pid; |
74 | | - |
75 | | - pid = _(p->pid); |
76 | 68 |
|
77 | 69 | bpf_get_current_comm(&woke.name, sizeof(woke.name)); |
78 | 70 | woke.ret = bpf_get_stackid(ctx, &stackmap, STACKID_FLAGS); |
@@ -121,9 +113,9 @@ int oncpu(struct trace_event_raw_sched_switch *ctx) |
121 | 113 | SEC("kprobe.multi/finish_task_switch*") |
122 | 114 | int oncpu(struct pt_regs *ctx) |
123 | 115 | { |
124 | | - struct task_struct *p = (void *) PT_REGS_PARM1(ctx); |
| 116 | + struct task_struct *p = (void *)PT_REGS_PARM1_CORE(ctx); |
125 | 117 | /* record previous thread sleep time */ |
126 | | - u32 pid = _(p->pid); |
| 118 | + u32 pid = BPF_CORE_READ(p, pid); |
127 | 119 | #endif |
128 | 120 | u64 delta, ts, *tsp; |
129 | 121 |
|
|
0 commit comments