summaryrefslogtreecommitdiffstats
path: root/lib/test_rhashtable.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2015-11-20 18:17:20 +0100
committerDavid S. Miller <davem@davemloft.net>2015-11-23 12:36:08 -0500
commitd662e037fc88b187494a95b5bc19b3c0e9b9ea36 (patch)
tree9dff531c5029aae25ba4d03faa9610c1d16b6b57 /lib/test_rhashtable.c
parent95e435afefe98b8ef6ae8b764879a064cd931a5c (diff)
downloadlinux-d662e037fc88b187494a95b5bc19b3c0e9b9ea36.tar.gz
linux-d662e037fc88b187494a95b5bc19b3c0e9b9ea36.tar.bz2
linux-d662e037fc88b187494a95b5bc19b3c0e9b9ea36.zip
rhashtable-test: allow to retry even if -ENOMEM was returned
This is rather a hack to expose the current issue with rhashtable to under high pressure sometimes return -ENOMEM even though system memory is not exhausted and a consecutive insert may succeed. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/test_rhashtable.c')
-rw-r--r--lib/test_rhashtable.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index 6fa77b3f0e80..270bf7289b1e 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -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;
}