From: Kirill A. Shutemov Date: Wed, 3 Jun 2020 23:00:12 +0000 (-0700) Subject: khugepaged: drain all LRU caches before scanning pages X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a980df33e9351e5474c06ec0fd96b2f409e2ff22;p=linux.git khugepaged: drain all LRU caches before scanning pages Having a page in LRU add cache offsets page refcount and gives false-negative on PageLRU(). It reduces collapse success rate. Drain all LRU add caches before scanning. It happens relatively rare and should not disturb the system too much. Signed-off-by: Kirill A. Shutemov Signed-off-by: Andrew Morton Tested-by: Zi Yan Reviewed-by: William Kucharski Reviewed-by: Zi Yan Acked-by: Yang Shi Cc: Andrea Arcangeli Cc: John Hubbard Cc: Mike Kravetz Cc: Ralph Campbell Link: http://lkml.kernel.org/r/20200416160026.16538-4-kirill.shutemov@linux.intel.com Signed-off-by: Linus Torvalds --- diff --git a/mm/khugepaged.c b/mm/khugepaged.c index c436fd390296f..8a74b9705a655 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2079,6 +2079,8 @@ static void khugepaged_do_scan(void) barrier(); /* write khugepaged_pages_to_scan to local stack */ + lru_add_drain_all(); + while (progress < pages) { if (!khugepaged_prealloc_page(&hpage, &wait)) break;