Re: [External] Re: [PATCH v2] writeback: fix obtain a reference to a freeing memcg css

2021-04-01 Thread Michal Hocko
On Thu 01-04-21 21:59:13, Muchun Song wrote: > On Thu, Apr 1, 2021 at 6:26 PM Michal Hocko wrote: [...] > > Even if the css ref count is not really necessary it shouldn't cause any > > harm and it makes the code easier to understand. At least a comment > > explaining why that is not necessary

Re: [External] Re: [PATCH v2] writeback: fix obtain a reference to a freeing memcg css

2021-04-01 Thread Muchun Song
On Thu, Apr 1, 2021 at 10:37 PM Michal Hocko wrote: > > On Thu 01-04-21 21:59:13, Muchun Song wrote: > > On Thu, Apr 1, 2021 at 6:26 PM Michal Hocko wrote: > [...] > > > Even if the css ref count is not really necessary it shouldn't cause any > > > harm and it makes the code easier to

Re: [External] Re: [PATCH v2] writeback: fix obtain a reference to a freeing memcg css

2021-04-01 Thread Muchun Song
On Thu, Apr 1, 2021 at 6:26 PM Michal Hocko wrote: > > On Thu 01-04-21 17:33:43, Muchun Song wrote: > > The caller of wb_get_create() should pin the memcg, because > > wb_get_create() relies on this guarantee. The rcu read lock > > only can guarantee that the memcg css returned by css_from_id() >

Re: [PATCH v2] writeback: fix obtain a reference to a freeing memcg css

2021-04-01 Thread Michal Hocko
On Thu 01-04-21 17:33:43, Muchun Song wrote: > The caller of wb_get_create() should pin the memcg, because > wb_get_create() relies on this guarantee. The rcu read lock > only can guarantee that the memcg css returned by css_from_id() > cannot be released, but the reference of the memcg can be

[PATCH v2] writeback: fix obtain a reference to a freeing memcg css

2021-04-01 Thread Muchun Song
The caller of wb_get_create() should pin the memcg, because wb_get_create() relies on this guarantee. The rcu read lock only can guarantee that the memcg css returned by css_from_id() cannot be released, but the reference of the memcg can be zero. Fix it by holding a reference to the css before