c6a191ef |
1 | /* test-async-tsc.c |
2 | * |
3 | * test async tsc on AMD. |
4 | */ |
5 | |
6 | |
7 | #include <asm/atomic.h> |
8 | #include <linux/module.h> |
9 | #include <asm/timex.h> |
10 | #include <asm/hpet.h> |
11 | #include <asm/io.h> |
13ab9fcb |
12 | #include <linux/clocksource.h> |
13 | #include <linux/ltt.h> |
14 | #include <asm/cacheflush.h> |
15 | |
16 | //#define NR_LOOPS 10000 |
17 | #define NR_LOOPS 10 |
18 | |
19 | extern cycle_t read_hpet(void); |
c6a191ef |
20 | |
21 | static int __init test_init(void) |
22 | { |
23 | int i; |
24 | cycles_t time1, time2; |
25 | volatile unsigned long myval; |
13ab9fcb |
26 | int sync_save; /* racy */ |
c6a191ef |
27 | |
13ab9fcb |
28 | sync_save = ltt_tsc_is_sync; |
29 | ltt_tsc_is_sync = 0; |
30 | //ltt_tsc_is_sync = 1; |
31 | return -EPERM; //TEST ! |
32 | myval = ltt_get_timestamp64(); |
c6a191ef |
33 | time1 = get_cycles(); |
13ab9fcb |
34 | for (i=0; i < NR_LOOPS; i++) { |
c6a191ef |
35 | //printk("time %llu\n", ltt_tsc_read()); |
13ab9fcb |
36 | //get_cycles_barrier(); |
37 | //myval = get_cycles(); |
38 | //get_cycles_barrier(); |
39 | myval = read_hpet(); |
40 | //clflush(<t_last_tsc); |
41 | //myval = ltt_get_timestamp64(); |
42 | printk("val : %llu\n", (unsigned long long)myval); |
c6a191ef |
43 | } |
44 | time2 = get_cycles(); |
13ab9fcb |
45 | printk("timediff %llu\n", (time2-time1)/NR_LOOPS); |
46 | ltt_tsc_is_sync = sync_save; |
c6a191ef |
47 | return -EPERM; |
48 | } |
49 | |
50 | static void __exit test_exit(void) |
51 | { |
52 | } |
53 | |
54 | module_init(test_init); |
55 | module_exit(test_exit); |
56 | |
57 | MODULE_LICENSE("GPL"); |
58 | MODULE_AUTHOR("Mathieu Desnoyers"); |
59 | MODULE_DESCRIPTION("sync async tsc"); |
60 | |