From 8ba2d0ad0dd53dfb7d074df725acd0fb1792f4e6 Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 13 Aug 2008 23:18:01 +0000 Subject: [PATCH] update git-svn-id: http://ltt.polymtl.ca/svn@3021 04897980-b3bd-0310-b5e0-8ef037075253 --- trunk/tests/kernel/test-prefix-speed-32.c | 139 ++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 trunk/tests/kernel/test-prefix-speed-32.c diff --git a/trunk/tests/kernel/test-prefix-speed-32.c b/trunk/tests/kernel/test-prefix-speed-32.c new file mode 100644 index 00000000..63927d36 --- /dev/null +++ b/trunk/tests/kernel/test-prefix-speed-32.c @@ -0,0 +1,139 @@ +/* test-nop-speed.c + * + */ + +#include +#include +#include +#include +#include +#include + +#define NR_TESTS 10000000 + +int var, var2; +atomic_t atomicval; + +struct proc_dir_entry *pentry = NULL; + + +static inline int test_nop_atomic_add_return(int i, atomic_t *v) +{ + int __i = i; + asm volatile(".byte 0x90;" + "xaddl %0, %1;" + : "+r" (i), "+m" (v->counter) + : : "memory"); + return i + __i; +} + +static inline int test_prefix_atomic_add_return(int i, atomic_t *v) +{ + int __i = i; + asm volatile(".byte 0x3E;" + "xaddl %0, %1;" + : "+r" (i), "+m" (v->counter) + : : "memory"); + return i + __i; +} + +static inline int test_lock_atomic_add_return(int i, atomic_t *v) +{ + int __i = i; + asm volatile(".byte 0xf0;" + "xaddl %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_atomic_add_return(5, &atomicval); + var += 50; + var /= 10; + var *= var2; +} + +void testprefix(void) +{ + test_prefix_atomic_add_return(5, &atomicval); + var += 50; + var /= 10; + var *= var2; +} + +void testlock(void) +{ + test_lock_atomic_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("testprefix", NULL); +} + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("prefix test"); -- 2.34.1