aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/bpf_trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/bpf_trace.c')
-rw-r--r--kernel/trace/bpf_trace.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 26f603da7e26..3de25fbed785 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -192,18 +192,17 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5)
192{ 192{
193 struct bpf_map *map = (struct bpf_map *) (unsigned long) r1; 193 struct bpf_map *map = (struct bpf_map *) (unsigned long) r1;
194 struct bpf_array *array = container_of(map, struct bpf_array, map); 194 struct bpf_array *array = container_of(map, struct bpf_array, map);
195 struct bpf_event_entry *ee;
195 struct perf_event *event; 196 struct perf_event *event;
196 struct file *file;
197 197
198 if (unlikely(index >= array->map.max_entries)) 198 if (unlikely(index >= array->map.max_entries))
199 return -E2BIG; 199 return -E2BIG;
200 200
201 file = READ_ONCE(array->ptrs[index]); 201 ee = READ_ONCE(array->ptrs[index]);
202 if (unlikely(!file)) 202 if (unlikely(!ee))
203 return -ENOENT; 203 return -ENOENT;
204 204
205 event = file->private_data; 205 event = ee->event;
206
207 /* make sure event is local and doesn't have pmu::count */ 206 /* make sure event is local and doesn't have pmu::count */
208 if (event->oncpu != smp_processor_id() || 207 if (event->oncpu != smp_processor_id() ||
209 event->pmu->count) 208 event->pmu->count)
@@ -237,8 +236,8 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 flags, u64 r4, u64 size)
237 u64 index = flags & BPF_F_INDEX_MASK; 236 u64 index = flags & BPF_F_INDEX_MASK;
238 void *data = (void *) (long) r4; 237 void *data = (void *) (long) r4;
239 struct perf_sample_data sample_data; 238 struct perf_sample_data sample_data;
239 struct bpf_event_entry *ee;
240 struct perf_event *event; 240 struct perf_event *event;
241 struct file *file;
242 struct perf_raw_record raw = { 241 struct perf_raw_record raw = {
243 .size = size, 242 .size = size,
244 .data = data, 243 .data = data,
@@ -251,12 +250,11 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 flags, u64 r4, u64 size)
251 if (unlikely(index >= array->map.max_entries)) 250 if (unlikely(index >= array->map.max_entries))
252 return -E2BIG; 251 return -E2BIG;
253 252
254 file = READ_ONCE(array->ptrs[index]); 253 ee = READ_ONCE(array->ptrs[index]);
255 if (unlikely(!file)) 254 if (unlikely(!ee))
256 return -ENOENT; 255 return -ENOENT;
257 256
258 event = file->private_data; 257 event = ee->event;
259
260 if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE || 258 if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE ||
261 event->attr.config != PERF_COUNT_SW_BPF_OUTPUT)) 259 event->attr.config != PERF_COUNT_SW_BPF_OUTPUT))
262 return -EINVAL; 260 return -EINVAL;