[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250607061238.161756-3-irogers@google.com>
Date: Fri, 6 Jun 2025 23:12:36 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>, James Clark <james.clark@...aro.org>,
Zhongqiu Han <quic_zhonhan@...cinc.com>, Yicong Yang <yangyicong@...ilicon.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
bpf@...r.kernel.org
Subject: [PATCH v1 2/4] 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@...e [0x110]: event: 64
...
```
After:
```
$ perf record -o - -a sleep 1 | perf script -D -i -
0@...e [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@...e [0x110]: event: 64
...
```
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/perf/util/header.c | 8 ++++++++
tools/perf/util/header.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 84879d7fdffe..7798435ab5d3 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -4414,6 +4414,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)
@@ -4423,6 +4428,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,
--
2.50.0.rc0.604.gd4ff7b7c86-goog
Powered by blists - more mailing lists