[PATCH v2 1/4] mm/vmscan: remove the PageDirty check after MADV_FREE pages are page_ref_freezed

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

 



If the MADV_FREE pages are redirtied before they could be reclaimed,
put the pages back to anonymous LRU list by setting SwapBacked flag
and the pages will be reclaimed in normal swapout way. But as Yu Zhao
pointed out, "The page has only one reference left, which is from the
isolation. After the caller puts the page back on lru and drops the
reference, the page will be freed anyway. It doesn't matter which lru
it goes." So we don't bother checking PageDirty here.

[Yu Zhao's comment is also quoted in the code.]

Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
---
 mm/vmscan.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index a7602f71ec04..92a515e82b1b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1627,11 +1627,14 @@ static unsigned int shrink_page_list(struct list_head *page_list,
 			/* follow __remove_mapping for reference */
 			if (!page_ref_freeze(page, 1))
 				goto keep_locked;
-			if (PageDirty(page)) {
-				page_ref_unfreeze(page, 1);
-				goto keep_locked;
-			}
-
+			/*
+			 * The page has only one reference left, which is
+			 * from the isolation. After the caller puts the
+			 * page back on lru and drops the reference, the
+			 * page will be freed anyway. It doesn't matter
+			 * which lru it goes. So we don't bother checking
+			 * PageDirty here.
+			 */
 			count_vm_event(PGLAZYFREED);
 			count_memcg_page_event(page, PGLAZYFREED);
 		} else if (!mapping || !__remove_mapping(mapping, page, true,
-- 
2.23.0






[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