6f3f4fb57363029231eda3b4e7b76f9b41ca6879
4 * Copyright 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
5 * Distributed under GPLv2
8 #include <linux/jiffies.h>
9 #include <linux/compiler.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/math64.h>
13 #include <linux/spinlock.h>
14 #include <linux/seqlock.h>
15 #include <linux/cpumask.h>
16 #include <linux/smp.h>
17 #include <asm/timex.h>
18 #include <asm/system.h>
21 #include <linux/trace-clock.h>
22 #define get_timestamp trace_clock_read64
24 #define get_timestamp get_cycles
27 #define NR_LOOPS 20000
31 static void do_testbaseline(void)
35 cycles_t time1
, time2
, time
;
38 local_irq_save(flags
);
40 time1
= get_timestamp();
41 for (i
= 0; i
< NR_LOOPS
; i
++) {
44 time2
= get_timestamp();
45 local_irq_restore(flags
);
49 printk(KERN_ALERT
"test results: time for baseline\n");
50 printk(KERN_ALERT
"number of loops: %d\n", NR_LOOPS
);
51 printk(KERN_ALERT
"total time: %llu\n", (unsigned long long)time
);
52 time
= div_u64_rem(time
, NR_LOOPS
, &rem
);
53 printk(KERN_ALERT
"-> baseline takes %llu cycles\n", (unsigned long long)time
);
54 printk(KERN_ALERT
"test end\n");
57 static void remote_wmb(void *info
)
62 static void do_test_ipi(void)
66 cycles_t time1
, time2
, time
;
70 cpu
= smp_processor_id();
75 time1
= get_timestamp();
76 for (i
= 0; i
< NR_LOOPS
; i
++) {
77 smp_call_function_single(cpu
, remote_wmb
, NULL
, 1);
79 time2
= get_timestamp();
83 printk(KERN_ALERT
"test results: time for ipi\n");
84 printk(KERN_ALERT
"number of loops: %d\n", NR_LOOPS
);
85 printk(KERN_ALERT
"total time: %llu\n", (unsigned long long)time
);
86 time
= div_u64_rem(time
, NR_LOOPS
, &rem
);
87 printk(KERN_ALERT
"-> ipi takes %llu cycles\n", (unsigned long long)time
);
88 printk(KERN_ALERT
"test end\n");
91 static void do_test_wmb(void)
94 cycles_t time1
, time2
, time
;
98 time1
= get_timestamp();
99 for (i
= 0; i
< NR_LOOPS
; i
++) {
102 time2
= get_timestamp();
104 time
= time2
- time1
;
106 printk(KERN_ALERT
"test results: time for ipi\n");
107 printk(KERN_ALERT
"number of loops: %d\n", NR_LOOPS
);
108 printk(KERN_ALERT
"total time: %llu\n", (unsigned long long)time
);
109 time
= div_u64_rem(time
, NR_LOOPS
, &rem
);
110 printk(KERN_ALERT
"-> ipi takes %llu cycles\n", (unsigned long long)time
);
111 printk(KERN_ALERT
"test end\n");
114 static int ltt_test_init(void)
116 printk(KERN_ALERT
"test init\n");
118 printk(KERN_ALERT
"Number of active CPUs : %d\n", num_online_cpus());
122 return -EAGAIN
; /* Fail will directly unload the module */
125 static void ltt_test_exit(void)
127 printk(KERN_ALERT
"test exit\n");
130 module_init(ltt_test_init
)
131 module_exit(ltt_test_exit
)
133 MODULE_LICENSE("GPL");
134 MODULE_AUTHOR("Mathieu Desnoyers");
135 MODULE_DESCRIPTION("Test read lock speed");
This page took 0.032082 seconds and 3 git commands to generate.