mm: add page_check_address_transhuge() helper

page_referenced_one() and page_idle_clear_pte_refs_one() duplicate the
code for looking up pte of a (possibly transhuge) page.  Move this code
to a new helper function, page_check_address_transhuge(), and make the
above mentioned functions use it.

This is just a cleanup, no functional changes are intended.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Vladimir Davydov 2016-01-15 16:54:45 -08:00 committed by Linus Torvalds
parent d965432234
commit 8749cfea11
3 changed files with 144 additions and 143 deletions

View file

@ -215,6 +215,25 @@ static inline pte_t *page_check_address(struct page *page, struct mm_struct *mm,
return ptep;
}
/*
* Used by idle page tracking to check if a page was referenced via page
* tables.
*/
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
bool page_check_address_transhuge(struct page *page, struct mm_struct *mm,
unsigned long address, pmd_t **pmdp,
pte_t **ptep, spinlock_t **ptlp);
#else
static inline bool page_check_address_transhuge(struct page *page,
struct mm_struct *mm, unsigned long address,
pmd_t **pmdp, pte_t **ptep, spinlock_t **ptlp)
{
*ptep = page_check_address(page, mm, address, ptlp, 0);
*pmdp = NULL;
return !!*ptep;
}
#endif
/*
* Used by swapoff to help locate where page is expected in vma.
*/