BACKPORT: mm: multi-gen LRU: exploit locality in rmap
[platform/kernel/linux-rpi.git] / mm / rmap.c
index ced76b5..57127d7 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -66,6 +66,7 @@
 #include <linux/page_idle.h>
 #include <linux/memremap.h>
 #include <linux/userfaultfd_k.h>
+#include <linux/mm_inline.h>
 
 #include <asm/tlbflush.h>
 
@@ -772,6 +773,12 @@ static bool page_referenced_one(struct page *page, struct vm_area_struct *vma,
                }
 
                if (pvmw.pte) {
+                       if (lru_gen_enabled() && pte_young(*pvmw.pte) &&
+                           !(vma->vm_flags & (VM_SEQ_READ | VM_RAND_READ))) {
+                               lru_gen_look_around(&pvmw);
+                               referenced++;
+                       }
+
                        if (ptep_clear_flush_young_notify(vma, address,
                                                pvmw.pte)) {
                                /*