mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
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>
53 lines
824 B
C
53 lines
824 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <pthread.h>
|
|
#include <stdlib.h>
|
|
#include <signal.h>
|
|
#include <unistd.h>
|
|
#include <linux/compiler.h>
|
|
#include "../tests.h"
|
|
|
|
static volatile int a;
|
|
static volatile sig_atomic_t done;
|
|
|
|
static void sighandler(int sig __maybe_unused)
|
|
{
|
|
done = 1;
|
|
}
|
|
|
|
static inline void __attribute__((always_inline)) leaf(int b)
|
|
{
|
|
again:
|
|
a += b;
|
|
if (!done)
|
|
goto again;
|
|
}
|
|
|
|
static inline void __attribute__((always_inline)) middle(int b)
|
|
{
|
|
leaf(b);
|
|
}
|
|
|
|
static noinline void parent(int b)
|
|
{
|
|
middle(b);
|
|
}
|
|
|
|
static int inlineloop(int argc, const char **argv)
|
|
{
|
|
int sec = 1;
|
|
|
|
pthread_setname_np(pthread_self(), "perf-inlineloop");
|
|
if (argc > 0)
|
|
sec = atoi(argv[0]);
|
|
|
|
signal(SIGINT, sighandler);
|
|
signal(SIGALRM, sighandler);
|
|
alarm(sec);
|
|
|
|
parent(sec);
|
|
|
|
return 0;
|
|
}
|
|
|
|
DEFINE_WORKLOAD(inlineloop);
|