diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-04-28 17:35:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-28 17:35:48 -0400 |
commit | 4b0b72f7dd617b13abd1b04c947e15873e011a24 (patch) | |
tree | 16fc7bc990fa47cccb62bdb34cb23bd3c26b7a50 /net/ipv6 | |
parent | cfc1fbb079b265bf69d4ceba590a2e2c1a1cde33 (diff) |
net: speedup udp receive path
Since commit 95766fff ([UDP]: Add memory accounting.),
each received packet needs one extra sock_lock()/sock_release() pair.
This added latency because of possible backlog handling. Then later,
ticket spinlocks added yet another latency source in case of DDOS.
This patch introduces lock_sock_bh() and unlock_sock_bh()
synchronization primitives, avoiding one atomic operation and backlog
processing.
skb_free_datagram_locked() uses them instead of full blown
lock_sock()/release_sock(). skb is orphaned inside locked section for
proper socket memory reclaim, and finally freed outside of it.
UDP receive path now take the socket spinlock only once.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/udp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 3ead20ad9d07..91c60f0090a4 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -424,7 +424,7 @@ out: | |||
424 | return err; | 424 | return err; |
425 | 425 | ||
426 | csum_copy_err: | 426 | csum_copy_err: |
427 | lock_sock(sk); | 427 | lock_sock_bh(sk); |
428 | if (!skb_kill_datagram(sk, skb, flags)) { | 428 | if (!skb_kill_datagram(sk, skb, flags)) { |
429 | if (is_udp4) | 429 | if (is_udp4) |
430 | UDP_INC_STATS_USER(sock_net(sk), | 430 | UDP_INC_STATS_USER(sock_net(sk), |
@@ -433,7 +433,7 @@ csum_copy_err: | |||
433 | UDP6_INC_STATS_USER(sock_net(sk), | 433 | UDP6_INC_STATS_USER(sock_net(sk), |
434 | UDP_MIB_INERRORS, is_udplite); | 434 | UDP_MIB_INERRORS, is_udplite); |
435 | } | 435 | } |
436 | release_sock(sk); | 436 | unlock_sock_bh(sk); |
437 | 437 | ||
438 | if (flags & MSG_DONTWAIT) | 438 | if (flags & MSG_DONTWAIT) |
439 | return -EAGAIN; | 439 | return -EAGAIN; |