Message ID | 1428664747.25985.298.camel@edumazet-glaptop2.roam.corp.google.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
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
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 --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);