Skip to content

Commit c28ac3c

Browse files
Yu Zhaoakpm00
authored andcommitted
mm/mglru: skip special VMAs in lru_gen_look_around()
Special VMAs like VM_PFNMAP can contain anon pages from COW. There isn't much profit in doing lookaround on them. Besides, they can trigger the pte_special() warning in get_pte_pfn(). Skip them in lru_gen_look_around(). Link: https://lkml.kernel.org/r/[email protected] Fixes: 018ee47 ("mm: multi-gen LRU: exploit locality in rmap") Signed-off-by: Yu Zhao <[email protected]> Reported-by: [email protected] Closes: https://lore.kernel.org/[email protected]/ Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4bdd58d commit c28ac3c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mm/vmscan.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3955,6 +3955,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
39553955
int young = 0;
39563956
pte_t *pte = pvmw->pte;
39573957
unsigned long addr = pvmw->address;
3958+
struct vm_area_struct *vma = pvmw->vma;
39583959
struct folio *folio = pfn_folio(pvmw->pfn);
39593960
bool can_swap = !folio_is_file_lru(folio);
39603961
struct mem_cgroup *memcg = folio_memcg(folio);
@@ -3969,11 +3970,15 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
39693970
if (spin_is_contended(pvmw->ptl))
39703971
return;
39713972

3973+
/* exclude special VMAs containing anon pages from COW */
3974+
if (vma->vm_flags & VM_SPECIAL)
3975+
return;
3976+
39723977
/* avoid taking the LRU lock under the PTL when possible */
39733978
walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
39743979

3975-
start = max(addr & PMD_MASK, pvmw->vma->vm_start);
3976-
end = min(addr | ~PMD_MASK, pvmw->vma->vm_end - 1) + 1;
3980+
start = max(addr & PMD_MASK, vma->vm_start);
3981+
end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
39773982

39783983
if (end - start > MIN_LRU_BATCH * PAGE_SIZE) {
39793984
if (addr - start < MIN_LRU_BATCH * PAGE_SIZE / 2)
@@ -3998,7 +4003,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
39984003
unsigned long pfn;
39994004
pte_t ptent = ptep_get(pte + i);
40004005

4001-
pfn = get_pte_pfn(ptent, pvmw->vma, addr);
4006+
pfn = get_pte_pfn(ptent, vma, addr);
40024007
if (pfn == -1)
40034008
continue;
40044009

@@ -4009,7 +4014,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
40094014
if (!folio)
40104015
continue;
40114016

4012-
if (!ptep_test_and_clear_young(pvmw->vma, addr, pte + i))
4017+
if (!ptep_test_and_clear_young(vma, addr, pte + i))
40134018
VM_WARN_ON_ONCE(true);
40144019

40154020
young++;

0 commit comments

Comments
 (0)