diff options
author | David S. Miller | 2016-09-23 12:46:57 +0200 |
---|---|---|
committer | David S. Miller | 2016-09-23 12:46:57 +0200 |
commit | d6989d4bbe6c4d1c2a76696833a07f044e85694d (patch) | |
tree | 2d9a70d0feee4d4a20568be1b39a961fa0d27d81 /include/net/sock.h | |
parent | xen-netback: switch to threaded irq for control ring (diff) | |
parent | Merge tag 'media/v4.8-7' of git://git.kernel.org/pub/scm/linux/kernel/git/mch... (diff) | |
download | kernel-qcow2-linux-d6989d4bbe6c4d1c2a76696833a07f044e85694d.tar.gz kernel-qcow2-linux-d6989d4bbe6c4d1c2a76696833a07f044e85694d.tar.xz kernel-qcow2-linux-d6989d4bbe6c4d1c2a76696833a07f044e85694d.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index c797c57f4d9f..ebf75db08e06 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1339,6 +1339,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) |