Skip to content

Commit 699fa21

Browse files
kiryltorvalds
authored andcommitted
mm: fix handling PTE-mapped THPs in page_idle_clear_pte_refs()
For PTE-mapped THP page_check_address_transhuge() is not adequate: it cannot find all relevant PTEs, only the first one.i Let's switch it to page_vma_mapped_walk(). I don't think it's subject for stable@: it's not fatal. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Kirill A. Shutemov <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Srikar Dronamraju <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8eaeded commit 699fa21

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

mm/page_idle.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@ static int page_idle_clear_pte_refs_one(struct page *page,
5454
struct vm_area_struct *vma,
5555
unsigned long addr, void *arg)
5656
{
57-
struct mm_struct *mm = vma->vm_mm;
58-
pmd_t *pmd;
59-
pte_t *pte;
60-
spinlock_t *ptl;
57+
struct page_vma_mapped_walk pvmw = {
58+
.page = page,
59+
.vma = vma,
60+
.address = addr,
61+
};
6162
bool referenced = false;
6263

63-
if (!page_check_address_transhuge(page, mm, addr, &pmd, &pte, &ptl))
64-
return SWAP_AGAIN;
65-
66-
if (pte) {
67-
referenced = ptep_clear_young_notify(vma, addr, pte);
68-
pte_unmap(pte);
69-
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
70-
referenced = pmdp_clear_young_notify(vma, addr, pmd);
71-
} else {
72-
/* unexpected pmd-mapped page? */
73-
WARN_ON_ONCE(1);
64+
while (page_vma_mapped_walk(&pvmw)) {
65+
addr = pvmw.address;
66+
if (pvmw.pte) {
67+
referenced = ptep_clear_young_notify(vma, addr,
68+
pvmw.pte);
69+
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
70+
referenced = pmdp_clear_young_notify(vma, addr,
71+
pvmw.pmd);
72+
} else {
73+
/* unexpected pmd-mapped page? */
74+
WARN_ON_ONCE(1);
75+
}
7476
}
7577

76-
spin_unlock(ptl);
77-
7878
if (referenced) {
7979
clear_page_idle(page);
8080
/*

0 commit comments

Comments
 (0)