[PATCH 3/3] selftests/syscall_user_dispatch: Skip benchmark if SUD is unsupported

Christian Loehle <[email protected]>
Newsgroups org.kernel.vger.linux-kselftest,org.kernel.vger.linux-kernel
Message-ID <7f6caf7adeefaac0e57bb06d194b36795f2888bc.1786965107.git.christian.loehle@arm.com>
Syscall User Dispatch is unavailable on architectures without generic
syscall entry. On such architectures, sud_benchmark spends several
seconds calibrating before its SUD prctl fails with EINVAL.

Probe SUD with a valid disabled configuration before calibration and skip
when the kernel returns EINVAL. Treat other probe errors as failures and
continue to run the benchmark unchanged on supported kernels.

Fixes: d87ae0fa21c2 ("selftests: Add benchmark for syscall user dispatch")
Signed-off-by: Christian Loehle <[email protected]>
---
 .../selftests/syscall_user_dispatch/sud_benchmark.c      | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
index 073a03702ff5..bb05fece301a 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
@@ -18,6 +18,8 @@
 #include <sys/prctl.h>
 #include <sys/syscall.h>
 
+#include "kselftest.h"
+
 #ifndef PR_SET_SYSCALL_USER_DISPATCH
 # define PR_SET_SYSCALL_USER_DISPATCH	59
 # define PR_SYS_DISPATCH_OFF	0
@@ -140,6 +142,13 @@ int main(void)
 	int ret;
 	sigset_t mask;
 
+	ret = prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF,
+		    0UL, 0UL, 0UL);
+	if (ret == -1 && errno == EINVAL)
+		ksft_exit_skip("Syscall User Dispatch is not supported\n");
+	if (ret)
+		ksft_exit_fail_perror("PR_SET_SYSCALL_USER_DISPATCH");
+
 	memset(&act, 0, sizeof(act));
 	sigemptyset(&mask);
 
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.