Commit 699fa216 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Linus Torvalds

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/20170129173858.45174-5-kirill.shutemov@linux.intel.comSigned-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8eaedede
...@@ -54,26 +54,26 @@ static int page_idle_clear_pte_refs_one(struct page *page, ...@@ -54,26 +54,26 @@ static int page_idle_clear_pte_refs_one(struct page *page,
struct vm_area_struct *vma, struct vm_area_struct *vma,
unsigned long addr, void *arg) unsigned long addr, void *arg)
{ {
struct mm_struct *mm = vma->vm_mm; struct page_vma_mapped_walk pvmw = {
pmd_t *pmd; .page = page,
pte_t *pte; .vma = vma,
spinlock_t *ptl; .address = addr,
};
bool referenced = false; bool referenced = false;
if (!page_check_address_transhuge(page, mm, addr, &pmd, &pte, &ptl)) while (page_vma_mapped_walk(&pvmw)) {
return SWAP_AGAIN; addr = pvmw.address;
if (pvmw.pte) {
if (pte) { referenced = ptep_clear_young_notify(vma, addr,
referenced = ptep_clear_young_notify(vma, addr, pte); pvmw.pte);
pte_unmap(pte);
} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) { } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
referenced = pmdp_clear_young_notify(vma, addr, pmd); referenced = pmdp_clear_young_notify(vma, addr,
pvmw.pmd);
} else { } else {
/* unexpected pmd-mapped page? */ /* unexpected pmd-mapped page? */
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
} }
}
spin_unlock(ptl);
if (referenced) { if (referenced) {
clear_page_idle(page); clear_page_idle(page);
......
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