Commit f9a3e8e
committed
perf record: collect BPF metadata from existing BPF programs
JIRA: https://issues.redhat.com/browse/RHEL-78200
upstream
========
commit ab38e84
Author: Blake Jones <blakejones@google.com>
Date: Thu Jun 12 12:49:36 2025 -0700
description
===========
Look for .rodata maps, find ones with 'bpf_metadata_' variables, extract
their values as strings, and create a new PERF_RECORD_BPF_METADATA
synthetic event using that data. The code gets invoked from the existing
routine perf_event__synthesize_one_bpf_prog().
For example, a BPF program with the following variables:
const char bpf_metadata_version[] SEC(".rodata") = "3.14159";
int bpf_metadata_value[] SEC(".rodata") = 42;
would generate a PERF_RECORD_BPF_METADATA record with:
.prog_name = <BPF program name, e.g. "bpf_prog_a1b2c3_foo">
.nr_entries = 2
.entries[0].key = "version"
.entries[0].value = "3.14159"
.entries[1].key = "value"
.entries[1].value = "42"
Each of the BPF programs and subprograms that share those variables would
get a distinct PERF_RECORD_BPF_METADATA record, with the ".prog_name"
showing the name of each program or subprogram. The prog_name is
deliberately the same as the ".name" field in the corresponding
PERF_RECORD_KSYMBOL record.
This code only gets invoked if support for displaying BTF char arrays
as strings is detected.
Signed-off-by: Blake Jones <blakejones@google.com>
Link: https://lore.kernel.org/r/20250612194939.162730-3-blakejones@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Anubhav Shelat <ashelat@redhat.com>1 parent 1d981bb commit f9a3e8e
File tree
3 files changed
+362
-0
lines changed- tools
- lib/perf/include/perf
- perf/util
3 files changed
+362
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
470 | 486 | | |
471 | 487 | | |
472 | 488 | | |
| |||
489 | 505 | | |
490 | 506 | | |
491 | 507 | | |
| 508 | + | |
492 | 509 | | |
493 | 510 | | |
494 | 511 | | |
| |||
530 | 547 | | |
531 | 548 | | |
532 | 549 | | |
| 550 | + | |
533 | 551 | | |
534 | 552 | | |
535 | 553 | | |
0 commit comments