Re: [PATCH] mm: khugepaged: fix NR_FILE_PAGES accounting in collapse_file()
From: Johannes Weiner
Date: Thu Jan 29 2026 - 19:32:34 EST
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.
> 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").
Anon pages avoided this, because their accounting is done in rmap.c
when the pmd is mapped and the ptes zapped.