net: avoid limits overflow
Robin Holt tried to boot a 16TB machine and found some limits were reached : sysctl_tcp_mem[2], sysctl_udp_mem[2] We can switch infrastructure to use long "instead" of "int", now atomic_long_t primitives are available for free. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Reported-by: Robin Holt <holt@sgi.com> Reviewed-by: Robin Holt <holt@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
67286640f6
commit
8d987e5c75
@@ -259,8 +259,11 @@ static void tcp_fixup_sndbuf(struct sock *sk)
|
||||
int sndmem = tcp_sk(sk)->rx_opt.mss_clamp + MAX_TCP_HEADER + 16 +
|
||||
sizeof(struct sk_buff);
|
||||
|
||||
if (sk->sk_sndbuf < 3 * sndmem)
|
||||
sk->sk_sndbuf = min(3 * sndmem, sysctl_tcp_wmem[2]);
|
||||
if (sk->sk_sndbuf < 3 * sndmem) {
|
||||
sk->sk_sndbuf = 3 * sndmem;
|
||||
if (sk->sk_sndbuf > sysctl_tcp_wmem[2])
|
||||
sk->sk_sndbuf = sysctl_tcp_wmem[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* 2. Tuning advertised window (window_clamp, rcv_ssthresh)
|
||||
@@ -396,7 +399,7 @@ static void tcp_clamp_window(struct sock *sk)
|
||||
if (sk->sk_rcvbuf < sysctl_tcp_rmem[2] &&
|
||||
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK) &&
|
||||
!tcp_memory_pressure &&
|
||||
atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) {
|
||||
atomic_long_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) {
|
||||
sk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc),
|
||||
sysctl_tcp_rmem[2]);
|
||||
}
|
||||
@@ -4861,7 +4864,7 @@ static int tcp_should_expand_sndbuf(struct sock *sk)
|
||||
return 0;
|
||||
|
||||
/* If we are under soft global TCP memory pressure, do not expand. */
|
||||
if (atomic_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0])
|
||||
if (atomic_long_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0])
|
||||
return 0;
|
||||
|
||||
/* If we filled the congestion window, do not expand. */
|
||||
|
Reference in New Issue
Block a user