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

Configure Feed

Select the types of activity you want to include in your feed.

perf test workload: Add inlineloop test workload

The purpose of this workload is to gather samples in an inlined
function. This can be used to test whether inlined addr2line works
correctly.

Committer testing:

$ perf record perf test -w inlineloop 1
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.161 MB perf.data (4005 samples) ]
$ perf report --stdio --dso perf -s srcfile,srcline
#
# Total Lost Samples: 0
#
# Samples: 4K of event 'cpu/cycles/Pu'
# Event count (approx.): 5535180842
#
# Overhead Source File Source:Line
# ........ ............ ...............
#
99.04% inlineloop.c inlineloop.c:21
0.46% inlineloop.c inlineloop.c:20
#
$

Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Tony Jones <tonyj@suse.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
27fc6f56 f815fc0c

+56
+1
tools/perf/tests/builtin-test.c
··· 153 153 &workload__datasym, 154 154 &workload__landlock, 155 155 &workload__traploop, 156 + &workload__inlineloop, 156 157 }; 157 158 158 159 #define workloads__for_each(workload) \
+1
tools/perf/tests/tests.h
··· 240 240 DECLARE_WORKLOAD(datasym); 241 241 DECLARE_WORKLOAD(landlock); 242 242 DECLARE_WORKLOAD(traploop); 243 + DECLARE_WORKLOAD(inlineloop); 243 244 244 245 extern const char *dso_to_test; 245 246 extern const char *test_objdump_path;
+2
tools/perf/tests/workloads/Build
··· 8 8 perf-test-y += datasym.o 9 9 perf-test-y += landlock.o 10 10 perf-test-y += traploop.o 11 + perf-test-y += inlineloop.o 11 12 12 13 CFLAGS_sqrtloop.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE 13 14 CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer -U_FORTIFY_SOURCE 14 15 CFLAGS_brstack.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE 15 16 CFLAGS_datasym.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE 16 17 CFLAGS_traploop.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE 18 + CFLAGS_inlineloop.o = -g -O2
+52
tools/perf/tests/workloads/inlineloop.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <pthread.h> 3 + #include <stdlib.h> 4 + #include <signal.h> 5 + #include <unistd.h> 6 + #include <linux/compiler.h> 7 + #include "../tests.h" 8 + 9 + static volatile int a; 10 + static volatile sig_atomic_t done; 11 + 12 + static void sighandler(int sig __maybe_unused) 13 + { 14 + done = 1; 15 + } 16 + 17 + static inline void __attribute__((always_inline)) leaf(int b) 18 + { 19 + again: 20 + a += b; 21 + if (!done) 22 + goto again; 23 + } 24 + 25 + static inline void __attribute__((always_inline)) middle(int b) 26 + { 27 + leaf(b); 28 + } 29 + 30 + static noinline void parent(int b) 31 + { 32 + middle(b); 33 + } 34 + 35 + static int inlineloop(int argc, const char **argv) 36 + { 37 + int sec = 1; 38 + 39 + pthread_setname_np(pthread_self(), "perf-inlineloop"); 40 + if (argc > 0) 41 + sec = atoi(argv[0]); 42 + 43 + signal(SIGINT, sighandler); 44 + signal(SIGALRM, sighandler); 45 + alarm(sec); 46 + 47 + parent(sec); 48 + 49 + return 0; 50 + } 51 + 52 + DEFINE_WORKLOAD(inlineloop);