Re: [PATCH v2 33/35] mm/hugetlb_cgroup: track in-use folios per cgroup

From: Jose A. Perez de Azpillaga

Date: Fri Dec 04 2026 - 06:59:38 EST


On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote:
> From: Chris Mason <mason@xxxxxxxxxx>
>
> When offlining a hugetlb cgroup, hugetlb_cgroup_css_offline() walks the
> list of all in-use hugetlb folios of each hstate with hugetlb_lock held
> and interrupts disabled, to reparent the folios charged to the dying
> cgroup. With many in-use hugetlb folios, that can keep interrupts
> disabled for a long time on every hugetlb cgroup removal, even for
> cgroups that never charged any hugetlb folios.
>
> Let's fix it by keeping in-use folios that are charged to a hugetlb
> cgroup on per-cgroup lists, so offlining only has to walk the folios of
> the dying cgroup.
>
> Process in batches to not keep interrupts disabled for too long when a
> single cgroup has many folios. Use batches of 32, like reclaim does with
> SWAP_CLUSTER_MAX.
>
> This has low urgency, as it only matters with a lot of hugetlb folios;
> let's not CC stable.
>
> Fixes: da1def55919f ("hugetlb/cgroup: add support for cgroup removal")
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: add lock checks, add HUGETLB_CGROUP_OFFLINE_BATCH, simplify
> comments and description ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

LGTM:

Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>

--
cheers,
jose a. p-a