Re: [PATCH v2 4/4] mm: thp: reparent the split queue during memcg offline
From: Shakeel Butt
Date: Fri Sep 26 2025 - 12:37:19 EST
On Fri, Sep 26, 2025 at 02:57:39PM +0800, Qi Zheng wrote:
>
>
> On 9/26/25 6:35 AM, Shakeel Butt wrote:
[...]
> > >
> > > Yes, css_is_dying() can be used but please note that there is a rcu
> > > grace period between setting CSS_DYING and clearing CSS_ONLINE (i.e.
> > > reparenting deferred split queue) and during that period the deferred
> > > split THPs of the dying memcg will be hidden from shrinkers (which
> > > might be fine).
>
> My mistake, now I think using css_is_dying() is safe.
>
> >
> > BTW if this period is not acceptable and we don't want to add is_dying
> > to struct deferred_split, we can use something similar to what list_lru
> > does in the similar situation i.e. set a special value (LONG_MIN) in its
> > nr_items variable. That is make split_queue_len a long and set it to
> > LONG_MIN during memcg offlining/reparenting.
>
> I've considered this option, but I am concerned about the risk of
> overflow.
If you modify it only within a lock then why would it over or underflow?
>
> So I will try to use css_is_dying() in the next version.
No objection from me but add a comment on the potential window where the
deferred thps will be hidden from the shrinkers.