[PATCH] mm: clean up lazyfree page handling

From: Minchan Kim
Date: Thu Mar 02 2017 - 21:42:52 EST


We can make it simple to understand without need to be aware of
clean-swapin page.
This patch just clean up lazyfree page handling in try_to_unmap_one.

Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
---
mm/rmap.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index bb45712..f7eab40 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1413,17 +1413,17 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
VM_BUG_ON_PAGE(!PageSwapCache(page) && PageSwapBacked(page),
page);

- /*
- * swapin page could be clean, it has data stored in
- * swap. We can't silently discard it without setting
- * swap entry in the page table.
- */
- if (!PageDirty(page) && !PageSwapCache(page)) {
- /* It's a freeable page by MADV_FREE */
- dec_mm_counter(mm, MM_ANONPAGES);
- goto discard;
- } else if (!PageSwapBacked(page)) {
- /* dirty MADV_FREE page */
+ /* MADV_FREE page check */
+ if (!PageSwapBacked(page)) {
+ if (!PageDirty(page)) {
+ dec_mm_counter(mm, MM_ANONPAGES);
+ goto discard;
+ }
+
+ /*
+ * If the page was redirtied, it cannot be
+ * discarded. Remap the page to page table.
+ */
set_pte_at(mm, address, pvmw.pte, pteval);
ret = SWAP_DIRTY;
page_vma_mapped_walk_done(&pvmw);
--
2.7.4