[PATCH 12/14] perf test: Allow infinite named_thread loops
James Clark
james.clark at linaro.org
Tue Aug 11 08:30:15 PDT 2026
The following test will want this to run forever, so add support by
treating 0 loops as infinite.
Convert i and named_threads_work to be unsigned to avoid undefined
signed overflow behavior in infinite loop mode.
Signed-off-by: James Clark <james.clark at linaro.org>
---
tools/perf/Documentation/perf-test.txt | 2 +-
tools/perf/tests/workloads/named_threads.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentation/perf-test.txt
index 859df74e62ef..dca8972fec8d 100644
--- a/tools/perf/Documentation/perf-test.txt
+++ b/tools/perf/Documentation/perf-test.txt
@@ -68,7 +68,7 @@ OPTIONS
nrloops: brstack, context_switch_loop
'named_threads' accepts the number of threads and the number of loops to
- do in each thread.
+ do in each thread. Use 0 for an infinite loop.
The datasym, landlock, deterministic and callchain workloads don't accept
any.
diff --git a/tools/perf/tests/workloads/named_threads.c b/tools/perf/tests/workloads/named_threads.c
index d051d41a3cfe..6672c2f77684 100644
--- a/tools/perf/tests/workloads/named_threads.c
+++ b/tools/perf/tests/workloads/named_threads.c
@@ -11,7 +11,7 @@
#define MAX_THREADS 25
static int iterations = 500;
-int named_threads_work = 1234;
+unsigned int named_threads_work = 1234;
typedef void *(*thread_fn_t)(void *);
@@ -19,7 +19,8 @@ typedef void *(*thread_fn_t)(void *);
noinline void *named_threads_thread##n(void *arg __maybe_unused) \
{ \
pthread_setname_np(pthread_self(), "thread" #n); \
- for (int i = 0; i < iterations; i++) \
+ for (unsigned int i = 0; \
+ i < (unsigned int) iterations || iterations == 0; i++) \
named_threads_work += 3; \
\
return NULL; \
@@ -65,7 +66,7 @@ static thread_fn_t thread_fns[MAX_THREADS] = {
/*
* Creates argv[0] threads that run a unique function named "thread[x]" which performs
- * a multiplication in a loop for argv[1] loops.
+ * a multiplication in a loop for argv[1] loops (use 0 for infinite loop).
*/
static int named_threads(int argc, const char **argv)
{
--
2.43.0
More information about the linux-arm-kernel
mailing list