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>
12 #define NR_TESTS 20000
14 struct proc_dir_entry
*pentry
= NULL
;
21 void twobytesjump(void)
23 asm volatile ("jmp 1f\n\t"
24 ".byte 0x00, 0x00, 0x00\n\t"
28 void fivebytesjump(void)
30 asm (".byte 0xe9, 0x00, 0x00, 0x00, 0x00\n\t");
33 void threetwonops(void)
35 asm (".byte 0x66,0x66,0x90,0x66,0x90\n\t");
38 void fivebytesnop(void)
40 asm (".byte 0x66,0x66,0x66,0x66,0x90\n\t");
43 void fivebytespsixnop(void)
45 asm (".byte 0x0f,0x1f,0x44,0x00,0\n\t");
48 void perform_test(const char *name
, void (*callback
)(void))
51 cycles_t cycles1
, cycles2
;
54 local_irq_save(flags
);
56 cycles1
= get_cycles();
58 for(i
=0; i
<NR_TESTS
; i
++) {
62 cycles2
= get_cycles();
64 local_irq_restore(flags
);
65 printk("test %s cycles : %llu\n", name
, cycles2
-cycles1
);
68 static int my_open(struct inode
*inode
, struct file
*file
)
70 printk("NR_TESTS %d\n", NR_TESTS
);
72 perform_test("empty", empty
);
73 perform_test("2-bytes jump", twobytesjump
);
74 perform_test("5-bytes jump", fivebytesjump
);
75 perform_test("3/2 nops", threetwonops
);
76 perform_test("5-bytes nop with long prefix", fivebytesnop
);
77 perform_test("5-bytes P6 nop", fivebytespsixnop
);
83 static struct file_operations my_operations
= {
89 pentry
= create_proc_entry("testnops", 0444, NULL
);
91 pentry
->proc_fops
= &my_operations
;
96 void cleanup_module(void)
98 remove_proc_entry("testnops", NULL
);
101 MODULE_LICENSE("GPL");
102 MODULE_AUTHOR("Mathieu Desnoyers");
103 MODULE_DESCRIPTION("Marker Test");