]> git.proxmox.com Git - mirror_spl.git/blobdiff - module/splat/splat-kmem.c
Make file headers conform to ZFS style standard
[mirror_spl.git] / module / splat / splat-kmem.c
index cd0000bae67138c3031d645bd155962238d62bf2..282f42d773a2b5c98a4717fc4b4b1dab2d7f92bc 100644 (file)
@@ -1,4 +1,4 @@
-/*****************************************************************************\
+/*
  *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -22,7 +22,7 @@
  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
  *****************************************************************************
  *  Solaris Porting LAyer Tests (SPLAT) Kmem Tests.
-\*****************************************************************************/
+ */
 
 #include <sys/kmem.h>
 #include <sys/kmem_cache.h>
@@ -275,8 +275,8 @@ typedef struct kmem_cache_priv {
        struct file *kcp_file;
        kmem_cache_t *kcp_cache;
        spinlock_t kcp_lock;
-       wait_queue_head_t kcp_ctl_waitq;
-       wait_queue_head_t kcp_thr_waitq;
+       spl_wait_queue_head_t kcp_ctl_waitq;
+       spl_wait_queue_head_t kcp_thr_waitq;
        int kcp_flags;
        int kcp_kct_count;
        kmem_cache_thread_t *kcp_kct[SPLAT_KMEM_THREADS];
@@ -590,6 +590,9 @@ splat_kmem_cache_test(struct file *file, void *arg, char *name,
        kmem_cache_data_t **kcd = NULL;
        int i, rc = 0, objs = 0;
 
+       /* Limit size for low memory machines (1/128 of memory) */
+       size = MIN(size, (physmem * PAGE_SIZE) >> 7);
+
        splat_vprint(file, name,
            "Testing size=%d, align=%d, flags=0x%04x\n",
            size, align, flags);
@@ -619,7 +622,7 @@ splat_kmem_cache_test(struct file *file, void *arg, char *name,
         * it to a single slab for the purposes of this test.
         */
 #ifdef _LP64
-       objs = SPL_KMEM_CACHE_OBJ_PER_SLAB * 4;
+       objs = kcp->kcp_cache->skc_slab_objs * 4;
 #else
        objs = 1;
 #endif
@@ -739,7 +742,7 @@ splat_kmem_cache_thread_test(struct file *file, void *arg, char *name,
        for (i = 0; i < SPLAT_KMEM_THREADS; i++) {
                thr = thread_create(NULL, 0,
                                    splat_kmem_cache_test_thread,
-                                   kcp, 0, &p0, TS_RUN, minclsyspri);
+                                   kcp, 0, &p0, TS_RUN, defclsyspri);
                if (thr == NULL) {
                        rc = -ESRCH;
                        goto out_cache;
@@ -1128,9 +1131,15 @@ out:
 static int
 splat_kmem_test10(struct file *file, void *arg)
 {
-       uint64_t size, alloc, rc = 0;
+       uint64_t size, alloc, maxsize, limit, rc = 0;
+
+#if defined(CONFIG_64BIT)
+       maxsize = (1024 * 1024);
+#else
+       maxsize = (128 * 1024);
+#endif
 
-       for (size = 32; size <= 1024*1024; size *= 2) {
+       for (size = 32; size <= maxsize; size *= 2) {
 
                splat_vprint(file, SPLAT_KMEM_TEST10_NAME, "%-22s  %s", "name",
                             "time (sec)\tslabs       \tobjs    \thash\n");
@@ -1139,8 +1148,10 @@ splat_kmem_test10(struct file *file, void *arg)
 
                for (alloc = 1; alloc <= 1024; alloc *= 2) {
 
-                       /* Skip tests which exceed 1/2 of physical memory. */
-                       if (size * alloc * SPLAT_KMEM_THREADS > physmem / 2)
+                       /* Skip tests which exceed 1/2 of memory. */
+                       limit = MIN(physmem * PAGE_SIZE,
+                           vmem_size(NULL, VMEM_ALLOC | VMEM_FREE)) / 2;
+                       if (size * alloc * SPLAT_KMEM_THREADS > limit)
                                continue;
 
                        rc = splat_kmem_cache_thread_test(file, arg,
@@ -1220,7 +1231,8 @@ splat_kmem_test13(struct file *file, void *arg)
        int i, rc = 0, max_time = 10;
 
        size = 128 * 1024;
-       count = ((physmem * PAGE_SIZE) / 4 / size);
+       count = MIN(physmem * PAGE_SIZE, vmem_size(NULL,
+           VMEM_ALLOC | VMEM_FREE)) / 4 / size;
 
        kcp = splat_kmem_cache_test_kcp_alloc(file, SPLAT_KMEM_TEST13_NAME,
                                              size, 0, 0);
@@ -1340,31 +1352,31 @@ splat_kmem_init(void)
        spin_lock_init(&sub->test_lock);
        sub->desc.id = SPLAT_SUBSYSTEM_KMEM;
 
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST1_NAME, SPLAT_KMEM_TEST1_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST1_NAME, SPLAT_KMEM_TEST1_DESC,
                        SPLAT_KMEM_TEST1_ID, splat_kmem_test1);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST2_NAME, SPLAT_KMEM_TEST2_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST2_NAME, SPLAT_KMEM_TEST2_DESC,
                        SPLAT_KMEM_TEST2_ID, splat_kmem_test2);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST3_NAME, SPLAT_KMEM_TEST3_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST3_NAME, SPLAT_KMEM_TEST3_DESC,
                        SPLAT_KMEM_TEST3_ID, splat_kmem_test3);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST4_NAME, SPLAT_KMEM_TEST4_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST4_NAME, SPLAT_KMEM_TEST4_DESC,
                        SPLAT_KMEM_TEST4_ID, splat_kmem_test4);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST5_NAME, SPLAT_KMEM_TEST5_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST5_NAME, SPLAT_KMEM_TEST5_DESC,
                        SPLAT_KMEM_TEST5_ID, splat_kmem_test5);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST6_NAME, SPLAT_KMEM_TEST6_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST6_NAME, SPLAT_KMEM_TEST6_DESC,
                        SPLAT_KMEM_TEST6_ID, splat_kmem_test6);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST7_NAME, SPLAT_KMEM_TEST7_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST7_NAME, SPLAT_KMEM_TEST7_DESC,
                        SPLAT_KMEM_TEST7_ID, splat_kmem_test7);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST8_NAME, SPLAT_KMEM_TEST8_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST8_NAME, SPLAT_KMEM_TEST8_DESC,
                        SPLAT_KMEM_TEST8_ID, splat_kmem_test8);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST9_NAME, SPLAT_KMEM_TEST9_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST9_NAME, SPLAT_KMEM_TEST9_DESC,
                        SPLAT_KMEM_TEST9_ID, splat_kmem_test9);
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST10_NAME, SPLAT_KMEM_TEST10_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST10_NAME, SPLAT_KMEM_TEST10_DESC,
                        SPLAT_KMEM_TEST10_ID, splat_kmem_test10);
 #if 0
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST11_NAME, SPLAT_KMEM_TEST11_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST11_NAME, SPLAT_KMEM_TEST11_DESC,
                        SPLAT_KMEM_TEST11_ID, splat_kmem_test11);
 #endif
-       SPLAT_TEST_INIT(sub, SPLAT_KMEM_TEST13_NAME, SPLAT_KMEM_TEST13_DESC,
+       splat_test_init(sub, SPLAT_KMEM_TEST13_NAME, SPLAT_KMEM_TEST13_DESC,
                        SPLAT_KMEM_TEST13_ID, splat_kmem_test13);
 
        return sub;
@@ -1374,20 +1386,20 @@ void
 splat_kmem_fini(splat_subsystem_t *sub)
 {
        ASSERT(sub);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST13_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST13_ID);
 #if 0
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST11_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST11_ID);
 #endif
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST10_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST9_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST8_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST7_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST6_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST5_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST4_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST3_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST2_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_KMEM_TEST1_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST10_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST9_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST8_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST7_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST6_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST5_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST4_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST3_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST2_ID);
+       splat_test_fini(sub, SPLAT_KMEM_TEST1_ID);
 
        kfree(sub);
 }