leafloop.c (7ae9fb1b7ecbb5d85d07857943f677fd1a559b18) | leafloop.c (ff16aeb9b83441b8458d4235496cf320189a0c60) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ | 1/* SPDX-License-Identifier: GPL-2.0 */ |
2#include <signal.h> |
|
2#include <stdlib.h> 3#include <linux/compiler.h> | 3#include <stdlib.h> 4#include <linux/compiler.h> |
5#include <unistd.h> |
|
4#include "../tests.h" 5 6/* We want to check these symbols in perf script */ 7noinline void leaf(volatile int b); 8noinline void parent(volatile int b); 9 10static volatile int a; | 6#include "../tests.h" 7 8/* We want to check these symbols in perf script */ 9noinline void leaf(volatile int b); 10noinline void parent(volatile int b); 11 12static volatile int a; |
13static volatile sig_atomic_t done; |
|
11 | 14 |
15static void sighandler(int sig __maybe_unused) 16{ 17 done = 1; 18} 19 |
|
12noinline void leaf(volatile int b) 13{ | 20noinline void leaf(volatile int b) 21{ |
14 for (;;) | 22 while (!done) |
15 a += b; 16} 17 18noinline void parent(volatile int b) 19{ 20 leaf(b); 21} 22 23static int leafloop(int argc, const char **argv) 24{ | 23 a += b; 24} 25 26noinline void parent(volatile int b) 27{ 28 leaf(b); 29} 30 31static int leafloop(int argc, const char **argv) 32{ |
25 int c = 1; | 33 int sec = 1; |
26 27 if (argc > 0) | 34 35 if (argc > 0) |
28 c = atoi(argv[0]); | 36 sec = atoi(argv[0]); |
29 | 37 |
30 parent(c); | 38 signal(SIGINT, sighandler); 39 signal(SIGALRM, sighandler); 40 alarm(sec); 41 42 parent(sec); |
31 return 0; 32} 33 34DEFINE_WORKLOAD(leafloop); | 43 return 0; 44} 45 46DEFINE_WORKLOAD(leafloop); |