[PATCH v6 1/4] mm/khugepaged: drain lru after swapping in shmem

From: David Stevens
Date: Tue Apr 04 2023 - 08:01:36 EST


From: David Stevens <stevensd@xxxxxxxxxxxx>

Call lru_add_drain after swapping in shmem pages so that
isolate_lru_page is more likely to succeed.

Signed-off-by: David Stevens <stevensd@xxxxxxxxxxxx>
---
mm/khugepaged.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 666d2c4e38dd..90577247cfaf 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1963,6 +1963,8 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
result = SCAN_FAIL;
goto xa_unlocked;
}
+ /* drain pagevecs to help isolate_lru_page() */
+ lru_add_drain();
page = folio_file_page(folio, index);
} else if (trylock_page(page)) {
get_page(page);
--
2.40.0.348.gf938b09366-goog