Commit 9e9c24cd authored by Eric Dumazet's avatar Eric Dumazet Committed by Kamal Mostafa

net: do not deplete pfmemalloc reserve

[ Upstream commit 79930f58 ]

build_skb() should look at the page pfmemalloc status.
If set, this means page allocator allocated this page in the
expectation it would help to free other pages. Networking
stack can do that only if skb->pfmemalloc is also set.

Also, we must refrain using high order pages from the pfmemalloc
reserve, so __page_frag_refill() must also use __GFP_NOMEMALLOC for
them. Under memory pressure, using order-0 pages is probably the best
strategy.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent b73fa167
......@@ -307,7 +307,11 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
memset(skb, 0, offsetof(struct sk_buff, tail));
skb->truesize = SKB_TRUESIZE(size);
skb->head_frag = frag_size != 0;
if (frag_size) {
skb->head_frag = 1;
if (virt_to_head_page(data)->pfmemalloc)
skb->pfmemalloc = 1;
}
atomic_set(&skb->users, 1);
skb->head = data;
skb->data = data;
......@@ -350,7 +354,8 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
gfp_t gfp = gfp_mask;
if (order)
gfp |= __GFP_COMP | __GFP_NOWARN;
gfp |= __GFP_COMP | __GFP_NOWARN |
__GFP_NOMEMALLOC;
nc->frag.page = alloc_pages(gfp, order);
if (likely(nc->frag.page))
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment