Re: [PATCH] mm: khugepaged: fix NR_FILE_PAGES accounting in collapse_file()
From: Shakeel Butt
Date: Thu Jan 29 2026 - 19:51:31 EST
On Thu, Jan 29, 2026 at 07:32:14PM -0500, Johannes Weiner wrote:
> On Thu, Jan 29, 2026 at 10:40:54AM -0800, Shakeel Butt wrote:
> > @@ -2200,8 +2200,8 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr,
> > else
> > lruvec_stat_mod_folio(new_folio, NR_FILE_THPS, HPAGE_PMD_NR);
> >
> > + lruvec_stat_mod_folio(new_folio, NR_FILE_PAGES, HPAGE_PMD_NR);
>
> The memcg breakage is more visible, but I think this has been broken
> for NUMA stats even longer. new_folio could also come from a different
> node than the subpages, after all.
Indeed you are right, so I should blame Kiryl instead of Song :P
>
> > if (nr_none) {
> > - lruvec_stat_mod_folio(new_folio, NR_FILE_PAGES, nr_none);
> > /* nr_none is always 0 for non-shmem. */
> > lruvec_stat_mod_folio(new_folio, NR_SHMEM, nr_none);
>
> So AFAICT NR_SHMEM needs the same treatment.
>
> It looks like that's been broken since f3f0e1d2150b ("khugepaged: add
> support of collapse for tmpfs/shmem pages").
Thanks, I will send v2 with correct handling of NR_SHMEM as well.