Commit f0c0c115 authored by Shakeel Butt's avatar Shakeel Butt Committed by Linus Torvalds
Browse files

mm: memcontrol: account pagetables per node

For many workloads, pagetable consumption is significant and it makes
sense to expose it in the memory.stat for the memory cgroups.  However at
the moment, the pagetables are accounted per-zone.  Converting them to
per-node and using the right interface will correctly account for the
memory cgroups as well.

[akpm@linux-foundation.org: export __mod_lruvec_page_state to modules for arch/mips/kvm/]

Link: https://lkml.kernel.org/r/20201130212541.2781790-3-shakeelb@google.com


Signed-off-by: default avatarShakeel Butt <shakeelb@google.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarRoman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c47d5032
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1274,6 +1274,9 @@ PAGE_SIZE multiple when read back.
	  kernel_stack
		Amount of memory allocated to kernel stacks.

	  pagetables
                Amount of memory allocated for page tables.

	  percpu(npn)
		Amount of memory used for storing per-cpu kernel
		data structures.
+3 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
	cpu_dcache_wb_range((unsigned long)new_pgd,
			    (unsigned long)new_pgd +
			    PTRS_PER_PGD * sizeof(pgd_t));
	inc_zone_page_state(virt_to_page((unsigned long *)new_pgd),
	inc_lruvec_page_state(virt_to_page((unsigned long *)new_pgd),
			      NR_PAGETABLE);

	return new_pgd;
@@ -59,7 +59,7 @@ void pgd_free(struct mm_struct *mm, pgd_t * pgd)

	pte = pmd_page(*pmd);
	pmd_clear(pmd);
	dec_zone_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
	dec_lruvec_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
	pte_free(mm, pte);
	mm_dec_nr_ptes(mm);
	pmd_free(mm, pmd);
+1 −1
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ static ssize_t node_read_meminfo(struct device *dev,
#ifdef CONFIG_SHADOW_CALL_STACK
			     nid, node_page_state(pgdat, NR_KERNEL_SCS_KB),
#endif
			     nid, K(sum_zone_node_page_state(nid, NR_PAGETABLE)),
			     nid, K(node_page_state(pgdat, NR_PAGETABLE)),
			     nid, 0UL,
			     nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)),
			     nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)),
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
		   global_node_page_state(NR_KERNEL_SCS_KB));
#endif
	show_val_kb(m, "PageTables:     ",
		    global_zone_page_state(NR_PAGETABLE));
		    global_node_page_state(NR_PAGETABLE));

	show_val_kb(m, "NFS_Unstable:   ", 0);
	show_val_kb(m, "Bounce:         ",
+4 −4
Original line number Diff line number Diff line
@@ -2203,7 +2203,7 @@ static inline bool pgtable_pte_page_ctor(struct page *page)
	if (!ptlock_init(page))
		return false;
	__SetPageTable(page);
	inc_zone_page_state(page, NR_PAGETABLE);
	inc_lruvec_page_state(page, NR_PAGETABLE);
	return true;
}

@@ -2211,7 +2211,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
{
	ptlock_free(page);
	__ClearPageTable(page);
	dec_zone_page_state(page, NR_PAGETABLE);
	dec_lruvec_page_state(page, NR_PAGETABLE);
}

#define pte_offset_map_lock(mm, pmd, address, ptlp)	\
@@ -2298,7 +2298,7 @@ static inline bool pgtable_pmd_page_ctor(struct page *page)
	if (!pmd_ptlock_init(page))
		return false;
	__SetPageTable(page);
	inc_zone_page_state(page, NR_PAGETABLE);
	inc_lruvec_page_state(page, NR_PAGETABLE);
	return true;
}

@@ -2306,7 +2306,7 @@ static inline void pgtable_pmd_page_dtor(struct page *page)
{
	pmd_ptlock_free(page);
	__ClearPageTable(page);
	dec_zone_page_state(page, NR_PAGETABLE);
	dec_lruvec_page_state(page, NR_PAGETABLE);
}

/*
Loading