kselftest/arm64: sme: Provide streaming mode SVE stress test
authorMark Brown <broonie@kernel.org>
Tue, 19 Apr 2022 11:22:40 +0000 (12:22 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 28 Apr 2022 16:57:11 +0000 (17:57 +0100)
One of the features of SME is the addition of streaming mode, in which we
have access to a set of streaming mode SVE registers at the SME vector
length. Since these are accessed using the SVE instructions let's reuse
the existing SVE stress test for testing with a compile time option for
controlling the few small differences needed:

 - Enter streaming mode immediately on starting the program.
 - In streaming mode FFR is removed so skip reading and writing FFR.

Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20220419112247.711548-33-broonie@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
tools/testing/selftests/arm64/fp/.gitignore
tools/testing/selftests/arm64/fp/Makefile
tools/testing/selftests/arm64/fp/ssve-stress [new file with mode: 0644]
tools/testing/selftests/arm64/fp/sve-test.S

index 6e9a610..5729a5b 100644 (file)
@@ -5,5 +5,6 @@ rdvl-sve
 sve-probe-vls
 sve-ptrace
 sve-test
+ssve-test
 vec-syscfg
 vlset
index a224fff..e6643c9 100644 (file)
@@ -5,6 +5,7 @@ TEST_GEN_PROGS := sve-ptrace sve-probe-vls vec-syscfg
 TEST_PROGS_EXTENDED := fp-pidbench fpsimd-test fpsimd-stress \
        rdvl-sme rdvl-sve \
        sve-test sve-stress \
+       ssve-test ssve-stress \
        vlset
 
 all: $(TEST_GEN_PROGS) $(TEST_PROGS_EXTENDED)
@@ -19,6 +20,8 @@ sve-ptrace: sve-ptrace.o
 sve-probe-vls: sve-probe-vls.o rdvl.o
 sve-test: sve-test.o asm-utils.o
        $(CC) -nostdlib $^ -o $@
+ssve-test: sve-test.S asm-utils.o
+       $(CC) -DSSVE -nostdlib $^ -o $@
 vec-syscfg: vec-syscfg.o rdvl.o
 vlset: vlset.o
 
diff --git a/tools/testing/selftests/arm64/fp/ssve-stress b/tools/testing/selftests/arm64/fp/ssve-stress
new file mode 100644 (file)
index 0000000..e2bd2cc
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) 2015-2019 ARM Limited.
+# Original author: Dave Martin <Dave.Martin@arm.com>
+
+set -ue
+
+NR_CPUS=`nproc`
+
+pids=
+logs=
+
+cleanup () {
+       trap - INT TERM CHLD
+       set +e
+
+       if [ -n "$pids" ]; then
+               kill $pids
+               wait $pids
+               pids=
+       fi
+
+       if [ -n "$logs" ]; then
+               cat $logs
+               rm $logs
+               logs=
+       fi
+}
+
+interrupt () {
+       cleanup
+       exit 0
+}
+
+child_died () {
+       cleanup
+       exit 1
+}
+
+trap interrupt INT TERM EXIT
+
+for x in `seq 0 $((NR_CPUS * 4))`; do
+       log=`mktemp`
+       logs=$logs\ $log
+       ./ssve-test >$log &
+       pids=$pids\ $!
+done
+
+# Wait for all child processes to be created:
+sleep 10
+
+while :; do
+       kill -USR1 $pids
+done &
+pids=$pids\ $!
+
+wait
+
+exit 1
index f5b1b48..5892642 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/unistd.h>
 #include "assembler.h"
 #include "asm-offsets.h"
+#include "sme-inst.h"
 
 #define NZR    32
 #define NPR    16
@@ -156,6 +157,7 @@ endfunction
 // We fill the upper lanes of FFR with zeros.
 // Beware: corrupts P0.
 function setup_ffr
+#ifndef SSVE
        mov     x4, x30
 
        and     w0, w0, #0x3
@@ -178,6 +180,9 @@ function setup_ffr
        wrffr   p0.b
 
        ret     x4
+#else
+       ret
+#endif
 endfunction
 
 // Trivial memory compare: compare x2 bytes starting at address x0 with
@@ -260,6 +265,7 @@ endfunction
 // Beware -- corrupts P0.
 // Clobbers x0-x5.
 function check_ffr
+#ifndef SSVE
        mov     x3, x30
 
        ldr     x4, =scratch
@@ -280,6 +286,9 @@ function check_ffr
        mov     x2, x5
        mov     x30, x3
        b       memcmp
+#else
+       ret
+#endif
 endfunction
 
 // Any SVE register modified here can cause corruption in the main
@@ -295,10 +304,12 @@ function irritator_handler
        movi    v0.8b, #1
        movi    v9.16b, #2
        movi    v31.8b, #3
+#ifndef SSVE
        // And P0
        rdffr   p0.b
        // And FFR
        wrffr   p15.b
+#endif
 
        ret
 endfunction
@@ -359,6 +370,11 @@ endfunction
 .globl _start
 function _start
 _start:
+#ifdef SSVE
+       puts    "Streaming mode "
+       smstart_sm
+#endif
+
        // Sanity-check and report the vector length
 
        rdvl    x19, #8
@@ -407,6 +423,10 @@ _start:
        orr     w2, w2, #SA_NODEFER
        bl      setsignal
 
+#ifdef SSVE
+       smstart_sm              // syscalls will have exited streaming mode
+#endif
+
        mov     x22, #0         // generation number, increments per iteration
 .Ltest_loop:
        rdvl    x0, #8