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