summaryrefslogtreecommitdiff
path: root/targets/kernel_spin.c
diff options
context:
space:
mode:
Diffstat (limited to 'targets/kernel_spin.c')
-rw-r--r--targets/kernel_spin.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/targets/kernel_spin.c b/targets/kernel_spin.c
new file mode 100644
index 0000000..206b0bd
--- /dev/null
+++ b/targets/kernel_spin.c
@@ -0,0 +1,10 @@
+// A known amount of work: a loop of exactly four instructions, N times
+// (argv[1], default ten million). What the counters are checked against,
+// and the run that tracing overhead is measured on.
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+ unsigned long n = argc > 1 ? strtoul(argv[1], 0, 0) : 10000000;
+ __asm__ volatile("1: dec %0\n nop\n nop\n jnz 1b" : "+r"(n) : : "cc");
+ return 0;
+}