3 * Test time spent in a LTTng instrumentation probe.
7 #include <linux/config.h>
8 #include <linux/jiffies.h>
9 #include <linux/compiler.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
14 #define cmpxchg_up(ptr,o,n)\
15 ((__typeof__(*(ptr)))__cmpxchg_up((ptr),(unsigned long)(o),\
16 (unsigned long)(n),sizeof(*(ptr))))
17 static inline unsigned long __cmpxchg_up(volatile void *ptr
, unsigned long old
,
18 unsigned long new, int size
)
23 __asm__
__volatile__("cmpxchgb %b1,%2"
25 : "q"(new), "m"(*__xg(ptr
)), "0"(old
)
29 __asm__
__volatile__("cmpxchgw %w1,%2"
31 : "r"(new), "m"(*__xg(ptr
)), "0"(old
)
35 __asm__
__volatile__("cmpxchgl %1,%2"
37 : "r"(new), "m"(*__xg(ptr
)), "0"(old
)
45 #define NR_LOOPS 20000
47 volatile int test_val
= 100;
50 static inline void do_test(void)
56 ret
= cmpxchg_up(&test_val
, val
, val
+1);
59 static int ltt_test_init(void)
62 cycles_t time1
, time2
, time
;
63 cycles_t max_time
= 0, min_time
= 18446744073709551615ULL; /* (2^64)-1 */
64 cycles_t tot_time
= 0;
66 printk(KERN_ALERT
"test init\n");
68 local_irq_save(flags
);
70 for(i
=0; i
<NR_LOOPS
; i
++) {
71 //for(int j=0; j<10; j++) {
74 //max_time = max(max_time, time);
75 //min_time = min(min_time, time);
76 //printk("val : %d\n", test_val);
79 local_irq_restore(flags
);
83 printk(KERN_ALERT
"test results : time non locked cmpxchg\n");
84 printk(KERN_ALERT
"number of loops : %d\n", NR_LOOPS
);
85 printk(KERN_ALERT
"total time : %llu\n", tot_time
);
86 //printk(KERN_ALERT "min : %llu\n", min_time);
87 //printk(KERN_ALERT "max : %llu\n", max_time);
89 printk(KERN_ALERT
"test end\n");
91 return -EAGAIN
; /* Fail will directly unload the module */
94 static void ltt_test_exit(void)
96 printk(KERN_ALERT
"test exit\n");
99 module_init(ltt_test_init
)
100 module_exit(ltt_test_exit
)
102 MODULE_LICENSE("GPL");
103 MODULE_AUTHOR("Mathieu Desnoyers");
104 MODULE_DESCRIPTION("Linux Trace Toolkit Test");
This page took 0.067482 seconds and 4 git commands to generate.