Re: [PATCH net-next v4] net: ip: avoid OOM kills with large UDP sends over loopback
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2021-06-24 02:41:38
quoted
if (transhdrlen) { - skb = sock_alloc_send_skb(sk, - alloclen + hh_len + 15, + skb = sock_alloc_send_skb(sk, alloclen, (flags & MSG_DONTWAIT), &err); } else { skb = NULL; if (refcount_read(&sk->sk_wmem_alloc) + wmem_alloc_delta <= 2 * sk->sk_sndbuf) - skb = alloc_skb(alloclen + hh_len + 15, + skb = alloc_skb(alloclen, sk->sk_allocation); if (unlikely(!skb)) err = -ENOBUFS;Is there any risk of regressions? If so, would it be preferable to try regular alloc and only on failure, just below here, do the size and SG test and if permitted jump back to the last of the three alloc_len options?
sk_page_frag_refill when using frags will try also try large allocations first (SKB_FRAG_PAGE_ORDER == order-3) , but can degrade more gracefully under memory pressure than this header alloc. Which can only succeed or fail for the total size. So without memory pressure this only takes two extra allocations for a 64KB skb.