linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf: generate events for BPF metadata
@ 2025-05-21 22:27 Blake Jones
  2025-05-21 22:27 ` [PATCH 1/3] perf: add support for printing BTF character arrays as strings Blake Jones
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Blake Jones @ 2025-05-21 22:27 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Ian Rogers,
	Adrian Hunter, Kan Liang
  Cc: Chun-Tse Shao, Zhongqiu Han, James Clark, Charlie Jenkins,
	Andi Kleen, Dmitry Vyukov, Leo Yan, Yujie Liu, Graham Woodward,
	Yicong Yang, Ben Gainey, linux-kernel, bpf, linux-perf-users,
	Blake Jones

Commit ffa915f46193 ("Merge branch 'bpf_metadata'"), from September 2020,
added support to the kernel, libbpf, and bpftool to treat read-only BPF
variables that have names starting with 'bpf_metadata_' specially. This
patch series updates perf to handle these variables similarly, allowing a
perf.data file to capture relevant information about BPF programs on the
system being profiled.

When it encounters a BPF program, it reads the program's maps to find an
'.rodata' map with 'bpf_metadata_' variables. If it finds one, it extracts
their values as strings, and creates a new PERF_RECORD_BPF_METADATA
synthetic event using that data. It does this both for BPF programs that
were loaded when a 'perf record' starts, as well as for programs that are
loaded while the profile is running. For the latter case, it stores the
metadata for the duration of the profile, and then dumps it at the end of
the profile, where it's in a better context to do so.

The PERF_RECORD_BPF_METADATA event holds an array of key-value pairs, where
the key is the variable name (minus the "bpf_metadata_" prefix) and the
value is the variable's value, formatted as a string. The event also
includes the BPF program's name, so it can be correlated with
PERF_RECORD_KSYMBOL events.

Blake Jones (3):
  perf: add support for printing BTF character arrays as strings
  perf: collect BPF metadata from existing BPF programs
  perf: collect BPF metadata from new programs, and display the new
    event

 tools/lib/bpf/btf.h                          |   3 +-
 tools/lib/bpf/btf_dump.c                     |  51 ++-
 tools/lib/perf/include/perf/event.h          |  18 +
 tools/perf/builtin-inject.c                  |   1 +
 tools/perf/builtin-record.c                  |   8 +
 tools/perf/builtin-script.c                  |  15 +-
 tools/perf/tests/shell/test_bpf_metadata.sh  |  67 ++++
 tools/perf/util/bpf-event.c                  | 356 +++++++++++++++++++
 tools/perf/util/bpf-event.h                  |  14 +
 tools/perf/util/bpf_skel/sample_filter.bpf.c |   4 +
 tools/perf/util/env.c                        |  19 +-
 tools/perf/util/env.h                        |   4 +
 tools/perf/util/event.c                      |  21 ++
 tools/perf/util/event.h                      |   1 +
 tools/perf/util/header.c                     |   1 +
 tools/perf/util/session.c                    |   4 +
 tools/perf/util/synthetic-events.h           |   2 +
 tools/perf/util/tool.c                       |  14 +
 tools/perf/util/tool.h                       |   3 +-
 19 files changed, 600 insertions(+), 6 deletions(-)
 create mode 100644 tools/perf/tests/shell/test_bpf_metadata.sh

-- 
2.49.0.1143.g0be31eac6b-goog


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2025-06-04 23:04 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 22:27 [PATCH 0/3] perf: generate events for BPF metadata Blake Jones
2025-05-21 22:27 ` [PATCH 1/3] perf: add support for printing BTF character arrays as strings Blake Jones
2025-05-22 17:42   ` Arnaldo Carvalho de Melo
2025-05-22 18:19     ` Blake Jones
2025-05-29  0:58       ` Blake Jones
2025-05-30 17:40         ` Namhyung Kim
2025-05-31  7:26           ` Blake Jones
2025-06-03 18:23             ` Blake Jones
2025-06-03 18:43               ` Alexei Starovoitov
2025-06-03 19:47                 ` Namhyung Kim
2025-05-21 22:27 ` [PATCH 2/3] perf: collect BPF metadata from existing BPF programs Blake Jones
2025-05-29 17:47   ` Ian Rogers
2025-05-29 23:21     ` Blake Jones
2025-05-29 23:23       ` Ian Rogers
2025-06-03 20:15   ` Namhyung Kim
2025-06-03 21:27     ` Blake Jones
2025-06-03 21:44       ` Namhyung Kim
2025-06-03 21:54         ` Blake Jones
2025-06-03 22:09           ` Namhyung Kim
2025-06-03 22:29             ` Blake Jones
2025-06-04 21:40               ` Namhyung Kim
2025-06-04 22:12                 ` Arnaldo Carvalho de Melo
2025-06-04 23:04                   ` Blake Jones
2025-05-21 22:27 ` [PATCH 3/3] perf: collect BPF metadata from new programs, and display the new event Blake Jones
2025-05-29 18:12   ` Ian Rogers
2025-05-29 23:09     ` Blake Jones
2025-05-29 23:27       ` Ian Rogers
2025-05-29 23:49         ` Blake Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).