From a25275e2bd1f24834a62011c0ac7241fa66738a2 Mon Sep 17 00:00:00 2001 From: Prakash Gupta Date: Tue, 20 Nov 2018 18:36:20 +0530 Subject: [PATCH] mm: do not shrink pages marked for reclaim by MADV_FREE MADV_FREE clears pte dirty bit and then marks the page lazyfree (clear SwapBacked). PPR increments ISOLATE_FILES count, then isolates page and invokes a reclaim. Inbetween if this lazyfreed page is touched by user then it becomes dirty. PPR in shrink_page_list in try_to_unmap finds the page dirty, marks it back as PageSwapBacked and skips reclaim. As PageSwapBacked set, PPR identifies the page as anon and decrements ISOLATED_ANON, thus creating isolated count mismatch. This results in too_many_isolated() check causing delay in reclaim. Skip reclaiming lazyfreed pages in PPR path. Change-Id: I87223c4fa492c5e373ac48f116384b5de03da9fa Signed-off-by: Prakash Gupta Signed-off-by: Vinayak Menon --- fs/proc/task_mmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 350a1488ef13..49c7278f8d74 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1742,6 +1742,18 @@ cont: if (isolate_lru_page(compound_head(page))) continue; + /* MADV_FREE clears pte dirty bit and then marks the page + * lazyfree (clear SwapBacked). Inbetween if this lazyfreed page + * is touched by user then it becomes dirty. PPR in + * shrink_page_list in try_to_unmap finds the page dirty, marks + * it back as PageSwapBacked and skips reclaim. This can cause + * isolated count mismatch. + */ + if (PageAnon(page) && !PageSwapBacked(page)) { + putback_lru_page(page); + continue; + } + list_add(&page->lru, &page_list); inc_node_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page));