]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf test: Add deterministic workload
authorJames Clark <james.clark@linaro.org>
Tue, 9 Jun 2026 14:40:10 +0000 (15:40 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 10 Jun 2026 21:55:48 +0000 (18:55 -0300)
Add a workload that does the same thing every time for testing CPU trace
decoding.

Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Amir Ayupov <aaupov@meta.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mike Leach <mike.leach@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paschalis Mpeis <Paschalis.Mpeis@arm.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-test.txt
tools/perf/tests/builtin-test.c
tools/perf/tests/tests.h
tools/perf/tests/workloads/Build
tools/perf/tests/workloads/deterministic.c [new file with mode: 0644]

index 213eb62603ebefae527a53bca014ae886bee84de..c50a4b2d2d291e39ec4f2bf7e1120e51f0debc94 100644 (file)
@@ -57,7 +57,7 @@ OPTIONS
 --workload=::
        Run a built-in workload, to list them use '--list-workloads', current
        ones include: noploop, thloop, leafloop, sqrtloop, brstack, datasym,
-       context_switch_loop and landlock.
+       context_switch_loop, deterministic and landlock.
 
        Used with the shell script regression tests.
 
@@ -66,7 +66,7 @@ OPTIONS
                seconds: leafloop, noploop, sqrtloop, thloop
                nrloops: brstack, context_switch_loop
 
-       The datasym and landlock workloads don't accept any.
+       The datasym, landlock and deterministic workloads don't accept any.
 
 --list-workloads::
        List the available workloads to use with -w/--workload.
index 9284f897de3c7cced25dc56c3aafec6b2dcaeecd..ef7e3f52a383e5581f607884735700f5d69a277e 100644 (file)
@@ -164,6 +164,7 @@ static struct test_workload *workloads[] = {
        &workload__inlineloop,
        &workload__jitdump,
        &workload__context_switch_loop,
+       &workload__deterministic,
 
 #ifdef HAVE_RUST_SUPPORT
        &workload__code_with_type,
index 7cd4da4e96d33adbfa768ed82dc0b557e34bc287..bcfe9c33fc66094a92c3d511ad9a5571630df7db 100644 (file)
@@ -246,6 +246,7 @@ DECLARE_WORKLOAD(traploop);
 DECLARE_WORKLOAD(inlineloop);
 DECLARE_WORKLOAD(jitdump);
 DECLARE_WORKLOAD(context_switch_loop);
+DECLARE_WORKLOAD(deterministic);
 
 #ifdef HAVE_RUST_SUPPORT
 DECLARE_WORKLOAD(code_with_type);
index 7134a031cb7c112cf0a64d70950265f4cba5e626..90f2d8aa4941f822b20c23645c806856031f8ba1 100644 (file)
@@ -11,6 +11,7 @@ perf-test-y += traploop.o
 perf-test-y += inlineloop.o
 perf-test-y += jitdump.o
 perf-test-y += context_switch_loop.o
+perf-test-y += deterministic.o
 
 ifeq ($(CONFIG_RUST_SUPPORT),y)
     perf-test-y += code_with_type.o
@@ -23,3 +24,4 @@ CFLAGS_brstack.o          = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_datasym.o          = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_traploop.o         = -g -O0 -fno-inline -U_FORTIFY_SOURCE
 CFLAGS_inlineloop.o       = -g -O2
+CFLAGS_deterministic.o    = -g -O0 -fno-inline -U_FORTIFY_SOURCE
diff --git a/tools/perf/tests/workloads/deterministic.c b/tools/perf/tests/workloads/deterministic.c
new file mode 100644 (file)
index 0000000..8a78519
--- /dev/null
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/compiler.h>
+#include "../tests.h"
+
+int dt_work = 1234;
+
+static void function1(void)
+{
+       dt_work += 7;
+       dt_work += 7;
+       dt_work += 7;
+}
+
+static void function2(void)
+{
+       dt_work += 7;
+       dt_work += 7;
+       dt_work += 7;
+}
+
+static int deterministic(int argc __maybe_unused,
+                        const char **argv __maybe_unused)
+{
+       dt_work += 7;
+       dt_work += 7;
+       dt_work += 7;
+
+       function1();
+
+       dt_work += 7;
+       dt_work += 7;
+       dt_work += 7;
+
+       function2();
+
+       return 0;
+}
+
+DEFINE_WORKLOAD(deterministic);