Skip to content

Commit

Permalink
mm: fix handling PTE-mapped THPs in page_idle_clear_pte_refs()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kiryl authored and torvalds committed Feb 25, 2017
1 parent 8eaeded commit 699fa21
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions mm/page_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ static int page_idle_clear_pte_refs_one(struct page *page,
struct vm_area_struct *vma,
unsigned long addr, void *arg)
{
struct mm_struct *mm = vma->vm_mm;
pmd_t *pmd;
pte_t *pte;
spinlock_t *ptl;
struct page_vma_mapped_walk pvmw = {
.page = page,
.vma = vma,
.address = addr,
};
bool referenced = false;

if (!page_check_address_transhuge(page, mm, addr, &pmd, &pte, &ptl))
return SWAP_AGAIN;

if (pte) {
referenced = ptep_clear_young_notify(vma, addr, pte);
pte_unmap(pte);
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
referenced = pmdp_clear_young_notify(vma, addr, pmd);
} else {
/* unexpected pmd-mapped page? */
WARN_ON_ONCE(1);
while (page_vma_mapped_walk(&pvmw)) {
addr = pvmw.address;
if (pvmw.pte) {
referenced = ptep_clear_young_notify(vma, addr,
pvmw.pte);
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
referenced = pmdp_clear_young_notify(vma, addr,
pvmw.pmd);
} else {
/* unexpected pmd-mapped page? */
WARN_ON_ONCE(1);
}
}

spin_unlock(ptl);

if (referenced) {
clear_page_idle(page);
/*
Expand Down

0 comments on commit 699fa21

Please sign in to comment.