[PATCH 10/13] tool/perf: Add support for perf_arch_regs

Madhavan Srinivasan maddy at linux.vnet.ibm.com
Mon Aug 29 07:00:55 AEST 2016


Update the structure regs_dump with the arch_regs_mask
variable. Update perf_evsel__parse_sample() and
perf_event__sample_event_size() to include arch_regs_mask variable.

Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Ingo Molnar <mingo at kernel.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Jiri Olsa <jolsa at kernel.org>
Cc: Arnaldo Carvalho de Melo <acme at kernel.org>
Cc: Stephane Eranian <eranian at gmail.com>
Cc: Russell King <linux at arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will.deacon at arm.com>
Cc: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Cc: Michael Ellerman <mpe at ellerman.id.au>
Cc: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy at linux.vnet.ibm.com>
---
 tools/perf/util/event.h |  1 +
 tools/perf/util/evsel.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 8d363d5e65a2..aee0ff536e29 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -94,6 +94,7 @@ struct sample_event {
 struct regs_dump {
 	u64 abi;
 	u64 mask;
+	u64 arch_regs_mask;
 	u64 *regs;
 
 	/* Cached values/mask filled by first register access. */
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 21fd573106ed..aac8820b3bd5 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1902,6 +1902,8 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
 		OVERFLOW_CHECK_u64(array);
 		data->user_regs.abi = *array;
 		array++;
+		data->user_regs.arch_regs_mask = *array;
+		array++;
 
 		if (data->user_regs.abi) {
 			u64 mask = evsel->attr.sample_regs_user;
@@ -1961,11 +1963,14 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
 		OVERFLOW_CHECK_u64(array);
 		data->intr_regs.abi = *array;
 		array++;
+		data->intr_regs.arch_regs_mask = *array;
+		array++;
 
 		if (data->intr_regs.abi != PERF_SAMPLE_REGS_ABI_NONE) {
 			u64 mask = evsel->attr.sample_regs_intr;
 
 			sz = hweight_long(mask) * sizeof(u64);
+			sz += hweight_long(data->intr_regs.arch_regs_mask) * sizeof(u64);
 			OVERFLOW_CHECK(array, sz, max_size);
 			data->intr_regs.mask = mask;
 			data->intr_regs.regs = (u64 *)array;
@@ -2044,6 +2049,7 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
 		if (sample->user_regs.abi) {
 			result += sizeof(u64);
 			sz = hweight_long(sample->user_regs.mask) * sizeof(u64);
+			sz += hweight_long(sample->user_regs.arch_regs_mask) * sizeof(u64);
 			result += sz;
 		} else {
 			result += sizeof(u64);
@@ -2072,6 +2078,7 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
 		if (sample->intr_regs.abi) {
 			result += sizeof(u64);
 			sz = hweight_long(sample->intr_regs.mask) * sizeof(u64);
+			sz += hweight_long(sample->intr_regs.arch_regs_mask) * sizeof(u64);
 			result += sz;
 		} else {
 			result += sizeof(u64);
@@ -2223,7 +2230,9 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
 	if (type & PERF_SAMPLE_REGS_USER) {
 		if (sample->user_regs.abi) {
 			*array++ = sample->user_regs.abi;
+			*array++ = sample->user_regs.arch_regs_mask;
 			sz = hweight_long(sample->user_regs.mask) * sizeof(u64);
+			sz += hweight_long(sample->user_regs.arch_regs_mask) * sizeof(u64);
 			memcpy(array, sample->user_regs.regs, sz);
 			array = (void *)array + sz;
 		} else {
@@ -2259,7 +2268,9 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
 	if (type & PERF_SAMPLE_REGS_INTR) {
 		if (sample->intr_regs.abi) {
 			*array++ = sample->intr_regs.abi;
+			*array++ = sample->intr_regs.arch_regs_mask;
 			sz = hweight_long(sample->intr_regs.mask) * sizeof(u64);
+			sz += hweight_long(sample->intr_regs.arch_regs_mask) * sizeof(u64);
 			memcpy(array, sample->intr_regs.regs, sz);
 			array = (void *)array + sz;
 		} else {
-- 
2.7.4



More information about the Linuxppc-dev mailing list