Skip to content

Commit 900fc5f

Browse files
Naoya Horiguchitorvalds
authored andcommitted
pagewalk: add walk_page_vma()
Introduce walk_page_vma(), which is useful for the callers which want to walk over a given vma. It's used by later patches. Signed-off-by: Naoya Horiguchi <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent fafaa42 commit 900fc5f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

include/linux/mm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,7 @@ struct mm_walk {
12011201

12021202
int walk_page_range(unsigned long addr, unsigned long end,
12031203
struct mm_walk *walk);
1204+
int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
12041205
void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
12051206
unsigned long end, unsigned long floor, unsigned long ceiling);
12061207
int copy_page_range(struct mm_struct *dst, struct mm_struct *src,

mm/pagewalk.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,21 @@ int walk_page_range(unsigned long start, unsigned long end,
272272
} while (start = next, start < end);
273273
return err;
274274
}
275+
276+
int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk)
277+
{
278+
int err;
279+
280+
if (!walk->mm)
281+
return -EINVAL;
282+
283+
VM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem));
284+
VM_BUG_ON(!vma);
285+
walk->vma = vma;
286+
err = walk_page_test(vma->vm_start, vma->vm_end, walk);
287+
if (err > 0)
288+
return 0;
289+
if (err < 0)
290+
return err;
291+
return __walk_page_range(vma->vm_start, vma->vm_end, walk);
292+
}

0 commit comments

Comments
 (0)