From 34af6dd5b84ecbe3a0b20f98acb4034d5708685c Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 14 Apr 2022 12:16:57 -0700 Subject: [PATCH 1/3] mm/vmscan: Use VMA_ITERATOR in get_next_vma() The next vma may actually be many VMAs away, so use the VMA_ITERATOR to continue searching from vm_end onwards. Signed-off-by: Liam R. Howlett --- mm/vmscan.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d4a7d2bd276d..0f5c53996365 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3697,24 +3697,21 @@ static bool get_next_vma(struct mm_walk *walk, unsigned long mask, unsigned long unsigned long *start, unsigned long *end) { unsigned long next = round_up(*end, size); + VMA_ITERATOR(vmi, walk->mm, walk->vma->vm_end) VM_BUG_ON(mask & size); VM_BUG_ON(*start >= *end); VM_BUG_ON((next & mask) != (*start & mask)); - while (walk->vma) { - if (next >= walk->vma->vm_end) { - walk->vma = walk->vma->vm_next; + for_each_mte_vma(vmi, walk->vma) { + if (next >= walk->vma->vm_end) continue; - } if ((next & mask) != (walk->vma->vm_start & mask)) return false; - if (should_skip_vma(walk->vma->vm_start, walk->vma->vm_end, walk)) { - walk->vma = walk->vma->vm_next; + if (should_skip_vma(walk->vma->vm_start, walk->vma->vm_end, walk)) continue; - } *start = max(next, walk->vma->vm_start); next = (next | ~mask) + 1; @@ -4062,7 +4059,7 @@ static void walk_mm(struct lruvec *lruvec, struct mm_struct *mm, struct lru_gen_ /* the caller might be holding the lock for write */ if (mmap_read_trylock(mm)) { unsigned long start = walk->next_addr; - unsigned long end = mm->highest_vm_end; + unsigned long end = ULONG_MAX; err = walk_page_range(mm, start, end, &mm_walk_ops, walk); -- 2.34.1