|
@@ -191,14 +191,17 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5)
|
|
struct bpf_map *map = (struct bpf_map *) (unsigned long) r1;
|
|
struct bpf_map *map = (struct bpf_map *) (unsigned long) r1;
|
|
struct bpf_array *array = container_of(map, struct bpf_array, map);
|
|
struct bpf_array *array = container_of(map, struct bpf_array, map);
|
|
struct perf_event *event;
|
|
struct perf_event *event;
|
|
|
|
+ struct file *file;
|
|
|
|
|
|
if (unlikely(index >= array->map.max_entries))
|
|
if (unlikely(index >= array->map.max_entries))
|
|
return -E2BIG;
|
|
return -E2BIG;
|
|
|
|
|
|
- event = (struct perf_event *)array->ptrs[index];
|
|
|
|
- if (!event)
|
|
|
|
|
|
+ file = (struct file *)array->ptrs[index];
|
|
|
|
+ if (unlikely(!file))
|
|
return -ENOENT;
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
+ event = file->private_data;
|
|
|
|
+
|
|
/* make sure event is local and doesn't have pmu::count */
|
|
/* make sure event is local and doesn't have pmu::count */
|
|
if (event->oncpu != smp_processor_id() ||
|
|
if (event->oncpu != smp_processor_id() ||
|
|
event->pmu->count)
|
|
event->pmu->count)
|
|
@@ -228,6 +231,7 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 index, u64 r4, u64 size)
|
|
void *data = (void *) (long) r4;
|
|
void *data = (void *) (long) r4;
|
|
struct perf_sample_data sample_data;
|
|
struct perf_sample_data sample_data;
|
|
struct perf_event *event;
|
|
struct perf_event *event;
|
|
|
|
+ struct file *file;
|
|
struct perf_raw_record raw = {
|
|
struct perf_raw_record raw = {
|
|
.size = size,
|
|
.size = size,
|
|
.data = data,
|
|
.data = data,
|
|
@@ -236,10 +240,12 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 index, u64 r4, u64 size)
|
|
if (unlikely(index >= array->map.max_entries))
|
|
if (unlikely(index >= array->map.max_entries))
|
|
return -E2BIG;
|
|
return -E2BIG;
|
|
|
|
|
|
- event = (struct perf_event *)array->ptrs[index];
|
|
|
|
- if (unlikely(!event))
|
|
|
|
|
|
+ file = (struct file *)array->ptrs[index];
|
|
|
|
+ if (unlikely(!file))
|
|
return -ENOENT;
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
+ event = file->private_data;
|
|
|
|
+
|
|
if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE ||
|
|
if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE ||
|
|
event->attr.config != PERF_COUNT_SW_BPF_OUTPUT))
|
|
event->attr.config != PERF_COUNT_SW_BPF_OUTPUT))
|
|
return -EINVAL;
|
|
return -EINVAL;
|