aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-11-28 17:41:47 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-29 13:17:03 -0500
commitf07d960df33c5aef8f513efce0fd201f962f94a1 (patch)
tree33f1313283e85a642f4126029e47e4ec1f606282 /net/ipv4/tcp.c
parent4d77d2b567ec66a443792d99e96ac760991d80d0 (diff)
tcp: avoid frag allocation for small frames
tcp_sendmsg() uses select_size() helper to choose skb head size when a new skb must be allocated. If GSO is enabled for the socket, current strategy is to force all payload data to be outside of headroom, in PAGE fragments. This strategy is not welcome for small packets, wasting memory. Experiments show that best results are obtained when using 2048 bytes for skb head (This includes the skb overhead and various headers) This patch provides better len/truesize ratios for packets sent to loopback device, and reduce memory needs for in-flight loopback packets, particularly on arches with big pages. If a sender sends many 1-byte packets to an unresponsive application, receiver rmem_alloc will grow faster and will stop queuing these packets sooner, or will collapse its receive queue to free excess memory. netperf -t TCP_RR results are improved by ~4 %, and many workloads are improved as well (tbench, mysql...) Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index ecbc89a0436b..45156be3abfd 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -897,9 +897,12 @@ static inline int select_size(const struct sock *sk, bool sg)
897 int tmp = tp->mss_cache; 897 int tmp = tp->mss_cache;
898 898
899 if (sg) { 899 if (sg) {
900 if (sk_can_gso(sk)) 900 if (sk_can_gso(sk)) {
901 tmp = 0; 901 /* Small frames wont use a full page:
902 else { 902 * Payload will immediately follow tcp header.
903 */
904 tmp = SKB_WITH_OVERHEAD(2048 - MAX_TCP_HEADER);
905 } else {
903 int pgbreak = SKB_MAX_HEAD(MAX_TCP_HEADER); 906 int pgbreak = SKB_MAX_HEAD(MAX_TCP_HEADER);
904 907
905 if (tmp >= pgbreak && 908 if (tmp >= pgbreak &&