update
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 22 Aug 2007 00:33:32 +0000 (00:33 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 22 Aug 2007 00:33:32 +0000 (00:33 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2594 04897980-b3bd-0310-b5e0-8ef037075253

tests/kernel/Makefile
tests/kernel/test-showval.c [new file with mode: 0644]
tests/kernel/test-slub.c [new file with mode: 0644]
tests/kernel/test-slub2.c [new file with mode: 0644]

index af5ffd813a5d98c07a3af620e85ea203cf9cfe0c..6c840fee538883e5488dad9709a1617adfa43ab5 100644 (file)
@@ -12,9 +12,16 @@ ifneq ($(CONFIG_LTT),)
        #obj-m += ltt-probe-tests.o
        #obj-m += test-time-probe3.o
 endif
+       obj-m += test-slub.o
+       obj-m += test-slub2.o
+       obj-m += test-showval.o
        #obj-m += cond_call.o
        #obj-m += cond_call2.o
-       obj-m += test-irq-latency.o
+#      obj-m += test-irq-latency.o
+#      obj-m += test-kprobes2.o
+#      obj-m += test-imval.o
+       #obj-m += test-imval-bug.o
+#      obj-m += test-imvalw.o
        #obj-m += list-mark.o
        #obj-m += test-rodata.o
        #obj-m += test-tlb.o
@@ -35,6 +42,7 @@ endif
 #      obj-m += test-cmpxchg.o
 #      obj-m += test-cmpxchg-nolock.o
        obj-m += test-cmpxchg-nolock2.o
+       obj-m += test-cmpxchg8b.o
 #      obj-m += test-spinlock.o
 #      obj-m += test-inc.o
 #      obj-m += test-inc-nolock.o
diff --git a/tests/kernel/test-showval.c b/tests/kernel/test-showval.c
new file mode 100644 (file)
index 0000000..18fcaa6
--- /dev/null
@@ -0,0 +1,35 @@
+/* test-slub.c
+ *
+ * Compare local cmpxchg with irq disable / enable with cmpxchg_local for slub.
+ */
+
+
+#include <linux/jiffies.h>
+#include <linux/compiler.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/calc64.h>
+#include <asm/timex.h>
+#include <asm/system.h>
+
+extern atomic_t slub_fast_count;
+extern atomic_t slub_slow_count;
+
+static int slub_test_init(void)
+{
+       printk("Fast slub free: %u\n", atomic_read(&slub_fast_count));
+       printk("Slow slub free: %u\n", atomic_read(&slub_slow_count));
+       return -EAGAIN; /* Fail will directly unload the module */
+}
+
+static void slub_test_exit(void)
+{
+       printk(KERN_ALERT "test exit\n");
+}
+
+module_init(slub_test_init)
+module_exit(slub_test_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("SLUB test");
diff --git a/tests/kernel/test-slub.c b/tests/kernel/test-slub.c
new file mode 100644 (file)
index 0000000..88cb59c
--- /dev/null
@@ -0,0 +1,182 @@
+/* test-slub.c
+ *
+ * Compare local cmpxchg with irq disable / enable with cmpxchg_local for slub.
+ */
+
+
+#include <linux/jiffies.h>
+#include <linux/compiler.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/calc64.h>
+#include <asm/timex.h>
+#include <asm/system.h>
+
+#define TEST_COUNT 10000
+
+static int slub_test_init(void)
+{
+       void **v = kmalloc(TEST_COUNT * sizeof(void *), GFP_KERNEL);
+       unsigned int i;
+       cycles_t time1, time2, time;
+       long rem;
+       int size;
+
+       printk(KERN_ALERT "test init\n");
+
+       printk(KERN_ALERT "SLUB Performance testing\n");
+       printk(KERN_ALERT "========================\n");
+       printk(KERN_ALERT "1. Kmalloc: Repeatedly allocate then free test\n");
+       for (size = 8; size <= PAGE_SIZE << 2; size <<= 1) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       v[i] = kmalloc(size, GFP_KERNEL);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmalloc(%d) = \n", i, size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kfree(v[i]);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kfree = \n", i);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+
+       printk(KERN_ALERT "2. Kmalloc: alloc/free test\n");
+       for (size = 8; size <= PAGE_SIZE << 2; size <<= 1) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kfree(kmalloc(size, GFP_KERNEL));
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmalloc(%d)/kfree = \n", i, size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+#if 0
+       printk(KERN_ALERT "3. kmem_cache_alloc: Repeatedly allocate then free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size ++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       v[i] = kmem_cache_alloc(kmalloc_caches + size, GFP_KERNEL);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_alloc(%d) = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size, v[i]);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmem_cache_free = \n", i);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+
+       printk(KERN_ALERT "4. kmem_cache_alloc: alloc/free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size,
+                               kmem_cache_alloc(kmalloc_caches + size,
+                                                       GFP_KERNEL));
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_alloc(%d)/kmem_cache_free = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+       printk(KERN_ALERT "5. kmem_cache_zalloc: Repeatedly allocate then free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size ++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       v[i] = kmem_cache_zalloc(kmalloc_caches + size, GFP_KERNEL);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_zalloc(%d) = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size, v[i]);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmem_cache_free = \n", i);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+
+       printk(KERN_ALERT "6. kmem_cache_zalloc: alloc/free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size,
+                               kmem_cache_zalloc(kmalloc_caches + size,
+                                                       GFP_KERNEL));
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_zalloc(%d)/kmem_cache_free = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+       }
+#endif //0
+       kfree(v);
+       return -EAGAIN; /* Fail will directly unload the module */
+}
+
+static void slub_test_exit(void)
+{
+       printk(KERN_ALERT "test exit\n");
+}
+
+module_init(slub_test_init)
+module_exit(slub_test_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("SLUB test");
diff --git a/tests/kernel/test-slub2.c b/tests/kernel/test-slub2.c
new file mode 100644 (file)
index 0000000..5d302a3
--- /dev/null
@@ -0,0 +1,191 @@
+/* test-slub.c
+ *
+ * Compare local cmpxchg with irq disable / enable with cmpxchg_local for slub.
+ */
+
+
+#include <linux/jiffies.h>
+#include <linux/compiler.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/calc64.h>
+#include <asm/timex.h>
+#include <asm/system.h>
+
+#define TEST_COUNT 10000
+
+extern atomic_t slub_fast_count;
+extern atomic_t slub_slow_count;
+
+static int slub_test_init(void)
+{
+       void **v = kmalloc(TEST_COUNT * sizeof(void *), GFP_KERNEL);
+       unsigned int i;
+       cycles_t time1, time2, time;
+       long rem;
+       int size;
+
+       printk(KERN_ALERT "test init\n");
+
+       printk("Fast slub free: %u\n", atomic_read(&slub_fast_count));
+       printk("Slow slub free: %u\n", atomic_read(&slub_slow_count));
+       printk(KERN_ALERT "SLUB Performance testing\n");
+       printk(KERN_ALERT "========================\n");
+       printk(KERN_ALERT "1. Kmalloc: Repeatedly allocate then free test\n");
+       for (size = 8; size <= PAGE_SIZE << 2; size <<= 1) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       v[i] = kmalloc(size, GFP_KERNEL);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmalloc(%d) = \n", i, size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kfree(v[i]);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kfree = \n", i);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+       printk("Fast slub free: %u\n", atomic_read(&slub_fast_count));
+       printk("Slow slub free: %u\n", atomic_read(&slub_slow_count));
+
+       printk(KERN_ALERT "2. Kmalloc: alloc/free test\n");
+       for (size = 8; size <= PAGE_SIZE << 2; size <<= 1) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kfree(kmalloc(size, GFP_KERNEL));
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmalloc(%d)/kfree = \n", i, size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+       printk("Fast slub free: %u\n", atomic_read(&slub_fast_count));
+       printk("Slow slub free: %u\n", atomic_read(&slub_slow_count));
+#if 0
+       printk(KERN_ALERT "3. kmem_cache_alloc: Repeatedly allocate then free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size ++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       v[i] = kmem_cache_alloc(kmalloc_caches + size, GFP_KERNEL);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_alloc(%d) = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size, v[i]);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmem_cache_free = \n", i);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+
+       printk(KERN_ALERT "4. kmem_cache_alloc: alloc/free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size,
+                               kmem_cache_alloc(kmalloc_caches + size,
+                                                       GFP_KERNEL));
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_alloc(%d)/kmem_cache_free = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+       printk(KERN_ALERT "5. kmem_cache_zalloc: Repeatedly allocate then free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size ++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       v[i] = kmem_cache_zalloc(kmalloc_caches + size, GFP_KERNEL);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_zalloc(%d) = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size, v[i]);
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%i times kmem_cache_free = \n", i);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+       }
+
+       printk(KERN_ALERT "6. kmem_cache_zalloc: alloc/free test\n");
+       for (size = 3; size <= PAGE_SHIFT; size++) {
+               time1 = get_cycles();
+               for (i = 0; i < TEST_COUNT; i++) {
+                       kmem_cache_free(kmalloc_caches + size,
+                               kmem_cache_zalloc(kmalloc_caches + size,
+                                                       GFP_KERNEL));
+               }
+               time2 = get_cycles();
+               time = time2 - time1;
+
+               printk(KERN_ALERT "%d times kmem_cache_zalloc(%d)/kmem_cache_free = \n", i, 1 << size);
+               printk(KERN_ALERT "number of loops: %d\n", TEST_COUNT);
+               printk(KERN_ALERT "total time: %llu\n", time);
+               time = div_long_long_rem(time, TEST_COUNT, &rem);
+               printk(KERN_ALERT "-> %llu cycles\n", time);
+
+       }
+#endif //0
+       kfree(v);
+       return -EAGAIN; /* Fail will directly unload the module */
+}
+
+static void slub_test_exit(void)
+{
+       printk(KERN_ALERT "test exit\n");
+}
+
+module_init(slub_test_init)
+module_exit(slub_test_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("SLUB test");
This page took 0.029559 seconds and 4 git commands to generate.