[PATCH V3 19/25] perf tools: Allow auxtrace data alignment

Adrian Hunter
2015-04-24T19:35:20Z

Allow auxtrace data to be a multiple of
something other than page size. That is
needed for BTS where the buffer contains
24-byte records.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/auxtrace.c | 7 +++++++
tools/perf/util/auxtrace.h | 1 +
2 files changed, 8 insertions(+)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index b81130c..58accf7 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -1187,6 +1187,13 @@ static int __auxtrace_mmap__read(struct auxtrace_mmap *mm,
data2 = NULL;
}

+ if (itr->alignment) {
+ unsigned int unwanted = len1 % itr->alignment;
+
+ len1 -= unwanted;
+ size -= unwanted;
+ }
+
/* padding must be written by fn() e.g. record__process_auxtrace() */
padding = size & 7;
if (padding)
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index ae1249a..fb639c43 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -304,6 +304,7 @@ struct auxtrace_record {
const char *str);
u64 (*reference)(struct auxtrace_record *itr);
int (*read_finish)(struct auxtrace_record *itr, int idx);
+ unsigned int alignment;
};

#ifdef HAVE_AUXTRACE_SUPPORT
--
1.9.1