mm: memcontrol: account pagetables per node
Subsystems (10)
PATCH v2 1/1 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.
---
Changes since v1:
- Tried to fix linking errors for m68k and nds32
Documentation/admin-guide/cgroup-v2.rst | 3 +++ arch/m68k/include/asm/mcf_pgalloc.h | 1 + arch/nds32/mm/mm-nds32.c | 7 ++++--- drivers/base/node.c | 2 +- fs/proc/meminfo.c | 2 +- include/linux/mm.h | 11 +++++++---- include/linux/mmzone.h | 2 +- mm/memcontrol.c | 1 + mm/page_alloc.c | 6 +++--- 9 files changed, 22 insertions(+), 13 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +3 -0
@@ -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.
arch/m68k/include/asm/mcf_pgalloc.h +1 -0
@@ -4,6 +4,7 @@#include <asm/tlb.h> #include <asm/tlbflush.h> +#include <linux/memcontrol.h> extern inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) {
arch/nds32/mm/mm-nds32.c +4 -3
@@ -5,6 +5,7 @@#define __HAVE_ARCH_PGD_FREE#include <asm/pgalloc.h> +#include <linux/memcontrol.h> #define FIRST_KERNEL_PGD_NR (USER_PTRS_PER_PGD)
@@ -34,8 +35,8 @@ 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), -NR_PAGETABLE ); +inc_lruvec_page_state (virt_to_page ((unsigned long *)new_pgd), +NR_PAGETABLE );return new_pgd; }
@@ -59,7 +60,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);
drivers/base/node.c +1 -1
@@ -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)),
fs/proc/meminfo.c +1 -1
@@ -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: ",
include/linux/mm.h +7 -4
@@ -2177,12 +2177,15 @@ static inline void pgtable_init(void)pgtable_cache_init (); } +static void inc_lruvec_page_state (struct page *page,enum node_stat_item idx); +static void dec_lruvec_page_state (struct page *page,enum node_stat_item idx); +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; }
@@ -2190,7 +2193,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) \
@@ -2277,7 +2280,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; }
@@ -2285,7 +2288,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 ); }/*
include/linux/mmzone.h +1 -1
@@ -151,7 +151,6 @@ enum zone_stat_item {NR_ZONE_UNEVICTABLE ,NR_ZONE_WRITE_PENDING ,/* Count of dirty, writeback and unstable pages */ NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ -NR_PAGETABLE ,/* used for pagetables */ /* Second 128 byte cacheline */ NR_BOUNCE , #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -206,6 +205,7 @@ enum node_stat_item {#if IS_ENABLED (CONFIG_SHADOW_CALL_STACK )NR_KERNEL_SCS_KB ,/* measured in KiB */ #endif +NR_PAGETABLE ,/* used for pagetables */ NR_VM_NODE_STAT_ITEMS };
mm/memcontrol.c +1 -0
@@ -1501,6 +1501,7 @@ static struct memory_stat memory_stats[] = { { "anon", PAGE_SIZE, NR_ANON_MAPPED }, { "file", PAGE_SIZE, NR_FILE_PAGES }, { "kernel_stack", 1024, NR_KERNEL_STACK_KB }, + { "pagetables", PAGE_SIZE, NR_PAGETABLE }, { "percpu", 1, MEMCG_PERCPU_B }, { "sock", PAGE_SIZE, MEMCG_SOCK }, { "shmem", PAGE_SIZE, NR_SHMEM },
mm/page_alloc.c +3 -3
@@ -5515,7 +5515,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)global_node_page_state_pages (NR_SLAB_UNRECLAIMABLE_B ),global_node_page_state (NR_FILE_MAPPED ),global_node_page_state (NR_SHMEM ), -global_zone_page_state (NR_PAGETABLE ), +global_node_page_state (NR_PAGETABLE ),global_zone_page_state (NR_BOUNCE ),global_zone_page_state (NR_FREE_PAGES ), free_pcp,
@@ -5547,6 +5547,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)#ifdef CONFIG_SHADOW_CALL_STACK " shadow_call_stack:%lukB" #endif +" pagetables:%lukB" " all_unreclaimable? %s" "\n" , pgdat->node_id,
@@ -5572,6 +5573,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)#ifdef CONFIG_SHADOW_CALL_STACK node_page_state (pgdat,NR_KERNEL_SCS_KB ), #endif +K (node_page_state (pgdat,NR_PAGETABLE )), pgdat->kswapd_failures >=MAX_RECLAIM_RETRIES ? "yes" : "no"); }
@@ -5603,7 +5605,6 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)" present:%lukB" " managed:%lukB" " mlocked:%lukB" -" pagetables:%lukB" " bounce:%lukB" " free_pcp:%lukB" " local_pcp:%ukB"
@@ -5624,7 +5625,6 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)K (zone->present_pages),K (zone_managed_pages (zone)),K (zone_page_state (zone,NR_MLOCK )), -K (zone_page_state (zone,NR_PAGETABLE )),K (zone_page_state (zone,NR_BOUNCE )),K (free_pcp), K(this_cpu_read(zone->pageset->pcp.count)),
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Shakeel,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on m68k/for-next]
[also build test ERROR on driver-core/driver-core-testing linus/master v5.10-rc5 next-20201123] [cannot apply to mmotm/master cgroup/for-next hnaz-linux-mm/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Shakeel-Butt/mm-memcontrol-account-pagetables-per-node/20201124-001640 base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git for-next config: powerpc64-randconfig-m031-20201123 (attached as .config) compiler: powerpc64le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/22c0e4c0c8b324b0a2ffb5e11b18ecb7cea1543d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Shakeel-Butt/mm-memcontrol-account-pagetables-per-node/20201124-001640 git checkout 22c0e4c0c8b324b0a2ffb5e11b18ecb7cea1543d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
powerpc64le-linux-ld: arch/powerpc/mm/book3s64/mmu_context.o: in function `arch_exit_mmap':
>> (.text+0x588): undefined reference to `dec_lruvec_page_state'
(.text+0x588): call to `dec_lruvec_page_state' lacks nop, can't restore toc; (plt call stub)
powerpc64le-linux-ld: final link failed: bad value
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Shakeel,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on m68k/for-next]
[also build test ERROR on driver-core/driver-core-testing linus/master v5.10-rc5 next-20201123] [cannot apply to mmotm/master cgroup/for-next hnaz-linux-mm/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Shakeel-Butt/mm-memcontrol-account-pagetables-per-node/20201124-001640 base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git for-next config: arm-keystone_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/22c0e4c0c8b324b0a2ffb5e11b18ecb7cea1543d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Shakeel-Butt/mm-memcontrol-account-pagetables-per-node/20201124-001640 git checkout 22c0e4c0c8b324b0a2ffb5e11b18ecb7cea1543d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
arm-linux-gnueabi-ld: arch/arm/mm/idmap.o: in function `init_static_idmap':
>> idmap.c:(.init.text+0x10c): undefined reference to `inc_lruvec_page_state' arm-linux-gnueabi-ld: arch/arm/mm/pgd.o: in function `pgd_alloc': pgd.c:(.text+0x32c): undefined reference to `dec_lruvec_page_state' arm-linux-gnueabi-ld: arch/arm/mm/pgd.o: in function `pgd_free': pgd.c:(.text+0x4c8): undefined reference to `dec_lruvec_page_state' >> arm-linux-gnueabi-ld: pgd.c:(.text+0x544): undefined reference to `dec_lruvec_page_state'
arm-linux-gnueabi-ld: pgd.c:(.text+0x634): undefined reference to `dec_lruvec_page_state'
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org