50035446 |
1 | /* test-mark.c |
2 | * |
3 | */ |
4 | |
5 | #include <linux/module.h> |
6 | #include <linux/proc_fs.h> |
7 | #include <linux/sched.h> |
8 | #include <linux/timex.h> |
9 | #include <linux/marker.h> |
10 | #include <asm/ptrace.h> |
11 | |
12 | //asm volatile (""); |
13 | struct proc_dir_entry *pentry = NULL; |
14 | |
15 | static inline void test(unsigned long arg) |
16 | { |
17 | //asm volatile (""); |
18 | trace_mark(test_marker, "arg1 %lu arg2 %p", arg, current); |
19 | } |
20 | |
21 | static int my_open(struct inode *inode, struct file *file) |
22 | { |
23 | unsigned int i; |
24 | cycles_t cycles1, cycles2; |
25 | unsigned long flags; |
26 | |
27 | local_irq_save(flags); |
28 | rdtsc_barrier(); |
29 | cycles1 = get_cycles(); |
30 | rdtsc_barrier(); |
31 | for(i=0; i<20000; i++) { |
32 | test(i); |
33 | } |
34 | rdtsc_barrier(); |
35 | cycles2 = get_cycles(); |
36 | rdtsc_barrier(); |
37 | local_irq_restore(flags); |
38 | printk("cycles : %llu\n", cycles2-cycles1); |
39 | return -EPERM; |
40 | } |
41 | |
42 | |
43 | static struct file_operations my_operations = { |
44 | .open = my_open, |
45 | }; |
46 | |
47 | int init_module(void) |
48 | { |
49 | pentry = create_proc_entry("testmark", 0444, NULL); |
50 | if (pentry) |
51 | pentry->proc_fops = &my_operations; |
52 | |
53 | return 0; |
54 | } |
55 | |
56 | void cleanup_module(void) |
57 | { |
58 | remove_proc_entry("testmark", NULL); |
59 | } |
60 | |
61 | MODULE_LICENSE("GPL"); |
62 | MODULE_AUTHOR("Mathieu Desnoyers"); |
63 | MODULE_DESCRIPTION("Marker Test"); |
64 | |