bc82195a |
1 | /* test-micro-loop-marker.c |
2 | * |
3 | * Execute a marker in a loop |
4 | */ |
5 | |
6 | #include <linux/marker.h> |
7 | #include <linux/module.h> |
8 | #include <linux/proc_fs.h> |
9 | #include <linux/sched.h> |
10 | #include <asm/ptrace.h> |
11 | #include <linux/timex.h> |
12 | |
13 | #define NR_LOOPS 100000 |
14 | |
15 | struct proc_dir_entry *pentry = NULL; |
16 | |
17 | static int my_open(struct inode *inode, struct file *file) |
18 | { |
19 | volatile unsigned int i; |
20 | unsigned long flags; |
21 | cycles_t time1, time2; |
22 | |
23 | local_irq_save(flags); |
24 | time1 = get_cycles(); |
25 | for(i=0; i<NR_LOOPS; i++) { |
26 | MARK(subsys_mark1, "%d %p", 1, NULL); |
27 | } |
28 | time2 = get_cycles(); |
29 | local_irq_restore(flags); |
30 | printk("time delta (cycles): %llu\n", time2-time1); |
31 | |
32 | return -EPERM; |
33 | } |
34 | |
35 | |
36 | static struct file_operations my_operations = { |
37 | .open = my_open, |
38 | }; |
39 | |
40 | int init_module(void) |
41 | { |
42 | pentry = create_proc_entry("testmark", 0444, NULL); |
43 | if (pentry) |
44 | pentry->proc_fops = &my_operations; |
45 | |
46 | return 0; |
47 | } |
48 | |
49 | void cleanup_module(void) |
50 | { |
51 | remove_proc_entry("testmark", NULL); |
52 | } |
53 | |
54 | MODULE_LICENSE("GPL"); |
55 | MODULE_AUTHOR("Mathieu Desnoyers"); |
56 | MODULE_DESCRIPTION("Marker Test"); |
57 | |