Loading...
Note: File does not exist in v3.5.6.
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
9static volatile sig_atomic_t done;
10static volatile unsigned count;
11
12/* We want to check this symbol in perf report */
13noinline void test_loop(void);
14
15static void sighandler(int sig __maybe_unused)
16{
17 done = 1;
18}
19
20noinline void test_loop(void)
21{
22 while (!done)
23 count++;
24}
25
26static void *thfunc(void *arg)
27{
28 void (*loop_fn)(void) = arg;
29
30 loop_fn();
31 return NULL;
32}
33
34static int thloop(int argc, const char **argv)
35{
36 int sec = 1;
37 pthread_t th;
38
39 if (argc > 0)
40 sec = atoi(argv[0]);
41
42 signal(SIGINT, sighandler);
43 signal(SIGALRM, sighandler);
44 alarm(sec);
45
46 pthread_create(&th, NULL, thfunc, test_loop);
47 test_loop();
48 pthread_join(th, NULL);
49
50 return 0;
51}
52
53DEFINE_WORKLOAD(thloop);