From: James Clark Date: Tue, 9 Jun 2026 14:40:10 +0000 (+0100) Subject: perf test: Add deterministic workload X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=3fdf30607e28290d914c44b035f35a9a92512562;p=thirdparty%2Fkernel%2Flinux.git perf test: Add deterministic workload Add a workload that does the same thing every time for testing CPU trace decoding. Reviewed-by: Leo Yan Signed-off-by: James Clark Cc: Amir Ayupov Cc: Ian Rogers Cc: Jiri Olsa Cc: Jonathan Corbet Cc: Mike Leach Cc: Namhyung Kim Cc: Paschalis Mpeis Cc: Shuah Khan Cc: Suzuki Poulouse Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentation/perf-test.txt index 213eb62603ebe..c50a4b2d2d291 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -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. diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 9284f897de3c7..ef7e3f52a383e 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -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, diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 7cd4da4e96d33..bcfe9c33fc660 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -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); diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index 7134a031cb7c1..90f2d8aa4941f 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -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 index 0000000000000..8a78519fd075e --- /dev/null +++ b/tools/perf/tests/workloads/deterministic.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#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);