linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] page_frag: Recover from memory pressure
@ 2020-11-05  4:21 Matthew Wilcox (Oracle)
  2020-11-05 11:56 ` Vlastimil Babka
  2020-11-05 13:21 ` Eric Dumazet
  0 siblings, 2 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2020-11-05  4:21 UTC (permalink / raw)
  To: linux-mm, netdev, Dongli Zhang
  Cc: Matthew Wilcox (Oracle),
	Aruna Ramakrishna, Bert Barbe, Rama Nichanamatlu,
	Venkat Venkatsubra, Manjunath Patil, Joe Jin, SRINIVAS, stable

When the machine is under extreme memory pressure, the page_frag allocator
signals this to the networking stack by marking allocations with the
'pfmemalloc' flag, which causes non-essential packets to be dropped.
Unfortunately, even after the machine recovers from the low memory
condition, the page continues to be used by the page_frag allocator,
so all allocations from this page will continue to be dropped.

Fix this by freeing and re-allocating the page instead of recycling it.

Reported-by: Dongli Zhang <dongli.zhang@oracle.com>
Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Cc: Bert Barbe <bert.barbe@oracle.com>
Cc: Rama Nichanamatlu <rama.nichanamatlu@oracle.com>
Cc: Venkat Venkatsubra <venkat.x.venkatsubra@oracle.com>
Cc: Manjunath Patil <manjunath.b.patil@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Cc: SRINIVAS <srinivas.eeda@oracle.com>
Cc: stable@vger.kernel.org
Fixes: 79930f5892e ("net: do not deplete pfmemalloc reserve")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/page_alloc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 778e815130a6..631546ae1c53 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5139,6 +5139,10 @@ void *page_frag_alloc(struct page_frag_cache *nc,
 
 		if (!page_ref_sub_and_test(page, nc->pagecnt_bias))
 			goto refill;
+		if (nc->pfmemalloc) {
+			free_the_page(page, compound_order(page));
+			goto refill;
+		}
 
 #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
 		/* if size can vary use size else just use PAGE_SIZE */
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-15  6:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  4:21 [PATCH] page_frag: Recover from memory pressure Matthew Wilcox (Oracle)
2020-11-05 11:56 ` Vlastimil Babka
2020-11-05 12:05   ` Matthew Wilcox
2020-11-05 12:09     ` Vlastimil Babka
2020-11-05 13:21 ` Eric Dumazet
2020-11-05 14:02   ` Matthew Wilcox
2020-11-09 14:32     ` Matthew Wilcox
2020-11-09 14:37       ` Eric Dumazet
2020-11-15  6:47         ` Dongli Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).