All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v4 3/8] perf header: Properly warn/print when libtraceevent/libbpf support is missing
Date: Thu, 13 Aug 2026 23:29:45 +0000	[thread overview]
Message-ID: <20260813232946.08E801F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260401161324.332356-4-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Returning -1 for unsupported features in `process_*` callbacks causes `perf_header__process_sections()` to abort prematurely, silently skipping all subsequent header features.
- [Medium] `perf record` unconditionally prints errors for BPF features when compiled without `libbpf`.
--

--- Patch [3]: [PATCH v4 3/8] perf header: Properly warn/print when libtraceevent/libbpf support is missing ---
commit e5ac8f49aacee07fccb1639de8607d4e1627acf5
Author: Ian Rogers <irogers@google.com>

perf header: Properly warn/print when libtraceevent/libbpf support is missing

By removing the features from feat_ops with ifdefs the previous logic
would print "# (null)" when perf processed a feature that lacked
builtin support. Remove the ifdefs from feat_ops and in the relevant
functions print errors/messages about the lack of support.

> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
[ ... ]
> -#ifdef HAVE_LIBBPF_SUPPORT
> -static int write_bpf_prog_info(struct feat_fd *ff,
> +static int write_bpf_prog_info(struct feat_fd *ff  __maybe_unused,
>  			       struct evlist *evlist __maybe_unused)
>  {
> +#ifdef HAVE_LIBBPF_SUPPORT
>  	struct perf_env *env = &ff->ph->env;
>  	struct rb_root *root;
>  	struct rb_node *next;
[ ... ]
> @@ -1067,11 +1070,16 @@ static int write_bpf_prog_info(struct feat_fd *ff,
>  out:
>  	up_read(&env->bpf_progs.lock);
>  	return ret;
> +#else
> +	pr_err("ERROR: Trying to write bpf_prog_info without libbpf support.\n");
> +	return -1;
> +#endif // HAVE_LIBBPF_SUPPORT
>  }

[Severity: Medium]
Will this cause spurious error messages and failures on every invocation of
perf record when compiled without libbpf?

Previously, when HAVE_LIBBPF_SUPPORT was absent, the feature was missing from
feat_ops and silently skipped. Because record__init_features() unconditionally
sets HEADER_BPF_PROG_INFO, won't perf_header__adds_write() now call this
function, print the error, and return -1 on every run?

[ ... ]
> -static int write_bpf_btf(struct feat_fd *ff,
> +static int write_bpf_btf(struct feat_fd *ff __maybe_unused,
>  			 struct evlist *evlist __maybe_unused)
>  {
> +#ifdef HAVE_LIBBPF_SUPPORT
>  	struct perf_env *env = &ff->ph->env;
>  	struct rb_root *root;
>  	struct rb_node *next;
[ ... ]
> @@ -1100,8 +1108,11 @@ static int write_bpf_btf(struct feat_fd *ff,
>  out:
>  	up_read(&env->bpf_progs.lock);
>  	return ret;
> -}
> +#else
> +	pr_err("ERROR: Trying to write btf data without libbpf support.\n");
> +	return -1;
>  #endif // HAVE_LIBBPF_SUPPORT
> +}

[Severity: Medium]
Similar to the issue above, won't this unconditionally print an error and
fail perf record if libbpf is not supported, since HEADER_BPF_BTF is also
unconditionally set in record__init_features()?

[ ... ]
> -#ifdef HAVE_LIBTRACEEVENT
> -static int process_tracing_data(struct feat_fd *ff, void *data)
> +static int process_tracing_data(struct feat_fd *ff __maybe_unused, void *data __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	ssize_t ret = trace_report(ff->fd, data, false);
>  
>  	return ret < 0 ? -1 : 0;
> -}
> +#else
> +	pr_err("ERROR: Trying to read tracing data without libtraceevent support.\n");
> +	return -1;
>  #endif
> +}

[Severity: High]
Does returning -1 here cause perf_header__process_sections() to abort
prematurely and silently skip all remaining header features?

When processing features, perf_header__process_sections() iterates over the
added features:

    for_each_set_bit(feat, header->adds_features, HEADER_LAST_FEATURE) {
        err = process(sec++, header, feat, fd, data);
        if (err < 0)
            goto out_free;
    }

If perf encounters a perf.data file containing HEADER_TRACING_DATA but lacks
libtraceevent support, it looks like it will break out of the loop and skip
any features that appear after it in the bitmask (such as COMPRESSED or
CPU_PMU_CAPS), which could cause downstream failures like missing
decompression metadata.

Should this return 0 instead of -1 so that processing can continue?

[ ... ]
> -#ifdef HAVE_LIBBPF_SUPPORT
> -static int process_bpf_prog_info(struct feat_fd *ff, void *data __maybe_unused)
> +static int process_bpf_prog_info(struct feat_fd *ff __maybe_unused, void *data __maybe_unused)
>  {
> +#ifdef HAVE_LIBBPF_SUPPORT
>  	struct bpf_prog_info_node *info_node;
>  	struct perf_env *env = &ff->ph->env;
>  	struct perf_bpil *info_linear;
[ ... ]
> @@ -3402,10 +3422,15 @@ static int process_bpf_prog_info(struct feat_fd *ff, void *data __maybe_unused)
>  	free(info_node);
>  	up_write(&env->bpf_progs.lock);
>  	return err;
> +#else
> +	pr_err("ERROR: Trying to read bpf_prog_info without libbpf support.\n");
> +	return -1;
> +#endif // HAVE_LIBBPF_SUPPORT
>  }

[Severity: High]
Like process_tracing_data() above, won't returning -1 here abort
perf_header__process_sections() and skip the rest of the features in the file
if libbpf is not supported?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260401161324.332356-1-irogers@google.com?part=3

  reply	other threads:[~2026-08-13 23:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-28  6:59 [PATCH v2 0/7] perf data/pipe handling improvements Ian Rogers
2026-02-28  6:59 ` [PATCH v2 1/7] perf clockid: Add missing include Ian Rogers
2026-02-28  6:59 ` [PATCH v2 2/7] perf header: Add utility to convert feature number to a string Ian Rogers
2026-02-28  6:59 ` [PATCH v2 3/7] perf session: Extra logging for failed to process events Ian Rogers
2026-02-28  6:59 ` [PATCH v2 4/7] perf header: Refactor pipe mode end marker handling Ian Rogers
2026-03-05  6:23   ` Namhyung Kim
2026-04-01  5:26     ` Ian Rogers
2026-02-28  6:59 ` [PATCH v2 5/7] perf ordered-events: Event processing consistency with the regular reader Ian Rogers
2026-03-05  6:27   ` Namhyung Kim
2026-04-01  5:29     ` Ian Rogers
2026-02-28  6:59 ` [PATCH v2 6/7] perf evsel: Make unknown event names more unique Ian Rogers
2026-02-28  6:59 ` [PATCH v2 7/7] perf data convert ctf: Pipe mode improvements Ian Rogers
2026-03-05  6:39   ` Namhyung Kim
2026-04-01  5:51 ` [PATCH v3 0/7] perf data/pipe handling improvements Ian Rogers
2026-04-01  5:52   ` [PATCH v3 1/7] perf clockid: Add missing include Ian Rogers
2026-04-01  5:52   ` [PATCH v3 2/7] perf header: Add utility to convert feature number to a string Ian Rogers
2026-04-01  5:52   ` [PATCH v3 3/7] perf session: Extra logging for failed to process events Ian Rogers
2026-04-01  5:52   ` [PATCH v3 4/7] perf header: Refactor pipe mode end marker handling Ian Rogers
2026-04-01  5:52   ` [PATCH v3 5/7] perf ordered-events: Event processing consistency with the regular reader Ian Rogers
2026-04-01  5:52   ` [PATCH v3 6/7] perf evsel: Make unknown event names more unique Ian Rogers
2026-04-01  5:52   ` [PATCH v3 7/7] perf data convert ctf: Pipe mode improvements Ian Rogers
2026-04-01 16:13   ` [PATCH v4 0/8] perf data/pipe handling improvements Ian Rogers
2026-04-01 16:13     ` [PATCH v4 1/8] perf clockid: Add missing include Ian Rogers
2026-04-01 16:13     ` [PATCH v4 2/8] perf header: Add utility to convert feature number to a string Ian Rogers
2026-04-01 16:13     ` [PATCH v4 3/8] perf header: Properly warn/print when libtraceevent/libbpf support is missing Ian Rogers
2026-08-13 23:29       ` sashiko-bot [this message]
2026-04-01 16:13     ` [PATCH v4 4/8] perf session: Extra logging for failed to process events Ian Rogers
2026-04-01 16:13     ` [PATCH v4 5/8] perf header: Refactor pipe mode end marker handling Ian Rogers
2026-04-01 16:13     ` [PATCH v4 6/8] perf ordered-events: Event processing consistency with the regular reader Ian Rogers
2026-04-01 16:13     ` [PATCH v4 7/8] perf evsel: Make unknown event names more unique Ian Rogers
2026-04-01 16:13     ` [PATCH v4 8/8] perf data convert ctf: Pipe mode improvements Ian Rogers
2026-04-04  0:15     ` [PATCH v4 0/8] perf data/pipe handling improvements Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260813232946.08E801F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.