xref: /linux/tools/perf/tests/workloads/traploop.c (revision 68a052239fc4b351e961f698b824f7654a346091)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdlib.h>
3 #include "../tests.h"
4 
5 #define BENCH_RUNS 999999
6 
7 #ifdef __aarch64__
8 static void trap_bench(void)
9 {
10 	unsigned long val;
11 
12 	asm("mrs %0, ID_AA64ISAR0_EL1" : "=r" (val));   /* TRAP + ERET */
13 }
14 #else
15 static void trap_bench(void) { }
16 #endif
17 
18 static int traploop(int argc, const char **argv)
19 {
20 	int num_loops = BENCH_RUNS;
21 
22 	if (argc > 0)
23 		num_loops = atoi(argv[0]);
24 
25 	for (int i = 0; i < num_loops; i++)
26 		trap_bench();
27 
28 	return 0;
29 }
30 
31 DEFINE_WORKLOAD(traploop);
32