perf auxtrace: Define auxtrace record alignment
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 6 Feb 2019 10:39:43 +0000 (12:39 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 6 Feb 2019 13:25:39 +0000 (10:25 -0300)
Define auxtrace record alignment so that it can be referenced elsewhere.

Note this is preparation for patch "perf intel-pt: Fix overlap calculation
for padding"

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20190206103947.15750-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/auxtrace.c
tools/perf/util/auxtrace.h

index 94a22cc8004c035be80558b54613f301b4febbc4..ad186d3255d130e59da05a3cd589e770cdfb633d 100644 (file)
@@ -1279,9 +1279,9 @@ static int __auxtrace_mmap__read(struct perf_mmap *map,
        }
 
        /* padding must be written by fn() e.g. record__process_auxtrace() */
-       padding = size & 7;
+       padding = size & (PERF_AUXTRACE_RECORD_ALIGNMENT - 1);
        if (padding)
-               padding = 8 - padding;
+               padding = PERF_AUXTRACE_RECORD_ALIGNMENT - padding;
 
        memset(&ev, 0, sizeof(ev));
        ev.auxtrace.header.type = PERF_RECORD_AUXTRACE;
index 8e50f96d4b23de86e4939d7276e024f7c353aa81..fac32482db619b175b0ca29bc98669150e307cc9 100644 (file)
@@ -40,6 +40,9 @@ struct record_opts;
 struct auxtrace_info_event;
 struct events_stats;
 
+/* Auxtrace records must have the same alignment as perf event records */
+#define PERF_AUXTRACE_RECORD_ALIGNMENT 8
+
 enum auxtrace_type {
        PERF_AUXTRACE_UNKNOWN,
        PERF_AUXTRACE_INTEL_PT,