Re: [PATCH] page_frag: Recover from memory pressure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/5/20 5:21 AM, Matthew Wilcox (Oracle) wrote:
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@xxxxxxxxxx>
Cc: Aruna Ramakrishna <aruna.ramakrishna@xxxxxxxxxx>
Cc: Bert Barbe <bert.barbe@xxxxxxxxxx>
Cc: Rama Nichanamatlu <rama.nichanamatlu@xxxxxxxxxx>
Cc: Venkat Venkatsubra <venkat.x.venkatsubra@xxxxxxxxxx>
Cc: Manjunath Patil <manjunath.b.patil@xxxxxxxxxx>
Cc: Joe Jin <joe.jin@xxxxxxxxxx>
Cc: SRINIVAS <srinivas.eeda@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 79930f5892e ("net: do not deplete pfmemalloc reserve")
Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
  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;

Theoretically the refill can fail and we return NULL while leaving nc->va pointing to a freed page, so I think you should set nc->va to NULL.

Geez, can't the same thing already happen after we sub the nc->pagecnt_bias from page ref, and last users of the page fragments then return them and dec the ref to zero and the page gets freed?

+		}
#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
  		/* if size can vary use size else just use PAGE_SIZE */







[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux