[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <E1AFB404-3305-47D6-AABE-EBAD83E5DFF4@linux.dev>
Date: Wed, 24 Jul 2024 10:26:24 +0800
From: Muchun Song <muchun.song@...ux.dev>
To: Shakeel Butt <shakeel.butt@...ux.dev>
Cc: Muchun Song <songmuchun@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>,
cgroups@...r.kernel.org,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: kmem: add lockdep assertion to obj_cgroup_memcg
> On Jul 24, 2024, at 02:39, Shakeel Butt <shakeel.butt@...ux.dev> wrote:
>
> On Mon, Jul 22, 2024 at 03:08:10PM GMT, Muchun Song wrote:
>> The obj_cgroup_memcg() is supposed to safe to prevent the returned
>> memory cgroup from being freed only when the caller is holding the
>> rcu read lock or objcg_lock or cgroup_mutex. It is very easy to
>> ignore thoes conditions when users call some upper APIs which call
>> obj_cgroup_memcg() internally like mem_cgroup_from_slab_obj() (See
>> the link below). So it is better to add lockdep assertion to
>> obj_cgroup_memcg() to find those issues ASAP.
>>
>> Because there is no user of obj_cgroup_memcg() holding objcg_lock
>> to make the returned memory cgroup safe, do not add objcg_lock
>> assertion (We should export objcg_lock if we really want to do)
>> and leave a comment to indicate it is intentional.
>>
>
> Do we expect non-memcg code to access objcg_lock? To me this is some
> internal implementation detail of memcg and should not be accessible
> outside memcg code. So, I would recommend to not mention objcg_lock at
> all.
Also make sense. Will update next version.
Powered by blists - more mailing lists