Re: [PATCH] memcg: sink mem_cgroup_uncharge_folios() into free_unref_folios()
From: Johannes Weiner
Date: Thu Aug 27 2026 - 10:52:40 EST
On Thu, Aug 27, 2026 at 11:05:16AM +0800, Ridong Chen wrote:
> From: Ridong Chen <chenridong@xxxxxxxxxx>
>
> Every caller of free_unref_folios() invokes mem_cgroup_uncharge_folios()
> on the same batch immediately beforehand. This pattern is duplicated
> across shrink_folio_list(), move_folios_to_lru(), folio_batch_move_lru()
> and folios_put_refs().
>
> Move the uncharge into free_unref_folios() itself so the batch is
> uncharged in one place before the folios are freed. This removes the
> repeated boilerplate at every call site and makes it impossible to free
> a batch without uncharging it first. No functional change intended.
Hm, IMO this is confusing. You're making uncharging an included
service in a subset of the page allocator freeing API. Batch freeing
uncharges, but single page freeing does not.
I don't think saving 7 lines is worth that API caveat.