Re: [PATCH v3 4/5] mm: kmem: scoped objcg protection

From: Vlastimil Babka
Date: Wed Oct 18 2023 - 10:05:08 EST


On 10/17/23 00:18, Roman Gushchin wrote:
> Switch to a scope-based protection of the objcg pointer on slab/kmem
> allocation paths. Instead of using the get_() semantics in the
> pre-allocation hook and put the reference afterwards, let's rely
> on the fact that objcg is pinned by the scope.
>
> It's possible because:
> 1) if the objcg is received from the current task struct, the task is
> keeping a reference to the objcg.
> 2) if the objcg is received from an active memcg (remote charging),
> the memcg is pinned by the scope and has a reference to the
> corresponding objcg.
>
> Signed-off-by: Roman Gushchin (Cruise) <roman.gushchin@xxxxxxxxx>
> Tested-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
> Acked-by: Shakeel Butt <shakeelb@xxxxxxxxxx>

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>