diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-11-14 19:14:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-11-14 19:14:05 -0500 |
commit | d90bf5a976793edfa88d3bb2393f0231eb8ce1e5 (patch) | |
tree | c664096ffb1f34413ef57e906b38a255bf57edd0 | |
parent | 66ba886254edbbd9442d30f1eef6f6fb0145027d (diff) |
[NET]: rt_check_expire() can take a long time, add a cond_resched()
On commit 39c90ece7565f5c47110c2fa77409d7a9478bd5b:
[IPV4]: Convert rt_check_expire() from softirq processing to workqueue.
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/route.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 45651834e1e2..1bff9ed349ff 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -578,6 +578,9 @@ static void rt_check_expire(struct work_struct *work) | |||
578 | i = (i + 1) & rt_hash_mask; | 578 | i = (i + 1) & rt_hash_mask; |
579 | rthp = &rt_hash_table[i].chain; | 579 | rthp = &rt_hash_table[i].chain; |
580 | 580 | ||
581 | if (need_resched()) | ||
582 | cond_resched(); | ||
583 | |||
581 | if (*rthp == NULL) | 584 | if (*rthp == NULL) |
582 | continue; | 585 | continue; |
583 | spin_lock_bh(rt_hash_lock_addr(i)); | 586 | spin_lock_bh(rt_hash_lock_addr(i)); |