update test
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 13 Aug 2008 16:55:31 +0000 (16:55 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 13 Aug 2008 16:55:31 +0000 (16:55 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@3012 04897980-b3bd-0310-b5e0-8ef037075253

trunk/tests/kernel/Makefile
trunk/tests/kernel/test-nop-speed.c [new file with mode: 0644]

index a246c501db0fbc89ef9e92ae8ef97b21d5c6462b..5d68be3a2c9d59e178eb29cfb7944db5f3fd70ec 100644 (file)
@@ -14,12 +14,13 @@ ifneq ($(CONFIG_LTT),)
 endif
        #obj-m += test-sys_call.o
 #      obj-m += test-bug.o
-       obj-m += test-cmpxchg-nolock2.o
-       obj-m += test-trace-speed.o
-       obj-m += test-rcu-speed.o
-       obj-m += test-fct-speed.o
-       obj-m += test-int3-speed.o
-       obj-m += test-kprobes2.o
+       obj-m += test-nop-speed.o
+#      obj-m += test-cmpxchg-nolock2.o
+#      obj-m += test-trace-speed.o
+#      obj-m += test-rcu-speed.o
+#      obj-m += test-fct-speed.o
+#      obj-m += test-int3-speed.o
+#      obj-m += test-kprobes2.o
        #obj-m += test-mark-speed.o
        #obj-m += test-mark-speed-edit.o
        #obj-m += test-mark-speed-opt.o
diff --git a/trunk/tests/kernel/test-nop-speed.c b/trunk/tests/kernel/test-nop-speed.c
new file mode 100644 (file)
index 0000000..f75af52
--- /dev/null
@@ -0,0 +1,104 @@
+/* test-nop-speed.c
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/sched.h>
+#include <linux/timex.h>
+#include <linux/marker.h>
+#include <asm/ptrace.h>
+
+#define NR_TESTS 20000
+
+struct proc_dir_entry *pentry = NULL;
+
+void empty(void)
+{
+       asm volatile ("");
+}
+
+void twobytesjump(void)
+{
+       asm volatile ("jmp 1f\n\t"
+               ".byte 0x00, 0x00, 0x00\n\t"
+               "1:\n\t");
+}
+
+void fivebytesjump(void)
+{
+       asm (".byte 0xe9, 0x00, 0x00, 0x00, 0x00\n\t");
+}
+
+void threetwonops(void)
+{
+       asm (".byte 0x66,0x66,0x90,0x66,0x90\n\t");
+}
+
+void fivebytesnop(void)
+{
+       asm (".byte 0x66,0x66,0x66,0x66,0x90\n\t");
+}
+
+void fivebytespsixnop(void)
+{
+       asm (".byte 0x0f,0x1f,0x44,0x00,0\n\t");
+}
+
+void perform_test(const char *name, void (*callback)(void))
+{
+       unsigned int i;
+       cycles_t cycles1, cycles2;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       rdtsc_barrier();
+       cycles1 = get_cycles();
+       rdtsc_barrier();
+       for(i=0; i<NR_TESTS; i++) {
+               callback();
+       }
+       rdtsc_barrier();
+       cycles2 = get_cycles();
+       rdtsc_barrier();
+       local_irq_restore(flags);
+       printk("test %s cycles : %llu\n", name, cycles2-cycles1);
+}
+
+static int my_open(struct inode *inode, struct file *file)
+{
+       printk("NR_TESTS %d\n", NR_TESTS);
+
+       perform_test("empty", empty);
+       perform_test("2-bytes jump", twobytesjump);
+       perform_test("5-bytes jump", fivebytesjump);
+       perform_test("3/2 nops", threetwonops);
+       perform_test("5-bytes nop with long prefix", fivebytesnop);
+       perform_test("5-bytes P6 nop", fivebytespsixnop);
+
+       return -EPERM;
+}
+
+
+static struct file_operations my_operations = {
+       .open = my_open,
+};
+
+int init_module(void)
+{
+       pentry = create_proc_entry("testnops", 0444, NULL);
+       if (pentry)
+               pentry->proc_fops = &my_operations;
+
+       return 0;
+}
+
+void cleanup_module(void)
+{
+       remove_proc_entry("testnops", NULL);
+}
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Marker Test");
+
This page took 0.025369 seconds and 4 git commands to generate.