From: Eric Dumazet <eric.dumazet@gmail.com>
To: Thomas Graf <tgraf@suug.ch>
Cc: davem@davemloft.net, netdev@vger.kernel.org, mroos@linux.ee,
herbert@gondor.apana.org.au
Subject: Re: [PATCH net-next] rhashtable: Allow other tasks to be scheduled in large lookup loops
Date: Fri, 17 Jul 2015 10:24:17 +0200 [thread overview]
Message-ID: <1437121457.1026.21.camel@edumazet-glaptop2.roam.corp.google.com> (raw)
In-Reply-To: <2dcec22264c46d248e4f56ac5dfd6a8d321b162f.1437120351.git.tgraf@suug.ch>
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.
next prev parent reply other threads:[~2015-07-17 8:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-07-17 8:28 ` Eric Dumazet
2015-07-17 8:50 ` 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=1437121457.1026.21.camel@edumazet-glaptop2.roam.corp.google.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=mroos@linux.ee \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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