Commit 3200a8aa authored by Dave Hansen's avatar Dave Hansen Committed by Linus Torvalds

break out numa_maps gather_pte_stats() checks

gather_pte_stats() does a number of checks on a target page
to see whether it should even be considered for statistics.
This breaks that code out in to a separate function so that
we can use it in the transparent hugepage case in the next
patch.
Signed-off-by: default avatarDave Hansen <dave@linux.vnet.ibm.com>
Acked-by: default avatarHugh Dickins <hughd@google.com>
Reviewed-by: default avatarChristoph Lameter <cl@gentwo.org>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent eb4866d0
...@@ -904,6 +904,29 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, ...@@ -904,6 +904,29 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty,
md->node[page_to_nid(page)] += nr_pages; md->node[page_to_nid(page)] += nr_pages;
} }
static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma,
unsigned long addr)
{
struct page *page;
int nid;
if (!pte_present(pte))
return NULL;
page = vm_normal_page(vma, addr, pte);
if (!page)
return NULL;
if (PageReserved(page))
return NULL;
nid = page_to_nid(page);
if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
return NULL;
return page;
}
static int gather_pte_stats(pmd_t *pmd, unsigned long addr, static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
unsigned long end, struct mm_walk *walk) unsigned long end, struct mm_walk *walk)
{ {
...@@ -915,23 +938,9 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, ...@@ -915,23 +938,9 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
md = walk->private; md = walk->private;
orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
do { do {
struct page *page; struct page *page = can_gather_numa_stats(*pte, md->vma, addr);
int nid;
if (!pte_present(*pte))
continue;
page = vm_normal_page(md->vma, addr, *pte);
if (!page) if (!page)
continue; continue;
if (PageReserved(page))
continue;
nid = page_to_nid(page);
if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
continue;
gather_stats(page, md, pte_dirty(*pte), 1); gather_stats(page, md, pte_dirty(*pte), 1);
} while (pte++, addr += PAGE_SIZE, addr != end); } while (pte++, addr += PAGE_SIZE, addr != end);
......
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