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