diff options
Diffstat (limited to 'kernel/include/net/sock.h')
-rw-r--r-- | kernel/include/net/sock.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/include/net/sock.h b/kernel/include/net/sock.h index 14d3c0734..3d5ff7436 100644 --- a/kernel/include/net/sock.h +++ b/kernel/include/net/sock.h @@ -1425,6 +1425,16 @@ static inline void sk_mem_uncharge(struct sock *sk, int size) if (!sk_has_account(sk)) return; sk->sk_forward_alloc += size; + + /* Avoid a possible overflow. + * TCP send queues can make this happen, if sk_mem_reclaim() + * is not called and more than 2 GBytes are released at once. + * + * If we reach 2 MBytes, reclaim 1 MBytes right now, there is + * no need to hold that much forward allocation anyway. + */ + if (unlikely(sk->sk_forward_alloc >= 1 << 21)) + __sk_mem_reclaim(sk, 1 << 20); } static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb) |