From 2bbb1caba4eb05d4f1aae2473caf6a627d234158 Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 13 Aug 2008 23:08:53 +0000 Subject: [PATCH] add test prefix speed git-svn-id: http://ltt.polymtl.ca/svn@3018 04897980-b3bd-0310-b5e0-8ef037075253 --- trunk/tests/kernel/Makefile | 1 + trunk/tests/kernel/test-prefix-speed.c | 139 +++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 trunk/tests/kernel/test-prefix-speed.c diff --git a/trunk/tests/kernel/Makefile b/trunk/tests/kernel/Makefile index 5d68be3a..a940d08b 100644 --- a/trunk/tests/kernel/Makefile +++ b/trunk/tests/kernel/Makefile @@ -15,6 +15,7 @@ endif #obj-m += test-sys_call.o # obj-m += test-bug.o obj-m += test-nop-speed.o + obj-m += test-prefix-speed.o # obj-m += test-cmpxchg-nolock2.o # obj-m += test-trace-speed.o # obj-m += test-rcu-speed.o diff --git a/trunk/tests/kernel/test-prefix-speed.c b/trunk/tests/kernel/test-prefix-speed.c new file mode 100644 index 00000000..2ad63fcb --- /dev/null +++ b/trunk/tests/kernel/test-prefix-speed.c @@ -0,0 +1,139 @@ +/* test-nop-speed.c + * + */ + +#include +#include +#include +#include +#include +#include + +#define NR_TESTS 10000000 + +int var, var2; +atomic64_t atomicval; + +struct proc_dir_entry *pentry = NULL; + + +static inline long test_nop_atomic64_add_return(long i, atomic64_t *v) +{ + long __i = i; + asm volatile(".byte 0x90;" + "xaddq %0, %1;" + : "+r" (i), "+m" (v->counter) + : : "memory"); + return i + __i; +} + +static inline long test_prefix_atomic64_add_return(long i, atomic64_t *v) +{ + long __i = i; + asm volatile(".byte 0x3E;" + "xaddq %0, %1;" + : "+r" (i), "+m" (v->counter) + : : "memory"); + return i + __i; +} + +static inline long test_lock_atomic64_add_return(long i, atomic64_t *v) +{ + long __i = i; + asm volatile(".byte 0xf0;" + "xaddq %0, %1;" + : "+r" (i), "+m" (v->counter) + : : "memory"); + return i + __i; +} + + + +void empty(void) +{ + asm volatile (""); + var += 50; + var /= 10; + var *= var2; +} + +void testnop(void) +{ + test_nop_atomic64_add_return(5, &atomicval); + var += 50; + var /= 10; + var *= var2; +} + +void testprefix(void) +{ + test_prefix_atomic64_add_return(5, &atomicval); + var += 50; + var /= 10; + var *= var2; +} + +void testlock(void) +{ + test_lock_atomic64_add_return(5, &atomicval); + var += 50; + var /= 10; + var *= var2; +} + + + +void perform_test(const char *name, void (*callback)(void)) +{ + unsigned int i; + cycles_t cycles1, cycles2; + unsigned long flags; + + local_irq_save(flags); + rdtsc_barrier(); + cycles1 = get_cycles(); + rdtsc_barrier(); + for(i=0; iproc_fops = &my_operations; + + return 0; +} + +void cleanup_module(void) +{ + remove_proc_entry("testnops", NULL); +} + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("NOP Test"); -- 2.34.1