Re: [PATCH v1 7/9] workingset: memcg: sleep when flushing stats in workingset_refault()

From: Johannes Weiner
Date: Tue Mar 28 2023 - 14:47:54 EST


On Tue, Mar 28, 2023 at 08:18:11AM -0700, Shakeel Butt wrote:
> > @@ -406,6 +406,8 @@ void workingset_refault(struct folio *folio, void *shadow)
> > unpack_shadow(shadow, &memcgid, &pgdat, &eviction, &workingset);
> > eviction <<= bucket_order;
> >
> > + /* Flush stats (and potentially sleep) before holding RCU read lock */
>
> I think the only reason we use rcu lock is due to
> mem_cgroup_from_id(). Maybe we should add mem_cgroup_tryget_from_id().
> The other caller of mem_cgroup_from_id() in vmscan is already doing
> the same and could use mem_cgroup_tryget_from_id().

Good catch. Nothing else in there is protected by RCU. We can just
hold the ref instead.

> Though this can be done separately to this series (if we decide to do
> it at all).

Agreed