aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-05-26 11:55:28 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-26 23:21:29 -0400
commitd6a4e26afb80c049e7f94e1b7b506dcda61eee88 (patch)
tree809c23a70ad711aa0f1456068cb73f9c1ac11da9
parent095dc8e0c3686d586a01a50abc3e1bb9ac633054 (diff)
tcp: tcp_tso_autosize() minimum is one packet
By making sure sk->sk_gso_max_segs minimal value is one, and sysctl_tcp_min_tso_segs minimal value is one as well, tcp_tso_autosize() will return a non zero value. We can then revert 843925f33fcc293d80acf2c5c8a78adf3344d49b ("tcp: Do not apply TSO segment limit to non-TSO packets") and save few cpu cycles in fast path. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Neal Cardwell <ncardwell@google.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: Neal Cardwell <ncardwell@google.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/sock.c5
-rw-r--r--net/ipv4/sysctl_net_ipv4.c2
-rw-r--r--net/ipv4/tcp_output.c4
3 files changed, 7 insertions, 4 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 29124fcdc42a..e72633c346b1 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1581,6 +1581,8 @@ EXPORT_SYMBOL_GPL(sk_clone_lock);
1581 1581
1582void sk_setup_caps(struct sock *sk, struct dst_entry *dst) 1582void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
1583{ 1583{
1584 u32 max_segs = 1;
1585
1584 __sk_dst_set(sk, dst); 1586 __sk_dst_set(sk, dst);
1585 sk->sk_route_caps = dst->dev->features; 1587 sk->sk_route_caps = dst->dev->features;
1586 if (sk->sk_route_caps & NETIF_F_GSO) 1588 if (sk->sk_route_caps & NETIF_F_GSO)
@@ -1592,9 +1594,10 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
1592 } else { 1594 } else {
1593 sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM; 1595 sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;
1594 sk->sk_gso_max_size = dst->dev->gso_max_size; 1596 sk->sk_gso_max_size = dst->dev->gso_max_size;
1595 sk->sk_gso_max_segs = dst->dev->gso_max_segs; 1597 max_segs = max_t(u32, dst->dev->gso_max_segs, 1);
1596 } 1598 }
1597 } 1599 }
1600 sk->sk_gso_max_segs = max_segs;
1598} 1601}
1599EXPORT_SYMBOL_GPL(sk_setup_caps); 1602EXPORT_SYMBOL_GPL(sk_setup_caps);
1600 1603
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 841de32f1fee..e64892769607 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -702,7 +702,7 @@ static struct ctl_table ipv4_table[] = {
702 .maxlen = sizeof(int), 702 .maxlen = sizeof(int),
703 .mode = 0644, 703 .mode = 0644,
704 .proc_handler = proc_dointvec_minmax, 704 .proc_handler = proc_dointvec_minmax,
705 .extra1 = &zero, 705 .extra1 = &one,
706 .extra2 = &gso_max_segs, 706 .extra2 = &gso_max_segs,
707 }, 707 },
708 { 708 {
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 534e5fdb04c1..190538a2a88c 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2088,7 +2088,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
2088 if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now))) 2088 if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now)))
2089 break; 2089 break;
2090 2090
2091 if (tso_segs == 1 || !max_segs) { 2091 if (tso_segs == 1) {
2092 if (unlikely(!tcp_nagle_test(tp, skb, mss_now, 2092 if (unlikely(!tcp_nagle_test(tp, skb, mss_now,
2093 (tcp_skb_is_last(sk, skb) ? 2093 (tcp_skb_is_last(sk, skb) ?
2094 nonagle : TCP_NAGLE_PUSH)))) 2094 nonagle : TCP_NAGLE_PUSH))))
@@ -2101,7 +2101,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
2101 } 2101 }
2102 2102
2103 limit = mss_now; 2103 limit = mss_now;
2104 if (tso_segs > 1 && max_segs && !tcp_urg_mode(tp)) 2104 if (tso_segs > 1 && !tcp_urg_mode(tp))
2105 limit = tcp_mss_split_point(sk, skb, mss_now, 2105 limit = tcp_mss_split_point(sk, skb, mss_now,
2106 min_t(unsigned int, 2106 min_t(unsigned int,
2107 cwnd_quota, 2107 cwnd_quota,