Skip to content

Commit

Permalink
net: do not deplete pfmemalloc reserve
Browse files Browse the repository at this point in the history
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: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Apr 22, 2015
1 parent 26349c7 commit 79930f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,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;
Expand Down Expand Up @@ -348,7 +352,8 @@ static struct page *__page_frag_refill(struct netdev_alloc_cache *nc,
gfp_t gfp = gfp_mask;

if (order) {
gfp_mask |= __GFP_COMP | __GFP_NOWARN | __GFP_NORETRY;
gfp_mask |= __GFP_COMP | __GFP_NOWARN | __GFP_NORETRY |
__GFP_NOMEMALLOC;
page = alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
nc->frag.size = PAGE_SIZE << (page ? order : 0);
}
Expand Down

0 comments on commit 79930f5

Please sign in to comment.