Commit 98ea0259 authored by zhenwei pi's avatar zhenwei pi Committed by Matthew Wilcox (Oracle)

mm/rmap: Fix handling of hugetlbfs pages in page_vma_mapped_walk

page_mapped_in_vma() sets nr_pages to 1, which is usually correct as we
only want to know about the precise page and not about other pages in
the folio.  However, hugetlbfs does want to know about the entire hpage,
and using nr_pages to get the size of the hpage is wrong.  We could
change page_mapped_in_vma() to special-case hugetlbfs pages, but it's
better to ignore nr_pages in page_vma_mapped_walk() and get the size
from the VMA instead.

Fixes: 2aff7a47 ("mm: Convert page_vma_mapped_walk to work on PFNs")
Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
[edit commit message, use hstate directly]
parent ec4858e0
...@@ -163,7 +163,8 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) ...@@ -163,7 +163,8 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
return not_found(pvmw); return not_found(pvmw);
if (unlikely(is_vm_hugetlb_page(vma))) { if (unlikely(is_vm_hugetlb_page(vma))) {
unsigned long size = pvmw->nr_pages * PAGE_SIZE; struct hstate *hstate = hstate_vma(vma);
unsigned long size = huge_page_size(hstate);
/* The only possible mapping was handled on last iteration */ /* The only possible mapping was handled on last iteration */
if (pvmw->pte) if (pvmw->pte)
return not_found(pvmw); return not_found(pvmw);
...@@ -173,8 +174,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) ...@@ -173,8 +174,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
if (!pvmw->pte) if (!pvmw->pte)
return false; return false;
pvmw->ptl = huge_pte_lockptr(size_to_hstate(size), mm, pvmw->ptl = huge_pte_lockptr(hstate, mm, pvmw->pte);
pvmw->pte);
spin_lock(pvmw->ptl); spin_lock(pvmw->ptl);
if (!check_pte(pvmw)) if (!check_pte(pvmw))
return not_found(pvmw); return not_found(pvmw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment