Skip to contentSkip to conversation

perf test: Add ARM SPE system wide test

PATCH Superseded Namhyung Kim 2 participants 4 messages Jun 16, 2022 – Jun 24, 2022 perf events

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH v2 1/1 perf test: Add ARM SPE system wide test

In the past it had a problem not setting the pid/tid on the sample correctly when system-wide mode is used. Although it's fixed now it'd be nice if we have a test case for it.

---
* skip if system-wide record was failed

 tools/perf/tests/shell/test_arm_spe.sh | 28 +++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
tools/perf/tests/shell/test_arm_spe.sh +25 -3
index e59044edc406..962841a51f27 100755
@@ -23,17 +23,20 @@ glb_err=0
 cleanup_files()
 {
 	rm -f ${perfdata}
+	rm -f ${perfdata}.old
 	exit $glb_err
 }
 
 trap cleanup_files exit term int
 
 arm_spe_report() {
-	if [ $2 != 0 ]; then
+	if [ $2 = 0 ]; then
+		echo "$1: PASS"
+	elif [ $2 = 2 ]; then
+		echo "$1: SKIPPED"
+	else
 		echo "$1: FAIL"
 		glb_err=$2
-	else
-		echo "$1: PASS"
 	fi
 }
 
@@ -85,5 +88,24 @@ arm_spe_snapshot_test() {
 	arm_spe_report "SPE snapshot testing" $err
 }
 
+arm_spe_system_wide_test() {
+	echo "Recording trace with system-wide mode $perfdata"
+	perf record -o ${perfdata} -e arm_spe// -a \
+		-- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1
+
+	if [ $? != 0 ]; then
+		arm_spe_report "SPE system-wide testing" 2
+		return
+	fi
+
+	perf_script_samples dd &&
+	perf_report_samples dd
+
+	err=$?
+	arm_spe_report "SPE system-wide testing" $err
+}
+
 arm_spe_snapshot_test
+arm_spe_system_wide_test
+
 exit $glb_err
Signature · 1 line
2.36.1.476.g0c4daa206d-goog
#1 lore raw

Hi Namhyung,

On Thu, Jun 16, 2022 at 04:05:46PM -0700, Namhyung Kim wrote:

[...]

tools/perf/tests/shell/test_arm_spe.sh arm_spe_snapshot_test() { · line 99

Quoted 9 lines
tools/perf/tests/shell/test_arm_spe.sh +9 -0
+arm_spe_system_wide_test() {
+	echo "Recording trace with system-wide mode $perfdata"
+	perf record -o ${perfdata} -e arm_spe// -a \
+		-- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1
+
+	if [ $? != 0 ]; then
+		arm_spe_report "SPE system-wide testing" 2
+		return
+	fi

I am awared the root permission issue after I saw German's suggestion.

If the snapshot test is passed, no matter the system wide test is passed or not, we will always return 0 for 'passed' result. But we might miss to capture the system-wide testing failure.

How about use 'dummy' event to verіfy the root permission? (actually I referred to intel-pt test):

        perf record -o ${tmpfile} -B -N --no-bpf-event -e dummy:u -a true 2>&1 >/dev/null
        if [ $? != 0 ]; then
        	arm_spe_report "SPE system-wide testing" 2
        	return
        fi

        perf record -o ${perfdata} -e arm_spe// -a \
                  -- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1

Thanks,
Leo

Quoted 14 lines
tools/perf/tests/shell/test_arm_spe.sh +9 -0
+	perf_script_samples dd &&
+	perf_report_samples dd
+
+	err=$?
+	arm_spe_report "SPE system-wide testing" $err
+}
+
 arm_spe_snapshot_test
+arm_spe_system_wide_test
+
 exit $glb_err
Signature · 1 line
2.36.1.476.g0c4daa206d-goog
#2 lore raw
Quoted 18 lines · Leo Yan

Hi Namhyung,

On Thu, Jun 16, 2022 at 04:05:46PM -0700, Namhyung Kim wrote:

[...]

tools/perf/tests/shell/test_arm_spe.sh arm_spe_snapshot_test() { · line 99

Quoted 9 lines
tools/perf/tests/shell/test_arm_spe.sh +9 -0
+arm_spe_system_wide_test() {
+	echo "Recording trace with system-wide mode $perfdata"
+	perf record -o ${perfdata} -e arm_spe// -a \
+		-- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1
+
+	if [ $? != 0 ]; then
+		arm_spe_report "SPE system-wide testing" 2
+		return
+	fi

I am awared the root permission issue after I saw German's suggestion.

Quoted 8 lines

If the snapshot test is passed, no matter the system wide test is passed or not, we will always return 0 for 'passed' result. But we might miss to capture the system-wide testing failure.

How about use 'dummy' event to verіfy the root permission? (actually I referred to intel-pt test):

        perf record -o ${tmpfile} -B -N --no-bpf-event -e dummy:u -a true 2>&1 >/dev/null

Sorry for typo, s/tmpfile/perfdata/

Quoted 7 lines
        if [ $? != 0 ]; then
        	arm_spe_report "SPE system-wide testing" 2
        	return
        fi

        perf record -o ${perfdata} -e arm_spe// -a \
                  -- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1
author maintainer
#3 lore raw

Hi Leo,

Quoted 27 lines · Leo Yan
Quoted 25 lines · Leo Yan

Hi Namhyung,

On Thu, Jun 16, 2022 at 04:05:46PM -0700, Namhyung Kim wrote:

[...]

tools/perf/tests/shell/test_arm_spe.sh arm_spe_snapshot_test() { · line 99

Quoted 9 lines
tools/perf/tests/shell/test_arm_spe.sh +9 -0
+arm_spe_system_wide_test() {
+   echo "Recording trace with system-wide mode $perfdata"
+   perf record -o ${perfdata} -e arm_spe// -a \
+           -- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1
+
+   if [ $? != 0 ]; then
+           arm_spe_report "SPE system-wide testing" 2
+           return
+   fi

I am awared the root permission issue after I saw German's suggestion.

If the snapshot test is passed, no matter the system wide test is passed or not, we will always return 0 for 'passed' result. But we might miss to capture the system-wide testing failure.

How about use 'dummy' event to verіfy the root permission? (actually I referred to intel-pt test):

Quoted 8 lines
Quoted 8 lines
        perf record -o ${perfdata} -B -N --no-bpf-event -e dummy:u -a true 2>&1 >/dev/null
        if [ $? != 0 ]; then
              arm_spe_report "SPE system-wide testing" 2
              return
        fi

        perf record -o ${perfdata} -e arm_spe// -a \
                  -- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1

Ok, will add the change.

Thanks,
Namhyung