Re: [PATCH v2 3/3] mm: Fix missing mem cgroup soft limit tree updates

From: Michal Hocko
Date: Mon Feb 22 2021 - 03:43:56 EST


On Fri 19-02-21 11:28:47, Tim Chen wrote:
>
>
> On 2/19/21 1:16 AM, Michal Hocko wrote:
>
> >>
> >> Something like this?
> >>
> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> >> index 8bddee75f5cb..b50cae3b2a1a 100644
> >> --- a/mm/memcontrol.c
> >> +++ b/mm/memcontrol.c
> >> @@ -3472,6 +3472,14 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
> >> if (!mz)
> >> break;
> >>
> >> + /*
> >> + * Soft limit tree is updated based on memcg events sampling.
> >> + * We could have missed some updates on page uncharge and
> >> + * the cgroup is below soft limit. Skip useless soft reclaim.
> >> + */
> >> + if (!soft_limit_excess(mz->memcg))
> >> + continue;
> >> +
> >> nr_scanned = 0;
> >> reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat,
> >
> > Yes I meant something like this but then I have looked more closely and
> > this shouldn't be needed afterall. __mem_cgroup_largest_soft_limit_node
> > already does all the work
> > if (!soft_limit_excess(mz->memcg) ||
> > !css_tryget(&mz->memcg->css))
> > goto retry;
> > so this shouldn't really happen.
> >
>
> Ah, that's true. The added check for soft_limit_excess is not needed.
>
> Do you think it is still a good idea to add patch 3 to
> restrict the uncharge update in page batch of the same node and cgroup?

I would rather drop it. The less the soft limit reclaim code is spread
around the better.
--
Michal Hocko
SUSE Labs