Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95e435af authored by Phil Sutter's avatar Phil Sutter Committed by David S. Miller
Browse files

rhashtable-test: calculate max_entries value by default



A maximum table size of 64k entries is insufficient for the multiple
threads test even in default configuration (10 threads * 50000 objects =
500000 objects in total). Since we know how many objects will be
inserted, calculate the max size unless overridden by parameter.

Note that specifying the exact number of objects upon table init won't
suffice as that value is being rounded down to the next power of two -
anticipate this by rounding up to the next power of two in beforehand.

Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e9089e5
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -36,9 +36,9 @@ static int runs = 4;
module_param(runs, int, 0);
module_param(runs, int, 0);
MODULE_PARM_DESC(runs, "Number of test runs per variant (default: 4)");
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_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;
static bool shrinking = false;
module_param(shrinking, bool, 0);
module_param(shrinking, bool, 0);
@@ -321,7 +321,7 @@ static int __init test_rht_init(void)
	entries = min(entries, MAX_ENTRIES);
	entries = min(entries, MAX_ENTRIES);


	test_rht_params.automatic_shrinking = shrinking;
	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;
	test_rht_params.nelem_hint = size;


	pr_info("Running rhashtable test nelem=%d, max_size=%d, shrinking=%d\n",
	pr_info("Running rhashtable test nelem=%d, max_size=%d, shrinking=%d\n",
@@ -367,6 +367,8 @@ static int __init test_rht_init(void)
		return -ENOMEM;
		return -ENOMEM;
	}
	}


	test_rht_params.max_size = max_size ? :
	                           roundup_pow_of_two(tcount * entries);
	err = rhashtable_init(&ht, &test_rht_params);
	err = rhashtable_init(&ht, &test_rht_params);
	if (err < 0) {
	if (err < 0) {
		pr_warn("Test failed: Unable to initialize hashtable: %d\n",
		pr_warn("Test failed: Unable to initialize hashtable: %d\n",