summaryrefslogtreecommitdiff
path: root/tools/perf/tests/workloads/callchain.c
blob: abbb406ba90b30a012620f46c6e84a5661066b76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "../tests.h"

/*
 * Mark as noinline to establish the call chain, and avoid the static
 * annotation to prevent LTO from renaming the functions.
 */
noinline void callchain_do_syscall(void);
noinline void callchain_foo(void);
noinline int callchain(int argc, const char **argv);

noinline void callchain_do_syscall(void)
{
	syscall(SYS_gettid);
}

noinline void callchain_foo(void)
{
	callchain_do_syscall();
}

noinline int callchain(int argc __maybe_unused,
		       const char **argv __maybe_unused)
{
	callchain_foo();

	return 0;
}

DEFINE_WORKLOAD(callchain);