Skip to content

Commit 6d0fd59

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: page_vma_mapped_walk(): settle PageHuge on entry
page_vma_mapped_walk() cleanup: get the hugetlbfs PageHuge case out of the way at the start, so no need to worry about it later. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Peter Xu <[email protected]> Cc: Alistair Popple <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Matthew Wilcox <[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 f003c03 commit 6d0fd59

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mm/page_vma_mapped.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
153153
if (pvmw->pmd && !pvmw->pte)
154154
return not_found(pvmw);
155155

156-
if (pvmw->pte)
157-
goto next_pte;
158-
159156
if (unlikely(PageHuge(page))) {
157+
/* The only possible mapping was handled on last iteration */
158+
if (pvmw->pte)
159+
return not_found(pvmw);
160+
160161
/* when pud is not present, pte will be NULL */
161162
pvmw->pte = huge_pte_offset(mm, pvmw->address, page_size(page));
162163
if (!pvmw->pte)
@@ -168,6 +169,9 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
168169
return not_found(pvmw);
169170
return true;
170171
}
172+
173+
if (pvmw->pte)
174+
goto next_pte;
171175
restart:
172176
pgd = pgd_offset(mm, pvmw->address);
173177
if (!pgd_present(*pgd))
@@ -233,7 +237,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
233237
return true;
234238
next_pte:
235239
/* Seek to next pte only makes sense for THP */
236-
if (!PageTransHuge(page) || PageHuge(page))
240+
if (!PageTransHuge(page))
237241
return not_found(pvmw);
238242
end = vma_address_end(page, pvmw->vma);
239243
do {

0 commit comments

Comments
 (0)