diff options
| author | Namhyung Kim <namhyung@kernel.org> | 2025-03-03 18:28:36 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-10 14:44:30 +0200 |
| commit | 71f2f4b5c227b196e1f57d0492273ff0acb041e4 (patch) | |
| tree | 3c7ddccfa924a660210383f41a7e2e9207d9c9fc /tools | |
| parent | b9982065b82b4177ba3a7a72ce18c84921f7494d (diff) | |
| download | linux-71f2f4b5c227b196e1f57d0492273ff0acb041e4.tar.gz linux-71f2f4b5c227b196e1f57d0492273ff0acb041e4.tar.bz2 linux-71f2f4b5c227b196e1f57d0492273ff0acb041e4.zip | |
perf test: Add timeout to datasym workload
[ Upstream commit f04c7ef35256beea57a598a7ea06dd2242ae9ae6 ]
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>
Stable-dep-of: 36e7748d33bf ("perf tests: Fix data symbol test with LTO builds")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/tests/workloads/datasym.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c index 8e08fc75a973..8ddb2aa6a049 100644 --- a/tools/perf/tests/workloads/datasym.c +++ b/tools/perf/tests/workloads/datasym.c @@ -1,3 +1,6 @@ +#include <stdlib.h> +#include <signal.h> +#include <unistd.h> #include <linux/compiler.h> #include "../tests.h" @@ -12,9 +15,25 @@ static buf buf1 = { .reserved[0] = 1, }; -static int datasym(int argc __maybe_unused, const char **argv __maybe_unused) +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +static int datasym(int argc, const char **argv) { - for (;;) { + int sec = 1; + + if (argc > 0) + sec = atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); + + while (!done) { buf1.data1++; if (buf1.data1 == 123) { /* |
