[PATCH 2/2] perf tools: Fix record failure when mixed with ARM SPE event

Wei Li liwei391 at huawei.com
Tue Jun 23 08:31:41 EDT 2020


When recording with cache-misses and arm_spe_x event, i found that
it will just fail without showing any error info if i put cache-misses
after arm_spe_x event.

[root at localhost 0620]# perf record -e cache-misses -e \
arm_spe_0/ts_enable=1,pct_enable=1,pa_enable=1,load_filter=1,\
jitter=1,store_filter=1,min_latency=0/ sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.067 MB perf.data ]
[root at localhost 0620]# perf record -e \
arm_spe_0/ts_enable=1,pct_enable=1,pa_enable=1,load_filter=1,jitter=1,\
store_filter=1,min_latency=0/ -e cache-misses sleep 1
[root at localhost 0620]#

Finally, i found the reason is that the parameter 'arm_spe_pmu' passed to
arm_spe_recording_init() in auxtrace_record__init() is wrong. When the
arm_spe_x event is not the last event, 'arm_spe_pmus[i]' will be out of
bounds.

It seems that the code can't support concurrent multiple different
arm_spe_x events currently. So add the code to check and record the
found 'arm_spe_pmu' to fix this issue.

In fact, we don't support concurrent multiple same arm_spe_x events either,
that is checked in arm_spe_recording_options(), and it will show the
relevant info.

Fixes: ffd3d18c20b8d ("perf tools: Add ARM Statistical Profiling Extensions (SPE) support")
Signed-off-by: Wei Li <liwei391 at huawei.com>
---
 tools/perf/arch/arm/util/auxtrace.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/arch/arm/util/auxtrace.c b/tools/perf/arch/arm/util/auxtrace.c
index 62b7b03d691a..7bb6f29e766c 100644
--- a/tools/perf/arch/arm/util/auxtrace.c
+++ b/tools/perf/arch/arm/util/auxtrace.c
@@ -58,6 +58,7 @@ struct auxtrace_record
 	bool found_etm = false;
 	bool found_spe = false;
 	static struct perf_pmu **arm_spe_pmus;
+	static struct perf_pmu *arm_spe_pmu;
 	static int nr_spes = 0;
 	int i = 0;
 
@@ -77,6 +78,13 @@ struct auxtrace_record
 
 		for (i = 0; i < nr_spes; i++) {
 			if (evsel->core.attr.type == arm_spe_pmus[i]->type) {
+				if (found_spe && (arm_spe_pmu != arm_spe_pmus[i])) {
+					pr_err("Concurrent multiple SPE operation not currently supported\n");
+					*err = -EOPNOTSUPP;
+					return NULL;
+				}
+
+				arm_spe_pmu = arm_spe_pmus[i];
 				found_spe = true;
 				break;
 			}
@@ -94,7 +102,7 @@ struct auxtrace_record
 
 #if defined(__aarch64__)
 	if (found_spe)
-		return arm_spe_recording_init(err, arm_spe_pmus[i]);
+		return arm_spe_recording_init(err, arm_spe_pmu);
 #endif
 
 	/*
-- 
2.17.1




More information about the linux-arm-kernel mailing list