X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Finclude%2Fnet%2Fsock.h;fp=kernel%2Finclude%2Fnet%2Fsock.h;h=3d5ff7436f41040eb7cbd9ef09f9cc57219b24c3;hb=52f993b8e89487ec9ee15a7fb4979e0f09a45b27;hp=14d3c07340079b7a3e9de54ee635011589247ffd;hpb=c189ccac5702322ed843fe17057035b7222a59b6;p=kvmfornfv.git 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)