aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamhyung Kim <[email protected]>2023-08-25 08:25:50 -0700
committerArnaldo Carvalho de Melo <[email protected]>2023-08-29 14:16:14 -0300
commitbaec60800dd4a379546f3ba311574d907a01a77d (patch)
tree7daa193bb1b98fe5b1286195293661b6eef2be09
parent9bf63282ea77a531ea58acb42fb3f40d2d1e4497 (diff)
libperf: 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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/lib/perf/include/perf/event.h4
1 files changed, 4 insertions, 0 deletions
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,