From: Eric Dumazet <dada1@cosmosbay.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH] NET : rt_check_expire() can take a long time, add a cond_resched()
Date: Wed, 14 Nov 2007 22:34:13 +0100 [thread overview]
Message-ID: <473B69D5.2050805@cosmosbay.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
On commit 39c90ece7565f5c47110c2fa77409d7a9478bd5b we converted
rt_check_expire() from softirq to workqueue, allowing the function to perform
all work it was supposed to do.
When the IP route cache is big, rt_check_expire() can take a long time to run.
(default settings : 20% of the hash table is scanned at each invocation)
Adding cond_resched() helps giving cpu to higher priority tasks if necessary.
Using a "if (need_resched())" test before calling "cond_resched();" is
necessary to avoid spending too much time doing the resched check.
(My tests gave a time reduction from 88 ms to 25 ms per rt_check_expire() run
on my i686 test machine)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: rt_check_expire_resched.patch --]
[-- Type: text/plain, Size: 387 bytes --]
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a9471b7..f0b28f9 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -580,6 +580,9 @@ static void rt_check_expire(struct work_struct *work)
i = (i + 1) & rt_hash_mask;
rthp = &rt_hash_table[i].chain;
+ if (need_resched())
+ cond_resched();
+
if (*rthp == NULL)
continue;
spin_lock_bh(rt_hash_lock_addr(i));
next reply other threads:[~2007-11-14 21:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-14 21:34 Eric Dumazet [this message]
2007-11-15 0:13 ` [PATCH] NET : rt_check_expire() can take a long time, add a cond_resched() David Miller
2007-11-15 7:30 ` Andi Kleen
2007-11-15 7:37 ` Herbert Xu
2007-11-15 8:25 ` Eric Dumazet
2007-11-15 8:57 ` David Miller
2007-11-17 13:08 ` Andi Kleen
2007-11-17 16:23 ` Eric Dumazet
2007-11-17 21:46 ` Andi Kleen
2007-11-18 0:27 ` David Miller
2007-11-15 8:52 ` David Miller
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=473B69D5.2050805@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.