lkml.org 
[lkml]   [2021]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 1/4] mm/vmscan: remove the PageDirty check after MADV_FREE pages are page_ref_freezed
Date
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@huawei.com>
---
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
\
 
 \ /
  Last update: 2021-07-17 09:00    [W:0.101 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site