convert from svn repository: remove tags directory
[lttv.git] / trunk / tests / kernel / test-tsc-sync.c
CommitLineData
31d375f5 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
12static DEFINE_PER_CPU(cycles_t, count) = 0;
13
14static struct timer_list test_timer;
15
feca19f0 16static atomic_t kernel_threads_to_run;
17
18
31d375f5 19/* IPI called on each CPU. */
20static void test_each(void *info)
21{
feca19f0 22 unsigned long flags;
23 local_irq_save(flags);
24 atomic_dec(&kernel_threads_to_run);
25 while(atomic_read(&kernel_threads_to_run))
26 cpu_relax();
63787240 27 __get_cpu_var(count) = get_cycles_sync();
feca19f0 28 local_irq_restore(flags);
31d375f5 29}
30
31static void do_test_timer(unsigned long data)
32{
33 int cpu;
34
feca19f0 35 atomic_set(&kernel_threads_to_run, num_online_cpus());
36
37 smp_call_function(test_each, NULL, 0, 0);
38 test_each(NULL);
31d375f5 39 /* Read all the counters */
40 printk("Counters read from CPU %d\n", smp_processor_id());
41 for_each_online_cpu(cpu) {
42 printk("Read : CPU %d, count %llu\n", cpu,
43 per_cpu(count, cpu));
44 }
45 del_timer(&test_timer);
46 test_timer.expires = jiffies + 1000;
47 add_timer(&test_timer);
48}
49
50static int __init test_init(void)
51{
52 /* initialize the timer that will increment the counter */
53 init_timer(&test_timer);
54 test_timer.function = do_test_timer;
55 test_timer.expires = jiffies + 1;
56 add_timer(&test_timer);
57
58 return 0;
59}
60
61static void __exit test_exit(void)
62{
63 del_timer_sync(&test_timer);
64}
65
66module_init(test_init);
67module_exit(test_exit);
68
69MODULE_LICENSE("GPL");
70MODULE_AUTHOR("Mathieu Desnoyers");
71MODULE_DESCRIPTION("sync tsc test");
72
This page took 0.032458 seconds and 4 git commands to generate.