Skip to content

Commit a765c41

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: page_vma_mapped_walk(): get vma_address_end() earlier
page_vma_mapped_walk() cleanup: get THP's vma_address_end() at the start, rather than later at next_pte. It's a little unnecessary overhead on the first call, but makes for a simpler loop in the following commit. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Peter Xu <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Wang Yugui <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yang Shi <[email protected]> Cc: Zi Yan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4744663 commit a765c41

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mm/page_vma_mapped.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
171171
return true;
172172
}
173173

174+
/*
175+
* Seek to next pte only makes sense for THP.
176+
* But more important than that optimization, is to filter out
177+
* any PageKsm page: whose page->index misleads vma_address()
178+
* and vma_address_end() to disaster.
179+
*/
180+
end = PageTransCompound(page) ?
181+
vma_address_end(page, pvmw->vma) :
182+
pvmw->address + PAGE_SIZE;
174183
if (pvmw->pte)
175184
goto next_pte;
176185
restart:
@@ -238,10 +247,6 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
238247
if (check_pte(pvmw))
239248
return true;
240249
next_pte:
241-
/* Seek to next pte only makes sense for THP */
242-
if (!PageTransHuge(page))
243-
return not_found(pvmw);
244-
end = vma_address_end(page, pvmw->vma);
245250
do {
246251
pvmw->address += PAGE_SIZE;
247252
if (pvmw->address >= end)

0 commit comments

Comments
 (0)