[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230825152552.112913-2-namhyung@kernel.org>
Date: Fri, 25 Aug 2023 08:25:50 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
linux-perf-users@...r.kernel.org
Subject: [PATCH v2 2/4] tools/lib/perf: Add perf_record_header_attr_id()
The HEADER_ATTR record has an event attr followed by the id array. But
perf data from a different version could have different size of attr.
So it cannot just use event->attr.id to access the array. Let's add the
perf_record_header_attr_id() macro to calculate the start of the array.
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/lib/perf/include/perf/event.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h
index ba2dcf64f4e6..e563dd8c3628 100644
--- a/tools/lib/perf/include/perf/event.h
+++ b/tools/lib/perf/include/perf/event.h
@@ -151,6 +151,10 @@ struct perf_record_header_attr {
__u64 id[];
};
+/* Returns the pointer to id array based on the actual attr size. */
+#define perf_record_header_attr_id(evt) \
+ ((void *)&(evt)->attr.attr + (evt)->attr.attr.size)
+
enum {
PERF_CPU_MAP__CPUS = 0,
PERF_CPU_MAP__MASK = 1,
--
2.42.0.rc1.204.g551eb34607-goog
Powered by blists - more mailing lists