netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NET : rt_check_expire() can take a long time, add a cond_resched()
@ 2007-11-14 21:34 Eric Dumazet
  2007-11-15  0:13 ` David Miller
  2007-11-15  7:30 ` Andi Kleen
  0 siblings, 2 replies; 11+ messages in thread
From: Eric Dumazet @ 2007-11-14 21:34 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

[-- 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));

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

end of thread, other threads:[~2007-11-18  0:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-14 21:34 [PATCH] NET : rt_check_expire() can take a long time, add a cond_resched() Eric Dumazet
2007-11-15  0:13 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).