Skip to content

Commit 90073ae

Browse files
Hugh DickinsSasha Levin
authored andcommitted
mm: page_vma_mapped_walk(): get vma_address_end() earlier
commit a765c41 upstream. 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/4542b34d-862f-7cb4-bb22-e0df6ce830a2@google.com Signed-off-by: Hugh Dickins <hughd@google.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Alistair Popple <apopple@nvidia.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Peter Xu <peterx@redhat.com> Cc: Ralph Campbell <rcampbell@nvidia.com> Cc: Wang Yugui <wangyugui@e16-tech.com> Cc: Will Deacon <will@kernel.org> Cc: Yang Shi <shy828301@gmail.com> Cc: Zi Yan <ziy@nvidia.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf60fc2 commit 90073ae

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎mm/page_vma_mapped.c‎

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

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

0 commit comments

Comments
 (0)