xref: /linux/tools/perf/tests/workloads/callchain.c (revision 67f8bc848ee31831336bd478e57d2f993551902e)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/compiler.h>
3 #include <sys/syscall.h>
4 #include <unistd.h>
5 #include "../tests.h"
6 
7 /*
8  * Mark as noinline to establish the call chain, and avoid the static
9  * annotation to prevent LTO from renaming the functions.
10  */
11 noinline void callchain_do_syscall(void);
12 noinline void callchain_foo(void);
13 noinline int callchain(int argc, const char **argv);
14 
15 noinline void callchain_do_syscall(void)
16 {
17 	syscall(SYS_gettid);
18 }
19 
20 noinline void callchain_foo(void)
21 {
22 	callchain_do_syscall();
23 }
24 
25 noinline int callchain(int argc __maybe_unused,
26 		       const char **argv __maybe_unused)
27 {
28 	callchain_foo();
29 
30 	return 0;
31 }
32 
33 DEFINE_WORKLOAD(callchain);
34