Re: [PATCH] mm: khugepaged: fix NR_FILE_PAGES accounting in collapse_file()
From: Shakeel Butt
Date: Thu Jan 29 2026 - 19:48:36 EST
On Thu, Jan 29, 2026 at 10:47:16PM +0000, Matthew Wilcox wrote:
> On Thu, Jan 29, 2026 at 10:40:54AM -0800, Shakeel Butt wrote:
> > Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
>
> Are you sure this is the right Fixes? 99cb0dbd47a1 wasn't cgroup
> aware:
>
> if (nr_none) {
> struct zone *zone = page_zone(new_page);
>
> __mod_node_page_state(zone->zone_pgdat, NR_FILE_PAGES, nr_none);
> - __mod_node_page_state(zone->zone_pgdat, NR_SHMEM, nr_none);
> + if (is_shmem)
> + __mod_node_page_state(zone->zone_pgdat,
> + NR_SHMEM, nr_none);
> }
>
> b8eddff8886b added cgroup support:
>
> if (is_shmem)
> - __inc_node_page_state(new_page, NR_SHMEM_THPS);
> + __inc_lruvec_page_state(new_page, NR_SHMEM_THPS);
> else {
> - __inc_node_page_state(new_page, NR_FILE_THPS);
> + __inc_lruvec_page_state(new_page, NR_FILE_THPS);
> filemap_nr_thps_inc(mapping);
> }
>
> which would seem like the right Fixes: to me?
>
b8eddff8886b is about different stats NR_SHMEM_THPS & NR_FILE_THPS.
However as Johannes responded this code was broken even before memcg
awareness for NR_FILE_PAGES and NR_SHMEM.
I will send v2 with correct handling of NR_SHMEM as well.