Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: memcontrol: switch to native NR_VMALLOC vmstat counter

Eliminates the custom memcg counter and results in a single, consolidated
accounting call in vmalloc code.

Link: https://lkml.kernel.org/r/20260223160147.3792777-2-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Johannes Weiner and committed by
Andrew Morton
c466412c b9ec0ed9

+6 -15
-1
include/linux/memcontrol.h
··· 35 35 MEMCG_SWAP = NR_VM_NODE_STAT_ITEMS, 36 36 MEMCG_SOCK, 37 37 MEMCG_PERCPU_B, 38 - MEMCG_VMALLOC, 39 38 MEMCG_KMEM, 40 39 MEMCG_ZSWAP_B, 41 40 MEMCG_ZSWAPPED,
+2 -2
mm/memcontrol.c
··· 317 317 NR_SHMEM_THPS, 318 318 NR_FILE_THPS, 319 319 NR_ANON_THPS, 320 + NR_VMALLOC, 320 321 NR_KERNEL_STACK_KB, 321 322 NR_PAGETABLE, 322 323 NR_SECONDARY_PAGETABLE, ··· 353 352 MEMCG_SWAP, 354 353 MEMCG_SOCK, 355 354 MEMCG_PERCPU_B, 356 - MEMCG_VMALLOC, 357 355 MEMCG_KMEM, 358 356 MEMCG_ZSWAP_B, 359 357 MEMCG_ZSWAPPED, ··· 1364 1364 { "sec_pagetables", NR_SECONDARY_PAGETABLE }, 1365 1365 { "percpu", MEMCG_PERCPU_B }, 1366 1366 { "sock", MEMCG_SOCK }, 1367 - { "vmalloc", MEMCG_VMALLOC }, 1367 + { "vmalloc", NR_VMALLOC }, 1368 1368 { "shmem", NR_SHMEM }, 1369 1369 #ifdef CONFIG_ZSWAP 1370 1370 { "zswap", MEMCG_ZSWAP_B },
+4 -12
mm/vmalloc.c
··· 3459 3459 3460 3460 if (unlikely(vm->flags & VM_FLUSH_RESET_PERMS)) 3461 3461 vm_reset_perms(vm); 3462 - /* All pages of vm should be charged to same memcg, so use first one. */ 3463 - if (vm->nr_pages && !(vm->flags & VM_MAP_PUT_PAGES)) 3464 - mod_memcg_page_state(vm->pages[0], MEMCG_VMALLOC, -vm->nr_pages); 3465 3462 for (i = 0; i < vm->nr_pages; i++) { 3466 3463 struct page *page = vm->pages[i]; 3467 3464 ··· 3468 3471 * can be freed as an array of order-0 allocations 3469 3472 */ 3470 3473 if (!(vm->flags & VM_MAP_PUT_PAGES)) 3471 - dec_node_page_state(page, NR_VMALLOC); 3474 + mod_lruvec_page_state(page, NR_VMALLOC, -1); 3472 3475 __free_page(page); 3473 3476 cond_resched(); 3474 3477 } ··· 3659 3662 continue; 3660 3663 } 3661 3664 3662 - mod_node_page_state(page_pgdat(page), NR_VMALLOC, 1 << large_order); 3665 + mod_lruvec_page_state(page, NR_VMALLOC, 1 << large_order); 3663 3666 3664 3667 split_page(page, large_order); 3665 3668 for (i = 0; i < (1U << large_order); i++) ··· 3706 3709 pages + nr_allocated); 3707 3710 3708 3711 for (i = nr_allocated; i < nr_allocated + nr; i++) 3709 - inc_node_page_state(pages[i], NR_VMALLOC); 3712 + mod_lruvec_page_state(pages[i], NR_VMALLOC, 1); 3710 3713 3711 3714 nr_allocated += nr; 3712 3715 ··· 3732 3735 if (unlikely(!page)) 3733 3736 break; 3734 3737 3735 - mod_node_page_state(page_pgdat(page), NR_VMALLOC, 1 << order); 3738 + mod_lruvec_page_state(page, NR_VMALLOC, 1 << order); 3736 3739 3737 3740 /* 3738 3741 * High-order allocations must be able to be treated as ··· 3875 3878 area->nr_pages = vm_area_alloc_pages( 3876 3879 vmalloc_gfp_adjust(gfp_mask, page_order), node, 3877 3880 page_order, nr_small_pages, area->pages); 3878 - 3879 - /* All pages of vm should be charged to same memcg, so use first one. */ 3880 - if (gfp_mask & __GFP_ACCOUNT && area->nr_pages) 3881 - mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, 3882 - area->nr_pages); 3883 3881 3884 3882 /* 3885 3883 * If not enough pages were obtained to accomplish an