drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / tools / perf / tests / workloads / sqrtloop.c
blobccc94c6a6676a3e2af6db487e21943723cd66916
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <math.h>
3 #include <signal.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <linux/compiler.h>
7 #include <sys/wait.h>
8 #include "../tests.h"
10 static volatile sig_atomic_t done;
12 static void sighandler(int sig __maybe_unused)
14 done = 1;
17 static int __sqrtloop(int sec)
19 signal(SIGALRM, sighandler);
20 alarm(sec);
22 while (!done)
23 (void)sqrt(rand());
24 return 0;
27 static int sqrtloop(int argc, const char **argv)
29 int sec = 1;
31 if (argc > 0)
32 sec = atoi(argv[0]);
34 switch (fork()) {
35 case 0:
36 return __sqrtloop(sec);
37 case -1:
38 return -1;
39 default:
40 wait(NULL);
42 return 0;
45 DEFINE_WORKLOAD(sqrtloop);