#include #include #include #include #define MAX_LOOP 1000 #define MAX_CALL 10 #define MAX_STACK 32 unsigned long stack_entries[MAX_STACK]; void stackdump(void) { struct stack_trace st; st.max_entries = MAX_STACK; st.entries = stack_entries; save_stack_trace(&st); } void alpha(unsigned long call) { if (call) alpha(--call); else stackdump(); } static void bench_loop(void) { u64 st, ed; unsigned long count; unsigned long flags; pr_info("Start benchmarking.\n"); local_irq_save(flags); st = get_cycles(); for (count = 0; count < MAX_LOOP; count++) alpha(MAX_CALL); ed = get_cycles(); local_irq_restore(flags); pr_info("End benchmarking. Elapsed: %lu cycles, loop count:%lu\n", (unsigned long)(ed - st), count); } static int __init bench_init(void) { bench_loop(); return 0; } static void __exit bench_exit(void) { } module_init(bench_init) module_exit(bench_exit) MODULE_LICENSE("GPL");