Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Add 'leafloop' test workload

The leafloop workload is to run an infinite loop in the test_leaf
function. This is needed for the ARM fp callgraph test to verify if it
gets the correct callchains.

$ perf test -w leafloop

Committer notes:

Add a:

-U_FORTIFY_SOURCE

to the leafloop CFLAGS as the main perf flags set it and it requires
building with optimization, and this new test has a -O0.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20221116233854.1596378-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
41522f74 0b8ff0ba

+39
+1
tools/perf/tests/builtin-test.c
··· 121 121 static struct test_workload *workloads[] = { 122 122 &workload__noploop, 123 123 &workload__thloop, 124 + &workload__leafloop, 124 125 }; 125 126 126 127 static int num_subtests(const struct test_suite *t)
+1
tools/perf/tests/tests.h
··· 202 202 /* The list of test workloads */ 203 203 DECLARE_WORKLOAD(noploop); 204 204 DECLARE_WORKLOAD(thloop); 205 + DECLARE_WORKLOAD(leafloop); 205 206 206 207 #endif /* TESTS_H */
+3
tools/perf/tests/workloads/Build
··· 2 2 3 3 perf-y += noploop.o 4 4 perf-y += thloop.o 5 + perf-y += leafloop.o 6 + 7 + CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer -U_FORTIFY_SOURCE
+34
tools/perf/tests/workloads/leafloop.c
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #include <stdlib.h> 3 + #include <linux/compiler.h> 4 + #include "../tests.h" 5 + 6 + /* We want to check these symbols in perf script */ 7 + noinline void leaf(volatile int b); 8 + noinline void parent(volatile int b); 9 + 10 + static volatile int a; 11 + 12 + noinline void leaf(volatile int b) 13 + { 14 + for (;;) 15 + a += b; 16 + } 17 + 18 + noinline void parent(volatile int b) 19 + { 20 + leaf(b); 21 + } 22 + 23 + static int leafloop(int argc, const char **argv) 24 + { 25 + int c = 1; 26 + 27 + if (argc > 0) 28 + c = atoi(argv[0]); 29 + 30 + parent(c); 31 + return 0; 32 + } 33 + 34 + DEFINE_WORKLOAD(leafloop);