Commit f04c7ef3 authored by Namhyung Kim's avatar Namhyung Kim
Browse files

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: default avatarLeo Yan <leo.yan@arm.com>
Tested-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Tested-by: default avatarThomas 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: default avatarNamhyung Kim <namhyung@kernel.org>
parent 15bcfb96
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
#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) {
			/*