[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240807153843.3231451-9-howardchu95@gmail.com>
Date: Wed, 7 Aug 2024 23:38:42 +0800
From: Howard Chu <howardchu95@...il.com>
To: namhyung@...nel.org
Cc: irogers@...gle.com,
acme@...nel.org,
adrian.hunter@...el.com,
jolsa@...nel.org,
kan.liang@...ux.intel.com,
linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v4 8/9] perf header: Add field 'embed'
We have to save the embedded data's sample type for it to be consumed
correctly by perf script or perf report.
This will approach most definitely break some perf.data convertor.
Signed-off-by: Howard Chu <howardchu95@...il.com>
---
tools/perf/util/header.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 55e9553861d0..d60e77d5c25c 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -80,6 +80,7 @@ const char perf_version_string[] = PERF_VERSION;
struct perf_file_attr {
struct perf_event_attr attr;
+ __u64 embed;
struct perf_file_section ids;
};
@@ -3713,6 +3714,7 @@ static int perf_session__do_write_header(struct perf_session *session,
}
f_attr = (struct perf_file_attr){
.attr = evsel->core.attr,
+ .embed = evsel->sample_type_embed,
.ids = {
.offset = evsel->id_offset,
.size = evsel->core.ids * sizeof(u64),
@@ -4147,6 +4149,14 @@ static int read_attr(int fd, struct perf_header *ph,
ret = readn(fd, ptr, left);
}
+
+ ret = readn(fd, &f_attr->embed, sizeof(f_attr->embed));
+ if (ret <= 0) {
+ pr_debug("failed to read %d bytes of embedded sample type\n",
+ (int)sizeof(f_attr->embed));
+ return -1;
+ }
+
/* read perf_file_section, ids are read in caller */
ret = readn(fd, &f_attr->ids, sizeof(f_attr->ids));
@@ -4272,6 +4282,8 @@ int perf_session__read_header(struct perf_session *session, int repipe_fd)
tmp = lseek(fd, 0, SEEK_CUR);
evsel = evsel__new(&f_attr.attr);
+ evsel->sample_type_embed = f_attr.embed;
+
if (evsel == NULL)
goto out_delete_evlist;
--
2.45.2
Powered by blists - more mailing lists