public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops
@ 2015-07-17  8:07 Thomas Graf
  2015-07-17  8:24 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Graf @ 2015-07-17  8:07 UTC (permalink / raw)
  To: davem; +Cc: netdev, mroos, herbert

Depending on system speed, the large lookup loop can take a considerable
amount of time to complete causing watchdog warnings to appear. Allow
other tasks to be scheduled after every batch of 1000 lookups.

Reported-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
 lib/test_rhashtable.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index c90777e..5ed6211 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -20,8 +20,10 @@
 #include <linux/rcupdate.h>
 #include <linux/rhashtable.h>
 #include <linux/slab.h>
+#include <linux/sched.h>
 
 #define MAX_ENTRIES	1000000
+#define RELAX_CPU_AFTER	1000
 #define TEST_INSERT_FAIL INT_MAX
 
 static int entries = 50000;
@@ -61,7 +63,7 @@ static struct rhashtable_params test_rht_params = {
 
 static int __init test_rht_lookup(struct rhashtable *ht)
 {
-	unsigned int i;
+	unsigned int i, relax_cnt = RELAX_CPU_AFTER;
 
 	for (i = 0; i < entries * 2; i++) {
 		struct test_obj *obj;
@@ -87,6 +89,11 @@ static int __init test_rht_lookup(struct rhashtable *ht)
 				return -EINVAL;
 			}
 		}
+
+		if (!relax_cnt--) {
+			schedule();
+			relax_cnt = RELAX_CPU_AFTER;
+		}
 	}
 
 	return 0;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops
  2015-07-17  8:07 [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops Thomas Graf
@ 2015-07-17  8:24 ` Eric Dumazet
  2015-07-17  8:28   ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2015-07-17  8:24 UTC (permalink / raw)
  To: Thomas Graf; +Cc: davem, netdev, mroos, herbert

On Fri, 2015-07-17 at 10:07 +0200, Thomas Graf wrote:
> Depending on system speed, the large lookup loop can take a considerable
> amount of time to complete causing watchdog warnings to appear. Allow
> other tasks to be scheduled after every batch of 1000 lookups.
> 
> Reported-by: Meelis Roos <mroos@linux.ee>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> ---
>  lib/test_rhashtable.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
> index c90777e..5ed6211 100644
> --- a/lib/test_rhashtable.c
> +++ b/lib/test_rhashtable.c
> @@ -20,8 +20,10 @@
>  #include <linux/rcupdate.h>
>  #include <linux/rhashtable.h>
>  #include <linux/slab.h>
> +#include <linux/sched.h>
>  
>  #define MAX_ENTRIES	1000000
> +#define RELAX_CPU_AFTER	1000
>  #define TEST_INSERT_FAIL INT_MAX
>  
>  static int entries = 50000;
> @@ -61,7 +63,7 @@ static struct rhashtable_params test_rht_params = {
>  
>  static int __init test_rht_lookup(struct rhashtable *ht)
>  {
> -	unsigned int i;
> +	unsigned int i, relax_cnt = RELAX_CPU_AFTER;
>  
>  	for (i = 0; i < entries * 2; i++) {
>  		struct test_obj *obj;
> @@ -87,6 +89,11 @@ static int __init test_rht_lookup(struct rhashtable *ht)
>  				return -EINVAL;
>  			}
>  		}
> +
> +		if (!relax_cnt--) {
> +			schedule();
> +			relax_cnt = RELAX_CPU_AFTER;
> +		}
>  	}
>  
>  	return 0;

Please simply use cond_resched() without counting and magic value.

 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops
  2015-07-17  8:24 ` Eric Dumazet
@ 2015-07-17  8:28   ` Eric Dumazet
  2015-07-17  8:50     ` Thomas Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2015-07-17  8:28 UTC (permalink / raw)
  To: Thomas Graf; +Cc: davem, netdev, mroos, herbert

On Fri, 2015-07-17 at 10:24 +0200, Eric Dumazet wrote:

> Please simply use cond_resched() without counting and magic value.

Also use cond_resched() in insert and delete phases ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops
  2015-07-17  8:28   ` Eric Dumazet
@ 2015-07-17  8:50     ` Thomas Graf
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Graf @ 2015-07-17  8:50 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, netdev, mroos, herbert

On 07/17/15 at 10:28am, Eric Dumazet wrote:
> On Fri, 2015-07-17 at 10:24 +0200, Eric Dumazet wrote:
> 
> > Please simply use cond_resched() without counting and magic value.

Done

> Also use cond_resched() in insert and delete phases ?

When I tried that it made the walker duplicates disappear which weakens
the test case a little bit but it's probably safer this way.  I'll include
it in the v2.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-17  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-17  8:07 [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops Thomas Graf
2015-07-17  8:24 ` Eric Dumazet
2015-07-17  8:28   ` Eric Dumazet
2015-07-17  8:50     ` Thomas Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox