]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ipv4: Use binary search to choose tcp PMTU probe_size
authorFan Du <fan.du@intel.com>
Fri, 6 Mar 2015 03:18:23 +0000 (11:18 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Mar 2015 19:57:41 +0000 (14:57 -0500)
Current probe_size is chosen by doubling mss_cache,
the probing process will end shortly with a sub-optimal
mss size, and the link mtu will not be taken full
advantage of, in return, this will make user to tweak
tcp_base_mss with care.

Use binary search to choose probe_size in a fine
granularity manner, an optimal mss will be found
to boost performance as its maxmium.

In addition, introduce a sysctl_tcp_probe_threshold
to control when probing will stop in respect to
the width of search range.

Test env:
Docker instance with vxlan encapuslation(82599EB)
iperf -c 10.0.0.24  -t 60

before this patch:
1.26 Gbits/sec

After this patch: increase 26%
1.59 Gbits/sec

Signed-off-by: Fan Du <fan.du@intel.com>
Acked-by: John Heffner <johnwheffner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netns/ipv4.h
include/net/tcp.h
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_output.c

index 1085e12f940f022d37132292c00b16f930770372..e051d399fa170f70602fdacccd5ae6d29b901c80 100644 (file)
@@ -87,6 +87,7 @@ struct netns_ipv4 {
        int sysctl_tcp_fwmark_accept;
        int sysctl_tcp_mtu_probing;
        int sysctl_tcp_base_mss;
+       int sysctl_tcp_probe_threshold;
 
        struct ping_group_range ping_group_range;
 
index 834089b0cffc745088a112f9e9b1c3b3cf0c4051..1ad82e334e2760c779ca2cbe37c565f3aed3522e 100644 (file)
@@ -67,6 +67,9 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
 /* The least MTU to use for probing */
 #define TCP_BASE_MSS           1024
 
+/* Specify interval when tcp mtu probing will stop */
+#define TCP_PROBE_THRESHOLD    8
+
 /* After receiving this amount of duplicate ACKs fast retransmit starts. */
 #define TCP_FASTRETRANS_THRESH 3
 
index d151539da8e6948571bfdfbc105c838b3b561d71..d3c09c12ee815eb008cd7ee40449d3e2aa9dc4e2 100644 (file)
@@ -883,6 +883,13 @@ static struct ctl_table ipv4_net_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
        },
+       {
+               .procname       = "tcp_probe_threshold",
+               .data           = &init_net.ipv4.sysctl_tcp_probe_threshold,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
        { }
 };
 
index 5a2dfed4783b6ed0185dccded960972b4d6e13b0..35790d977a2b951de3de9070aadca5bf99632fd0 100644 (file)
@@ -2460,6 +2460,7 @@ static int __net_init tcp_sk_init(struct net *net)
        }
        net->ipv4.sysctl_tcp_ecn = 2;
        net->ipv4.sysctl_tcp_base_mss = TCP_BASE_MSS;
+       net->ipv4.sysctl_tcp_probe_threshold = TCP_PROBE_THRESHOLD;
        return 0;
 
 fail:
index 8bbd86cd81c8290eecc43bff90efc14f41689cb1..ed024cbb097f6b526609eb3b20f01097901bfe37 100644 (file)
@@ -1842,11 +1842,13 @@ static int tcp_mtu_probe(struct sock *sk)
        struct tcp_sock *tp = tcp_sk(sk);
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct sk_buff *skb, *nskb, *next;
+       struct net *net = sock_net(sk);
        int len;
        int probe_size;
        int size_needed;
        int copy;
        int mss_now;
+       int interval;
 
        /* Not currently probing/verifying,
         * not in recovery,
@@ -1859,11 +1861,17 @@ static int tcp_mtu_probe(struct sock *sk)
            tp->rx_opt.num_sacks || tp->rx_opt.dsack)
                return -1;
 
-       /* Very simple search strategy: just double the MSS. */
+       /* Use binary search for probe_size between tcp_mss_base,
+        * and current mss_clamp. if (search_high - search_low)
+        * smaller than a threshold, backoff from probing.
+        */
        mss_now = tcp_current_mss(sk);
-       probe_size = 2 * tp->mss_cache;
+       probe_size = tcp_mtu_to_mss(sk, (icsk->icsk_mtup.search_high +
+                                   icsk->icsk_mtup.search_low) >> 1);
        size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache;
-       if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) {
+       interval = icsk->icsk_mtup.search_high - icsk->icsk_mtup.search_low;
+       if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high) ||
+           interval < max(1, net->ipv4.sysctl_tcp_probe_threshold)) {
                /* TODO: set timer for probe_converge_event */
                return -1;
        }