mm: rework mapcount accounting to enable 4k mapping of THPs
[deliverable/linux.git] / lib / test_rhashtable.c
index cfc3440f17e7b16272555df0c310eb6a4743b867..270bf7289b1e0182a9a34a11e2b0bb2b152463ae 100644 (file)
@@ -36,9 +36,9 @@ static int runs = 4;
 module_param(runs, int, 0);
 MODULE_PARM_DESC(runs, "Number of test runs per variant (default: 4)");
 
-static int max_size = 65536;
+static int max_size = 0;
 module_param(max_size, int, 0);
-MODULE_PARM_DESC(runs, "Maximum table size (default: 65536)");
+MODULE_PARM_DESC(runs, "Maximum table size (default: calculated)");
 
 static bool shrinking = false;
 module_param(shrinking, bool, 0);
@@ -52,6 +52,10 @@ static int tcount = 10;
 module_param(tcount, int, 0);
 MODULE_PARM_DESC(tcount, "Number of threads to spawn (default: 10)");
 
+static bool enomem_retry = false;
+module_param(enomem_retry, bool, 0);
+MODULE_PARM_DESC(enomem_retry, "Retry insert even if -ENOMEM was returned (default: off)");
+
 struct test_obj {
        int                     value;
        struct rhash_head       node;
@@ -79,14 +83,22 @@ static struct semaphore startup_sem = __SEMAPHORE_INITIALIZER(startup_sem, 0);
 static int insert_retry(struct rhashtable *ht, struct rhash_head *obj,
                         const struct rhashtable_params params)
 {
-       int err, retries = -1;
+       int err, retries = -1, enomem_retries = 0;
 
        do {
                retries++;
                cond_resched();
                err = rhashtable_insert_fast(ht, obj, params);
+               if (err == -ENOMEM && enomem_retry) {
+                       enomem_retries++;
+                       err = -EBUSY;
+               }
        } while (err == -EBUSY);
 
+       if (enomem_retries)
+               pr_info(" %u insertions retried after -ENOMEM\n",
+                       enomem_retries);
+
        return err ? : retries;
 }
 
@@ -321,7 +333,7 @@ static int __init test_rht_init(void)
        entries = min(entries, MAX_ENTRIES);
 
        test_rht_params.automatic_shrinking = shrinking;
-       test_rht_params.max_size = max_size;
+       test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries);
        test_rht_params.nelem_hint = size;
 
        pr_info("Running rhashtable test nelem=%d, max_size=%d, shrinking=%d\n",
@@ -367,6 +379,8 @@ static int __init test_rht_init(void)
                return -ENOMEM;
        }
 
+       test_rht_params.max_size = max_size ? :
+                                  roundup_pow_of_two(tcount * entries);
        err = rhashtable_init(&ht, &test_rht_params);
        if (err < 0) {
                pr_warn("Test failed: Unable to initialize hashtable: %d\n",
This page took 0.027431 seconds and 5 git commands to generate.