Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Add timeout to datasym workload

Unlike others it has an infinite loop that make it annoying to call.
Make it finish after 1 second and handle command-line argument to change
the setting.

Reviewed-by: Leo Yan <leo.yan@arm.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Leo Yan <leo.yan@arm.com>
Link: https://lore.kernel.org/r/20250304022837.1877845-6-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+21 -2
+21 -2
tools/perf/tests/workloads/datasym.c
··· 1 + #include <stdlib.h> 2 + #include <signal.h> 3 + #include <unistd.h> 1 4 #include <linux/compiler.h> 2 5 #include "../tests.h" 3 6 ··· 15 12 .reserved[0] = 1, 16 13 }; 17 14 18 - static int datasym(int argc __maybe_unused, const char **argv __maybe_unused) 15 + static volatile sig_atomic_t done; 16 + 17 + static void sighandler(int sig __maybe_unused) 19 18 { 20 - for (;;) { 19 + done = 1; 20 + } 21 + 22 + static int datasym(int argc, const char **argv) 23 + { 24 + int sec = 1; 25 + 26 + if (argc > 0) 27 + sec = atoi(argv[0]); 28 + 29 + signal(SIGINT, sighandler); 30 + signal(SIGALRM, sighandler); 31 + alarm(sec); 32 + 33 + while (!done) { 21 34 buf1.data1++; 22 35 if (buf1.data1 == 123) { 23 36 /*