add teest tsc sync
[lttv.git] / tests / kernel / test-tsc-sync.c
1 /* test-tsc-sync.c
2 *
3 * Test TSC sync
4 */
5
6
7 #include <linux/module.h>
8 #include <linux/timer.h>
9 #include <asm/timex.h>
10 #include <linux/jiffies.h>
11
12 static DEFINE_PER_CPU(cycles_t, count) = 0;
13
14 static struct timer_list test_timer;
15
16 /* IPI called on each CPU. */
17 static void test_each(void *info)
18 {
19 __get_cpu_var(count) = get_cycles();
20 }
21
22 static void do_test_timer(unsigned long data)
23 {
24 int cpu;
25
26 /* Increment the counters */
27 on_each_cpu(test_each, NULL, 0, 1);
28 /* Read all the counters */
29 printk("Counters read from CPU %d\n", smp_processor_id());
30 for_each_online_cpu(cpu) {
31 printk("Read : CPU %d, count %llu\n", cpu,
32 per_cpu(count, cpu));
33 }
34 del_timer(&test_timer);
35 test_timer.expires = jiffies + 1000;
36 add_timer(&test_timer);
37 }
38
39 static int __init test_init(void)
40 {
41 /* initialize the timer that will increment the counter */
42 init_timer(&test_timer);
43 test_timer.function = do_test_timer;
44 test_timer.expires = jiffies + 1;
45 add_timer(&test_timer);
46
47 return 0;
48 }
49
50 static void __exit test_exit(void)
51 {
52 del_timer_sync(&test_timer);
53 }
54
55 module_init(test_init);
56 module_exit(test_exit);
57
58 MODULE_LICENSE("GPL");
59 MODULE_AUTHOR("Mathieu Desnoyers");
60 MODULE_DESCRIPTION("sync tsc test");
61
This page took 0.031245 seconds and 5 git commands to generate.