Re: [PATCH 3/3] mm/hugetlb: fix NR_HUGETLB accounting for unused surplus folios

From: Oscar Salvador (SUSE)

Date: Thu Oct 29 2026 - 09:23:03 EST


On Thu, Oct 29, 2026 at 11:21:47AM +0800, Muchun Song wrote:
> My thinking is that we should not use lruvec_stat_mod_folio(). Instead, we
> should use mod_node_page_state() and mod_memcg_lruvec_state()
> independently. In that case, when a new hugetlb page is allocated, we could
> account for it directly via mod_node_page_state(). The reason is tha
> lruvec_stat_mod_folio() also accounts per-memcg NR_HUGETLB; only by
> splitting the two can we minimize the problems introduced by accounting. For
> callers that need to consider memcg, mod_memcg_lruvec_state() can be used.

Ok, this sounds pretty compeling, and IMHO makes sense.

I mean I get the ideabehind this patch but it feels like papering over
the real problem.



> I expect that after some cleanup, there will be only one place that needs to
> handle per-node NR_HUGETLB.
>
> Thoughts?
>
> Thanks,
> Muchun
>
>
> > I will have another look later on.
> >
> >
> >
> > --
> > Oscar Salvador
> > SUSE Labs
>

--
Oscar Salvador
SUSE Labs