* [PATCH] perf: record: Clear BPF headers if not needed
@ 2026-07-01 14:13 Mayuresh Chitale
2026-07-01 14:31 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Mayuresh Chitale @ 2026-07-01 14:13 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Ian Rogers
Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
James Clark, linux-perf-users, linux-kernel, bpf,
Mayuresh Chitale
When perf is compiled without libbpf support (e.g., passing NO_LIBELF=1)
and even if the user explicitly passes the '--no-bpf-event' flag, the file
header feature bitmask still unconditionally retains the BPF/BTF tracking
bits. As a result, write_bpf_prog_info() and write_bpf_btf() always get
called and display the error messages below:
ERROR: Trying to write bpf_prog_info without libbpf support.
ERROR: Trying to write btf data without libbpf support.
Fix this by clearing HEADER_BPF_PROG_INFO and HEADER_BPF_BTF from the
features bitmask, whenever the user passes the '--no-bpf-event' flag.
Fixes: 598de368375e ("perf header: Properly warn/print when libtraceevent/libbpf support is missing")
Signed-off-by: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
---
tools/perf/builtin-record.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e91539055675..692ab7138d2c 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1829,6 +1829,11 @@ static void record__init_features(struct record *rec)
if (!record__comp_enabled(rec))
perf_header__clear_feat(&session->header, HEADER_COMPRESSED);
+ if (rec->opts.no_bpf_event) {
+ perf_header__clear_feat(&session->header, HEADER_BPF_PROG_INFO);
+ perf_header__clear_feat(&session->header, HEADER_BPF_BTF);
+ }
+
perf_header__clear_feat(&session->header, HEADER_STAT);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf: record: Clear BPF headers if not needed
2026-07-01 14:13 [PATCH] perf: record: Clear BPF headers if not needed Mayuresh Chitale
@ 2026-07-01 14:31 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-01 14:31 UTC (permalink / raw)
To: Mayuresh Chitale; +Cc: bpf, linux-perf-users
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch conditionally clears BPF header features based on `rec->opts.no_bpf_event` too early in `record__init_features()`, failing to fix the spurious error messages for default and dynamically evaluated cases when `perf` is compiled without `libbpf`.
--
commit 9515d1b27d6dcc9884718d4505a8cf399d665c9e
Author: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
perf: record: Clear BPF headers if not needed
This patch clears the HEADER_BPF_PROG_INFO and HEADER_BPF_BTF bits from the
file header feature bitmask when the '--no-bpf-event' flag is passed. This
aims to prevent spurious error messages about missing libbpf support when
writing perf data.
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index e915390556752..692ab7138d2c3 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1829,6 +1829,11 @@ static void record__init_features(struct record *rec)
> if (!record__comp_enabled(rec))
> perf_header__clear_feat(&session->header, HEADER_COMPRESSED);
>
> + if (rec->opts.no_bpf_event) {
> + perf_header__clear_feat(&session->header, HEADER_BPF_PROG_INFO);
> + perf_header__clear_feat(&session->header, HEADER_BPF_BTF);
> + }
> +
[Severity: Medium]
Does this conditionally clear the features too early in the initialization
process?
If the user does not explicitly pass the flag (the default case), or if the
flag is dynamically updated to true later (e.g. if updated after checking
!evlist__needs_bpf_sb_event(rec->evlist)), this condition will evaluate to
false.
Will this leave the spurious errors unresolved for default and dynamically
evaluated cases when perf is compiled without libbpf?
> perf_header__clear_feat(&session->header, HEADER_STAT);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701141347.4098670-1-mayuresh.chitale@oss.qualcomm.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-01 14:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 14:13 [PATCH] perf: record: Clear BPF headers if not needed Mayuresh Chitale
2026-07-01 14:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox