tcp: tcp_sendmsg() page recycling
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 4 Dec 2011 07:05:17 +0000 (07:05 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Dec 2011 18:20:40 +0000 (13:20 -0500)
If our TCP_PAGE(sk) is not shared (page_count() == 1), we can set page
offset to 0.

This permits better filling of the pages on small to medium tcp writes.

"tbench 16" results on my dev server (2x4x2 machine) :

Before : 3072 MB/s
After  : 3146 MB/s  (2.4 % gain)

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c

index 45156be3abfd59989f33763c56bace0324e30122..a09fe253b917bb5f894a05a80db01bf5ed4388a9 100644 (file)
@@ -1009,7 +1009,12 @@ new_segment:
                                int merge = 0;
                                int i = skb_shinfo(skb)->nr_frags;
                                struct page *page = TCP_PAGE(sk);
-                               int off = TCP_OFF(sk);
+                               int off;
+
+                               if (page && page_count(page) == 1)
+                                       TCP_OFF(sk) = 0;
+
+                               off = TCP_OFF(sk);
 
                                if (skb_can_coalesce(skb, i, page, off) &&
                                    off != PAGE_SIZE) {