summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2025-06-06 23:12:36 -0700
committerNamhyung Kim <namhyung@kernel.org>2025-06-25 12:37:29 -0700
commit57cbd56e2efe26483be2d4e7f62a7d9d816b54f1 (patch)
treed0a730188c178bbed419bd55e4c959c778864cbf
parent61051f9a8452d7f0878eaeb30299363310f07fd7 (diff)
perf header: Allow tracing of attr events
In pipe mode attr events capture the perf_event_attr. Allow their dumping as they normally start the file. Before: ``` $ perf record -o - -a sleep 1 | perf script -D -i - . ... raw event: size 272 bytes . 0000: 40 00 00 00 00 00 10 01 00 00 00 00 88 00 00 00 @............... . 0010: 00 00 00 00 00 00 00 00 a0 0f 00 00 00 00 00 00 ................ . 0020: 87 01 01 00 00 00 00 00 14 00 00 00 00 00 00 00 ................ . 0030: 01 84 05 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0090: 91 08 00 00 00 00 00 00 92 08 00 00 00 00 00 00 ................ . 00a0: 93 08 00 00 00 00 00 00 94 08 00 00 00 00 00 00 ................ . 00b0: 95 08 00 00 00 00 00 00 96 08 00 00 00 00 00 00 ................ . 00c0: 97 08 00 00 00 00 00 00 98 08 00 00 00 00 00 00 ................ . 00d0: 99 08 00 00 00 00 00 00 9a 08 00 00 00 00 00 00 ................ . 00e0: 9b 08 00 00 00 00 00 00 9c 08 00 00 00 00 00 00 ................ . 00f0: 9d 08 00 00 00 00 00 00 9e 08 00 00 00 00 00 00 ................ . 0100: 9f 08 00 00 00 00 00 00 a0 08 00 00 00 00 00 00 ................ -1 -1 0 [0x110]: PERF_RECORD_ATTR 0x110@pipe [0x110]: event: 64 ... ``` After: ``` $ perf record -o - -a sleep 1 | perf script -D -i - 0@pipe [0x110]: event: 64 . . ... raw event: size 272 bytes . 0000: 40 00 00 00 00 00 10 01 00 00 00 00 88 00 00 00 @............... . 0010: 00 00 00 00 00 00 00 00 a0 0f 00 00 00 00 00 00 ................ . 0020: 87 01 01 00 00 00 00 00 14 00 00 00 00 00 00 00 ................ . 0030: 01 84 05 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0090: 5c 08 00 00 00 00 00 00 5d 08 00 00 00 00 00 00 \.......]....... . 00a0: 5e 08 00 00 00 00 00 00 5f 08 00 00 00 00 00 00 ^......._....... . 00b0: 60 08 00 00 00 00 00 00 61 08 00 00 00 00 00 00 `.......a....... . 00c0: 62 08 00 00 00 00 00 00 63 08 00 00 00 00 00 00 b.......c....... . 00d0: 64 08 00 00 00 00 00 00 65 08 00 00 00 00 00 00 d.......e....... . 00e0: 66 08 00 00 00 00 00 00 67 08 00 00 00 00 00 00 f.......g....... . 00f0: 68 08 00 00 00 00 00 00 69 08 00 00 00 00 00 00 h.......i....... . 0100: 6a 08 00 00 00 00 00 00 6b 08 00 00 00 00 00 00 j.......k....... -1 -1 0 [0x110]: PERF_RECORD_ATTR, type = 0 (PERF_TYPE_HARDWARE), size = 136, config = 0 (PERF_COUNT_HW_CPU_CYCLES), { sample_period, sample_freq } = 4000, sample_type = IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format = ID|LOST, disabled = 1, freq = 1, precise_ip = 3, sample_id_all = 1 0x110@pipe [0x110]: event: 64 ... ``` Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20250617223356.2752099-4-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/util/header.c8
-rw-r--r--tools/perf/util/header.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 58f45a2a2ab6..3f1b78810059 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -4399,6 +4399,11 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp)
return ret;
}
+size_t perf_event__fprintf_attr(union perf_event *event, FILE *fp)
+{
+ return perf_event_attr__fprintf(fp, &event->attr.attr, __desc_attr__fprintf, NULL);
+}
+
int perf_event__process_attr(const struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct evlist **pevlist)
@@ -4408,6 +4413,9 @@ int perf_event__process_attr(const struct perf_tool *tool __maybe_unused,
struct evsel *evsel;
struct evlist *evlist = *pevlist;
+ if (dump_trace)
+ perf_event__fprintf_attr(event, stdout);
+
if (evlist == NULL) {
*pevlist = evlist = evlist__new();
if (evlist == NULL)
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 5201af6305f4..d16dfceccd74 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -175,6 +175,7 @@ int perf_event__process_attr(const struct perf_tool *tool, union perf_event *eve
int perf_event__process_event_update(const struct perf_tool *tool,
union perf_event *event,
struct evlist **pevlist);
+size_t perf_event__fprintf_attr(union perf_event *event, FILE *fp);
size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp);
#ifdef HAVE_LIBTRACEEVENT
int perf_event__process_tracing_data(struct perf_session *session,