Re: [PATCH v2 net-next 1/3] perf, bpf: Add BPF support to all perf_event types

From: Peter Zijlstra
Date: Mon May 29 2017 - 05:13:34 EST


On Thu, May 25, 2017 at 10:55:47PM -0700, Alexei Starovoitov wrote:

> +++ b/kernel/bpf/arraymap.c
> @@ -462,26 +462,22 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map,
>
> event = perf_file->private_data;
> ee = ERR_PTR(-EINVAL);
> + /* Per-task events are not supported */
> + if (event->attach_state & PERF_ATTACH_TASK)
> + goto err_out;
>
> attr = perf_event_attrs(event);
> if (IS_ERR(attr) || attr->inherit)
> goto err_out;

> + /* TRACEPOINT and BREAKPOINT not supported in perf_event_read_local */

I cannot find reason for this comment. That is, why would
perf_event_read_local() not support those two types?

> + if (attr->type == PERF_TYPE_TRACEPOINT ||
> + attr->type == PERF_TYPE_BREAKPOINT)
> + goto err_out;
>
> + ee = bpf_event_entry_gen(perf_file, map_file);
> + if (ee)
> + return ee;
> + ee = ERR_PTR(-ENOMEM);
>
> err_out:
> fput(perf_file);