Skip to content

Commit c48a11c

Browse files
Mel Gormantorvalds
authored andcommitted
netvm: propagate page->pfmemalloc to skb
The skb->pfmemalloc flag gets set to true iff during the slab allocation of data in __alloc_skb that the the PFMEMALLOC reserves were used. If the packet is fragmented, it is possible that pages will be allocated from the PFMEMALLOC reserve without propagating this information to the skb. This patch propagates page->pfmemalloc from pages allocated for fragments to the skb. Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: David S. Miller <davem@davemloft.net> Cc: Neil Brown <neilb@suse.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Christie <michaelc@cs.wisc.edu> Cc: Eric B Munson <emunson@mgebm.net> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Cc: Mel Gorman <mgorman@suse.de> Cc: Christoph Lameter <cl@linux.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c93bdd0 commit c48a11c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/skbuff.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,17 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
12471247
{
12481248
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
12491249

1250+
/*
1251+
* Propagate page->pfmemalloc to the skb if we can. The problem is
1252+
* that not all callers have unique ownership of the page. If
1253+
* pfmemalloc is set, we check the mapping as a mapping implies
1254+
* page->index is set (index and pfmemalloc share space).
1255+
* If it's a valid mapping, we cannot use page->pfmemalloc but we
1256+
* do not lose pfmemalloc information as the pages would not be
1257+
* allocated using __GFP_MEMALLOC.
1258+
*/
1259+
if (page->pfmemalloc && !page->mapping)
1260+
skb->pfmemalloc = true;
12501261
frag->page.p = page;
12511262
frag->page_offset = off;
12521263
skb_frag_size_set(frag, size);

0 commit comments

Comments
 (0)