Re: [PATCH v4 2/4] mm: memcontrol: make obj_cgroup_memcg() handle NULL objcg

From: Shakeel Butt

Date: Mon Aug 17 2026 - 12:17:47 EST


On Mon, Aug 17, 2026 at 05:03:26PM +0800, Qi Zheng wrote:
> From: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
>
> obj_cgroup_memcg() currently requires a non-NULL objcg, so callers that
> may hold a NULL objcg must guard the call with an explicit NULL check.
> This pattern is duplicated in folio_memcg(), folio_memcg_check(),
> mm/page_owner.c, and mm/zswap.c.
>
> Teach obj_cgroup_memcg() to accept NULL and return NULL in that case, then
> remove the redundant NULL checks at the call sites. Also remove the
> mem_cgroup_from_entry() wrapper in zswap, which existed solely to provide
> this NULL-safe behaviour, and replace its two callers with direct
> obj_cgroup_memcg() calls.
>
> No functional change intended.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>

Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>