Re: [PATCH v4 12/53] perf bpf: Don't synthesize BPF events when disabled

From: Arnaldo Carvalho de Melo
Date: Wed Nov 08 2023 - 11:15:01 EST


Em Thu, Nov 02, 2023 at 10:56:54AM -0700, Ian Rogers escreveu:
> If BPF sideband events are disabled on the command line, don't
> synthesize BPF events too.


Interesting, in 71184c6ab7e60fd5 ("perf record: Replace option
--bpf-event with --no-bpf-event") we checked that, but only down at
perf_event__synthesize_one_bpf_prog(), where we have:

if (!opts->no_bpf_event) {
/* Synthesize PERF_RECORD_BPF_EVENT */
*bpf_event = (struct perf_record_bpf_event)


So we better remove that, now redundant check? I'll apply your patch as
is and then we can remove that other check.

Song, can I have your Acked-by or Reviewed-by, please?

- Arnaldo



> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/bpf-event.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
> index 38fcf3ba5749..830711cae30d 100644
> --- a/tools/perf/util/bpf-event.c
> +++ b/tools/perf/util/bpf-event.c
> @@ -386,6 +386,9 @@ int perf_event__synthesize_bpf_events(struct perf_session *session,
> int err;
> int fd;
>
> + if (opts->no_bpf_event)
> + return 0;
> +
> event = malloc(sizeof(event->bpf) + KSYM_NAME_LEN + machine->id_hdr_size);
> if (!event)
> return -1;
> --
> 2.42.0.869.gea05f2083d-goog
>

--

- Arnaldo