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: add vmstat for kernel_file pages

Kernel file pages are tricky to track because they are indistinguishable
from files whose usage is accounted to the root cgroup.

To maintain good accounting, introduce a vmstat counter tracking kernel
file pages.

Confirmed that these work as expected at a high level by mounting a btrfs
using AS_KERNEL_FILE for metadata pages, and seeing the counter rise with
fs usage then go back to a minimal level after drop_caches and finally
down to 0 after unmounting the fs.

Link: https://lkml.kernel.org/r/08ff633e3a005ed5f7691bfd9f58a5df8e474339.1755812945.git.boris@bur.io
Signed-off-by: Boris Burkov <boris@bur.io>
Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Tested-by: syzbot@syzkaller.appspotmail.com
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Qu Wenruo <wqu@suse.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Boris Burkov and committed by
Andrew Morton
e3a9ac4e cf1dec76

+9
+1
include/linux/mmzone.h
··· 259 259 NR_HUGETLB, 260 260 #endif 261 261 NR_BALLOON_PAGES, 262 + NR_KERNEL_FILE_PAGES, 262 263 NR_VM_NODE_STAT_ITEMS 263 264 }; 264 265
+7
mm/filemap.c
··· 190 190 __lruvec_stat_mod_folio(folio, NR_FILE_THPS, -nr); 191 191 filemap_nr_thps_dec(mapping); 192 192 } 193 + if (test_bit(AS_KERNEL_FILE, &folio->mapping->flags)) 194 + mod_node_page_state(folio_pgdat(folio), 195 + NR_KERNEL_FILE_PAGES, -nr); 193 196 194 197 /* 195 198 * At this point folio must be either written or cleaned by ··· 992 989 if (!(gfp & __GFP_WRITE) && shadow) 993 990 workingset_refault(folio, shadow); 994 991 folio_add_lru(folio); 992 + if (kernel_file) 993 + mod_node_page_state(folio_pgdat(folio), 994 + NR_KERNEL_FILE_PAGES, 995 + folio_nr_pages(folio)); 995 996 } 996 997 return ret; 997 998 }
+1
mm/vmstat.c
··· 1290 1290 [I(NR_HUGETLB)] = "nr_hugetlb", 1291 1291 #endif 1292 1292 [I(NR_BALLOON_PAGES)] = "nr_balloon_pages", 1293 + [I(NR_KERNEL_FILE_PAGES)] = "nr_kernel_file_pages", 1293 1294 #undef I 1294 1295 1295 1296 /* system-wide enum vm_stat_item counters */