Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1215261

[PATCH 2/3] rhashtable-test: retry insert operations in threads

From Phil Sutter <phil@nwl.cc>
Newsgroups linux.kernel
Subject [PATCH 2/3] rhashtable-test: retry insert operations in threads
Date 2015-08-28 12:30 +0200
Message-ID <q2p50-t4-9@gated-at.bofh.it> (permalink)
References <q2p50-t4-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


After adding cond_resched() calls to threadfunc(), a surprisingly high
rate of insert failures occurred probably due to table resizes getting a
better chance to run in background. To not soften up the remaining
tests, retry inserts until they either succeed or fail permanently.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 lib/test_rhashtable.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index 63654e3..093cf84 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -244,7 +244,7 @@ static int thread_lookup_test(struct thread_data *tdata)
 
 static int threadfunc(void *data)
 {
-	int i, step, err = 0, insert_fails = 0;
+	int i, step, err = 0, retries = 0;
 	struct thread_data *tdata = data;
 
 	up(&prestart_sem);
@@ -253,21 +253,22 @@ static int threadfunc(void *data)
 
 	for (i = 0; i < entries; i++) {
 		tdata->objs[i].value = (tdata->id << 16) | i;
+insert_retry:
 		cond_resched();
 		err = rhashtable_insert_fast(&ht, &tdata->objs[i].node,
 		                             test_rht_params);
 		if (err == -ENOMEM || err == -EBUSY) {
-			tdata->objs[i].value = TEST_INSERT_FAIL;
-			insert_fails++;
+			retries++;
+			goto insert_retry;
 		} else if (err) {
 			pr_err("  thread[%d]: rhashtable_insert_fast failed\n",
 			       tdata->id);
 			goto out;
 		}
 	}
-	if (insert_fails)
-		pr_info("  thread[%d]: %d insert failures\n",
-		        tdata->id, insert_fails);
+	if (retries)
+		pr_info("  thread[%d]: retried insert operation %d times\n",
+		        tdata->id, retries);
 
 	err = thread_lookup_test(tdata);
 	if (err) {
-- 
2.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] rhashtable-test: add cond_resched() to thread test Phil Sutter <phil@nwl.cc> - 2015-08-28 12:30 +0200
  [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-08-28 12:30 +0200
    Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Thomas Graf <tgraf@suug.ch> - 2015-08-28 13:10 +0200
      Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-08-28 13:20 +0200
        Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-08-28 15:40 +0200
          Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Thomas Graf <tgraf@suug.ch> - 2015-08-29 00:50 +0200
            Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-08-29 11:10 +0200
              Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-08-30 09:50 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-08-31 13:10 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-09-01 13:50 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-09-01 14:50 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-09-01 15:10 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Eric Dumazet <eric.dumazet@gmail.com> - 2015-09-01 15:50 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-09-01 15:50 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-09-01 16:00 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Phil Sutter <phil@nwl.cc> - 2015-09-01 16:00 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-09-01 16:10 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Thomas Graf <tgraf@suug.ch> - 2015-09-01 16:20 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-09-01 16:20 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Thomas Graf <tgraf@suug.ch> - 2015-09-01 17:00 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Herbert Xu <herbert@gondor.apana.org.au> - 2015-09-02 04:10 +0200
                Re: [PATCH 2/3] rhashtable-test: retry insert operations in threads Thomas Graf <tgraf@suug.ch> - 2015-09-02 09:10 +0200
  [PATCH 3/3] rhashtable-test: calculate max_entries value by default Phil Sutter <phil@nwl.cc> - 2015-08-28 12:30 +0200
    Re: [PATCH 3/3] rhashtable-test: calculate max_entries value by  default Thomas Graf <tgraf@suug.ch> - 2015-08-28 13:20 +0200
  Re: [PATCH 1/3] rhashtable-test: add cond_resched() to thread test Thomas Graf <tgraf@suug.ch> - 2015-08-28 13:10 +0200

csiph-web