The patch titled Subject: mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3 has been added to the -mm tree. Its filename is mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Muchun Song <songmuchun@xxxxxxxxxxxxx> Subject: mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3 1. Fix compiler error on powerpc architecture reported by kernel test robot. 2. Fix a typo from "anno" to "anon". Link: https://lkml.kernel.org/r/20200913070010.44053-1-songmuchun@xxxxxxxxxxxxx Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Suggested-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Cc: Chris Down <chris@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 85 +++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 31 deletions(-) --- a/mm/memcontrol.c~mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3 +++ a/mm/memcontrol.c @@ -6384,6 +6384,52 @@ static int memory_stat_show(struct seq_f } #ifdef CONFIG_NUMA +struct numa_stat { + const char *name; + unsigned int ratio; + enum node_stat_item idx; +}; + +static struct numa_stat numa_stats[] = { + { "anon", PAGE_SIZE, NR_ANON_MAPPED }, + { "file", PAGE_SIZE, NR_FILE_PAGES }, + { "kernel_stack", 1024, NR_KERNEL_STACK_KB }, + { "shmem", PAGE_SIZE, NR_SHMEM }, + { "file_mapped", PAGE_SIZE, NR_FILE_MAPPED }, + { "file_dirty", PAGE_SIZE, NR_FILE_DIRTY }, + { "file_writeback", PAGE_SIZE, NR_WRITEBACK }, +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + /* + * The ratio will be initialized in numa_stats_init(). Because + * on some architectures, the macro of HPAGE_PMD_SIZE is not + * constant(e.g. powerpc). + */ + { "anon_thp", 0, NR_ANON_THPS }, +#endif + { "inactive_anon", PAGE_SIZE, NR_INACTIVE_ANON }, + { "active_anon", PAGE_SIZE, NR_ACTIVE_ANON }, + { "inactive_file", PAGE_SIZE, NR_INACTIVE_FILE }, + { "active_file", PAGE_SIZE, NR_ACTIVE_FILE }, + { "unevictable", PAGE_SIZE, NR_UNEVICTABLE }, + { "slab_reclaimable", 1, NR_SLAB_RECLAIMABLE_B }, + { "slab_unreclaimable", 1, NR_SLAB_UNRECLAIMABLE_B }, +}; + +static int __init numa_stats_init(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(numa_stats); i++) { +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (numa_stats[i].idx == NR_ANON_THPS) + numa_stats[i].ratio = HPAGE_PMD_SIZE; +#endif + } + + return 0; +} +pure_initcall(numa_stats_init); + static unsigned long memcg_node_page_state(struct mem_cgroup *memcg, unsigned int nid, enum node_stat_item idx) @@ -6394,33 +6440,7 @@ static unsigned long memcg_node_page_sta static const char *memory_numa_stat_format(struct mem_cgroup *memcg) { - struct numa_stat { - const char *name; - unsigned int ratio; - enum node_stat_item idx; - }; - - static const struct numa_stat stats[] = { - { "anno", PAGE_SIZE, NR_ANON_MAPPED }, - { "file", PAGE_SIZE, NR_FILE_PAGES }, - { "kernel_stack", 1024, NR_KERNEL_STACK_KB }, - { "shmem", PAGE_SIZE, NR_SHMEM }, - { "file_mapped", PAGE_SIZE, NR_FILE_MAPPED }, - { "file_dirty", PAGE_SIZE, NR_FILE_DIRTY }, - { "file_writeback", PAGE_SIZE, NR_WRITEBACK }, -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - { "anon_thp", HPAGE_PMD_SIZE, NR_ANON_THPS }, -#endif - { "inactive_anon", PAGE_SIZE, NR_INACTIVE_ANON }, - { "active_anon", PAGE_SIZE, NR_ACTIVE_ANON }, - { "inactive_file", PAGE_SIZE, NR_INACTIVE_FILE }, - { "active_file", PAGE_SIZE, NR_ACTIVE_FILE }, - { "unevictable", PAGE_SIZE, NR_UNEVICTABLE }, - { "slab_reclaimable", 1, NR_SLAB_RECLAIMABLE_B }, - { "slab_unreclaimable", 1, NR_SLAB_UNRECLAIMABLE_B }, - }; - - int i, nid; + int i; struct seq_buf s; /* Reserve a byte for the trailing null */ @@ -6428,13 +6448,16 @@ static const char *memory_numa_stat_form if (!s.buffer) return NULL; - for (i = 0; i < ARRAY_SIZE(stats); i++) { - seq_buf_printf(&s, "%s", stats[i].name); + for (i = 0; i < ARRAY_SIZE(numa_stats); i++) { + int nid; + + seq_buf_printf(&s, "%s", numa_stats[i].name); for_each_node_state(nid, N_MEMORY) { u64 size; - size = memcg_node_page_state(memcg, nid, stats[i].idx); - size *= stats[i].ratio; + size = memcg_node_page_state(memcg, nid, + numa_stats[i].idx); + size *= numa_stats[i].ratio; seq_buf_printf(&s, " N%d=%llu", nid, size); } seq_buf_putc(&s, '\n'); _ Patches currently in -mm which might be from songmuchun@xxxxxxxxxxxxx are kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2.patch mm-memcontrol-add-the-missing-numa_stat-interface-for-cgroup-v2-v3.patch mm-memcontrol-fix-out-of-bounds-on-the-buf-returned-by-memory_stat_format.patch mmhwpoison-refactor-soft_offline_huge_page-and-__soft_offline_page-fix-2.patch