traploop.c 514 B

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