Re: [PATCH 01/21] mm/hugetlb: charge the copy made at fork to the parent
From: Muchun Song
Date: Wed Nov 25 2026 - 20:49:29 EST
> On Nov 26, 2026, at 06:32, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> When copying page tables during fork(), the child is not yet assigned to
> the right memcg. When copying possibly pinned anon hugetlb folios, we
> must charge them to the parent's memcg, otherwise we can end up
> allocating more hugetlb folios than allowed.
>
> Let's fix it by charging the copy to the parent's mm, like we do when
> copying small folios in copy_present_page(), introducing a new helper
> function alloc_hugetlb_folio_for_fork().
>
> This is a hotfix for v7.4.
>
> Fixes: c2deb1356d82 ("mm/hugetlb: charge folios to the target mm's memcg")
> Reported-by: Chris Mason <mason@xxxxxxxxxx>
> Acked-by: Michal Hocko <mhocko@xxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>
Thanks.