perf auxtrace: Define auxtrace record alignment
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 6 Feb 2019 10:39:43 +0000 (12:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 13:35:29 +0000 (14:35 +0100)
commit c3fcadf0bb765faf45d6d562246e1d08885466df upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/perf/util/auxtrace.c
tools/perf/util/auxtrace.h

index bbb9823e93b95ecf343863cf665b07f580c6e65e..44c8bcefe2247815a4a9de9b80f390c9d1b28e52 100644 (file)
@@ -1264,9 +1264,9 @@ static int __auxtrace_mmap__read(struct auxtrace_mmap *mm,
        }
 
        /* 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 33b5e6cdf38c8302727fe55446b8f24d8342084d..d273bb47b3e3f34838693d425ad3fe84dbfe955d 100644 (file)
@@ -38,6 +38,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,