Skip to content

Commit 3200a8a

Browse files
Dave Hansentorvalds
authored andcommitted
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: Dave Hansen <[email protected]> Acked-by: Hugh Dickins <[email protected]> Reviewed-by: Christoph Lameter <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent eb4866d commit 3200a8a

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

fs/proc/task_mmu.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,29 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty,
904904
md->node[page_to_nid(page)] += nr_pages;
905905
}
906906

907+
static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma,
908+
unsigned long addr)
909+
{
910+
struct page *page;
911+
int nid;
912+
913+
if (!pte_present(pte))
914+
return NULL;
915+
916+
page = vm_normal_page(vma, addr, pte);
917+
if (!page)
918+
return NULL;
919+
920+
if (PageReserved(page))
921+
return NULL;
922+
923+
nid = page_to_nid(page);
924+
if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
925+
return NULL;
926+
927+
return page;
928+
}
929+
907930
static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
908931
unsigned long end, struct mm_walk *walk)
909932
{
@@ -915,23 +938,9 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
915938
md = walk->private;
916939
orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
917940
do {
918-
struct page *page;
919-
int nid;
920-
921-
if (!pte_present(*pte))
922-
continue;
923-
924-
page = vm_normal_page(md->vma, addr, *pte);
941+
struct page *page = can_gather_numa_stats(*pte, md->vma, addr);
925942
if (!page)
926943
continue;
927-
928-
if (PageReserved(page))
929-
continue;
930-
931-
nid = page_to_nid(page);
932-
if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
933-
continue;
934-
935944
gather_stats(page, md, pte_dirty(*pte), 1);
936945

937946
} while (pte++, addr += PAGE_SIZE, addr != end);

0 commit comments

Comments
 (0)