]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - spl/module/splat/splat-kmem.c
UBUNTU: SAUCE: (noup) Update spl to 0.7.3-1ubuntu1, zfs to 0.7.3-1ubuntu1
[mirror_ubuntu-bionic-kernel.git] / spl / module / splat / splat-kmem.c
index b9b566f3e3da2b725e65c8f5cd103e8040676f7d..d0649ad9a058467d117246561d94a8fc9331e996 100644 (file)
@@ -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
@@ -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);
 }