Re: [PATCH v4 1/9] perf evsel: Set BPF output to system-wide
From: Namhyung Kim
Date: Wed Aug 07 2024 - 19:21:49 EST
On Wed, Aug 07, 2024 at 11:38:35PM +0800, Howard Chu wrote:
> pid = -1 for bpf-output event.
>
> This makes perf record -p <PID> --off-cpu work. Otherwise bpf-output
> cannot be collected.
I don't understand why it's necessary. Why isn't it collected?
Is it the kernel to reject the BPF output event to open?
Thanks,
Namhyung
>
> Signed-off-by: Howard Chu <howardchu95@xxxxxxxxx>
> ---
> tools/perf/util/evsel.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index bc603193c477..b961467133cf 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2282,6 +2282,10 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
>
> test_attr__ready();
>
> + /* BPF output event can only be system-wide */
> + if (evsel__is_bpf_output(evsel))
> + pid = -1;
> +
> /* Debug message used by test scripts */
> pr_debug2_peo("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx",
> pid, perf_cpu_map__cpu(cpus, idx).cpu, group_fd, evsel->open_flags);
> --
> 2.45.2
>