netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	tgraf@suug.ch, fengguang.wu@intel.com, wfg@linux.intel.com,
	lkp@01.org
Subject: [PATCH 3/3] rhashtable-test: calculate max_entries value by default
Date: Fri, 28 Aug 2015 12:28:05 +0200	[thread overview]
Message-ID: <1440757685-14241-3-git-send-email-phil@nwl.cc> (raw)
In-Reply-To: <1440757685-14241-1-git-send-email-phil@nwl.cc>

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: Phil Sutter <phil@nwl.cc>
---
 lib/test_rhashtable.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index 093cf84..73fcb8e 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -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);
@@ -317,7 +317,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",
@@ -363,6 +363,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",
-- 
2.1.2

  parent reply	other threads:[~2015-08-28 10:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-28 10:28 [PATCH 1/3] rhashtable-test: add cond_resched() to thread test Phil Sutter
2015-08-28 10:28 ` [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter
2015-08-28 11:09   ` Thomas Graf
2015-08-28 11:13     ` Phil Sutter
2015-08-28 13:34       ` Phil Sutter
2015-08-28 22:43         ` Thomas Graf
2015-08-29  9:07           ` Phil Sutter
2015-08-30  7:47             ` Herbert Xu
2015-08-31 11:00               ` Phil Sutter
2015-09-01 11:43                 ` Herbert Xu
2015-09-01 12:46                   ` Phil Sutter
2015-09-01 13:00                     ` Herbert Xu
2015-09-01 13:40                       ` Eric Dumazet
2015-09-01 13:43                       ` Phil Sutter
2015-09-01 13:50                         ` Herbert Xu
2015-09-01 13:56                           ` Phil Sutter
2015-09-01 14:03                             ` Herbert Xu
2015-09-01 14:13                               ` Thomas Graf
2015-09-01 14:16                                 ` Herbert Xu
2015-09-01 14:51                                   ` Thomas Graf
2015-09-02  2:00                                     ` Herbert Xu
2015-09-02  7:07                                       ` Thomas Graf
2015-09-10  8:03                                     ` Herbert Xu
2015-09-10 10:05                                       ` Phil Sutter
2015-08-28 10:28 ` Phil Sutter [this message]
2015-08-28 11:11   ` [PATCH 3/3] rhashtable-test: calculate max_entries value by default Thomas Graf
2015-08-28 11:03 ` [PATCH 1/3] rhashtable-test: add cond_resched() to thread test Thomas Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440757685-14241-3-git-send-email-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=davem@davemloft.net \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    --cc=wfg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).