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 | #include <linux/string.h> |
13 | |
14 | #define NR_LOOPS 100000 |
15 | |
16 | |
17 | #define COPYLEN 4096 |
18 | char test[COPYLEN]; |
19 | char src[COPYLEN] = "aaaaaaaaaaaa"; |
20 | |
21 | struct proc_dir_entry *pentry = NULL; |
22 | |
23 | static int my_open(struct inode *inode, struct file *file) |
24 | { |
25 | unsigned int i; |
26 | unsigned long flags; |
27 | cycles_t time1, time2; |
28 | |
29 | local_irq_save(flags); |
30 | time1 = get_cycles(); |
31 | for(i=0; i<NR_LOOPS; i++) { |
32 | MARK(subsys_mark1, "%d %p", 1, NULL); |
33 | //memcpy(test, src, COPYLEN); |
34 | } |
35 | time2 = get_cycles(); |
36 | local_irq_restore(flags); |
37 | printk("time delta (cycles): %llu\n", time2-time1); |
38 | |
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 | |