diff mbox

[net] tcp/dccp: do not block bh too long in inet_twdr_twkill_work()

Message ID 1428664747.25985.298.camel@edumazet-glaptop2.roam.corp.google.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet April 10, 2015, 11:19 a.m. UTC
From: Eric Dumazet <edumazet@google.com>

I have seen inet_twdr_twkill_work() blocking softirq for
periods up to 1.5 seconds, depending on number of timewait sockets.

This is an unacceptable source of latency.

Note that inet_twdr_do_twkill_work() releases death_lock spinlock
for every tw handled, but does not take care of bh enabling.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/inet_timewait_sock.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Dumazet April 10, 2015, 3:31 p.m. UTC | #1
On Fri, 2015-04-10 at 04:19 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> I have seen inet_twdr_twkill_work() blocking softirq for
> periods up to 1.5 seconds, depending on number of timewait sockets.
> 
> This is an unacceptable source of latency.
> 
> Note that inet_twdr_do_twkill_work() releases death_lock spinlock
> for every tw handled, but does not take care of bh enabling.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---

BTW, inet_twdr_twcal_tick() suffers from similar problem, with latencies
of ~25ms, when /proc/sys/net/ipv4/tcp_tw_recycle is enabled.

Since it holds death_lock for the whole run, all other cpus are spinning
on it.

I believe we simply should add a timer per timewait, as I did for
request sockets.

This would simplify the code a lot, and would get rid of this awful non
scalable timer wheel.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller April 13, 2015, 1:04 a.m. UTC | #2
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 10 Apr 2015 04:19:07 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> I have seen inet_twdr_twkill_work() blocking softirq for
> periods up to 1.5 seconds, depending on number of timewait sockets.
> 
> This is an unacceptable source of latency.
> 
> Note that inet_twdr_do_twkill_work() releases death_lock spinlock
> for every tw handled, but does not take care of bh enabling.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

I think it makes sense to use local_softirq_pending() here rather
than flip the lock unconditionally.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 6d592f8555fb..9c7f480d6ad8 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -303,11 +303,9 @@  void inet_twdr_twkill_work(struct work_struct *work)
 				continue;
 
 			while (inet_twdr_do_twkill_work(twdr, i) != 0) {
-				if (need_resched()) {
-					spin_unlock_bh(&twdr->death_lock);
-					schedule();
-					spin_lock_bh(&twdr->death_lock);
-				}
+				spin_unlock_bh(&twdr->death_lock);
+				cond_resched();
+				spin_lock_bh(&twdr->death_lock);
 			}
 
 			twdr->thread_slots &= ~(1 << i);