mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org,
	Thomas Richter <tmricht@linux.ibm.com>, Leo Yan <leo.yan@arm.com>
Subject: [PATCH v2 5/6] perf test: Add timeout to datasym workload
Date: Mon,  3 Mar 2025 18:28:36 -0800	[thread overview]
Message-ID: <20250304022837.1877845-6-namhyung@kernel.org> (raw)
In-Reply-To: <20250304022837.1877845-1-namhyung@kernel.org>

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.

Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Leo Yan <leo.yan@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/workloads/datasym.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c
index 8e08fc75a973e5f7..8ddb2aa6a049e343 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) {
 			/*
-- 
2.48.1.711.g2feabab25a-goog


  parent reply	other threads:[~2025-03-04  2:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
2025-03-04  2:28 ` [PATCH v2 1/6] perf test: Add --metric-only to perf stat output tests Namhyung Kim
2025-03-04  2:28 ` [PATCH v2 2/6] perf test: Skip perf probe tests when running as non-root Namhyung Kim
2025-03-04  2:28 ` [PATCH v2 3/6] perf test: Skip perf trace " Namhyung Kim
2025-03-04  2:28 ` [PATCH v2 4/6] perf test: Add trace record and replay test Namhyung Kim
2025-03-04  2:28 ` Namhyung Kim [this message]
2025-03-04  7:37   ` [PATCH v2 5/6] perf test: Add timeout to datasym workload Thomas Richter
2025-03-04 15:16   ` Leo Yan
2025-03-04  2:28 ` [PATCH v2 6/6] perf test: Simplify data symbol test Namhyung Kim
2025-03-04  7:38   ` Thomas Richter
2025-03-04 15:15   ` Leo Yan
2025-03-04 16:17 ` [PATCH v2 0/6] perf test: Small improvements Falcon, Thomas
2025-03-06 17:14 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250304022837.1877845-6-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®