Linux Perf Users
 help / color / mirror / Atom feed
* [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

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