diff options
author | Eric Dumazet <edumazet@google.com> | 2018-11-29 16:56:20 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-11-29 20:10:14 +0100 |
commit | 19bf62613a800ef4ffa26cbae6b723d9f46740ed (patch) | |
tree | 7a48396a78634310d66e156caf70a5ef61451ad5 /net/ipv4 | |
parent | qede - Add a statistic for a case where driver drops tx packet due to memory ... (diff) | |
download | linux-19bf62613a800ef4ffa26cbae6b723d9f46740ed.tar.xz linux-19bf62613a800ef4ffa26cbae6b723d9f46740ed.zip |
tcp: remove loop to compute wscale
We can remove the loop and conditional branches
and compute wscale efficiently thanks to ilog2()
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp_output.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index c5dc4c4fdadd..e4c1e51b18c1 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -233,16 +233,14 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss, if (init_rcv_wnd) *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss); - (*rcv_wscale) = 0; + *rcv_wscale = 0; if (wscale_ok) { /* Set window scaling on max possible window */ space = max_t(u32, space, sock_net(sk)->ipv4.sysctl_tcp_rmem[2]); space = max_t(u32, space, sysctl_rmem_max); space = min_t(u32, space, *window_clamp); - while (space > U16_MAX && (*rcv_wscale) < TCP_MAX_WSCALE) { - space >>= 1; - (*rcv_wscale)++; - } + *rcv_wscale = clamp_t(int, ilog2(space) - 15, + 0, TCP_MAX_WSCALE); } /* Set the clamp no higher than max representable value */ (*window_clamp) = min_t(__u32, U16_MAX << (*rcv_wscale), *window_clamp); |