Re: [PATCH] mm: kmem: make mem_cgroup_from_obj() vmalloc()-safe

From: Muchun Song
Date: Sun Jun 12 2022 - 10:45:17 EST


On Sat, Jun 11, 2022 at 2:04 AM Roman Gushchin <roman.gushchin@xxxxxxxxx> wrote:
>
> Currently mem_cgroup_from_obj() is not working properly with objects
> allocated using vmalloc(). It creates problems in some cases, when
> it's called for static objects belonging to modules or generally
> allocated using vmalloc().
>
> This patch makes mem_cgroup_from_obj() safe to be called on objects
> allocated using vmalloc().
>
> It also introduces mem_cgroup_from_slab_obj(), which is a faster
> version to use in places when we know the object is either a slab
> object or a generic slab page (e.g. when adding an object to a lru
> list).
>
> Suggested-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
> Signed-off-by: Roman Gushchin <roman.gushchin@xxxxxxxxx>
> Tested-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>
> Acked-by: Shakeel Butt <shakeelb@xxxxxxxxxx>

Acked-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>

Thanks.