Re: [PATCHv3] mm: remove '!root_reclaim' checking in should_abort_scan()
From: Barry Song
Date: Mon Apr 06 2026 - 23:46:02 EST
On Fri, Apr 3, 2026 at 3:05 PM Zhaoyang Huang <huangzhaoyang@xxxxxxxxx> wrote:
>
> On Fri, Apr 3, 2026 at 6:59 AM Barry Song <baohua@xxxxxxxxxx> wrote:
> >
> > On Wed, Mar 18, 2026 at 9:18 AM zhaoyang.huang
> > <zhaoyang.huang@xxxxxxxxxx> wrote:
> > >
> > > From: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>
> > >
> > > Android systems usually use memory.reclaim interface to implement user
> > > space memory management which expects that the requested reclaim target
> > > and actually reclaimed amount memory are not diverging by too much. With
> > > the current MGRLU implementation there is, however, no bail out when the
> > > reclaim target is reached and this could lead to an excessive reclaim
> > > that scales with the reclaim hierarchy size.For example, we can get a
> > > nr_reclaimed=394/nr_to_reclaim=32 proactive reclaim under a common 1-N
> > > cgroup hierarchy.
> > > This defect arised from the goal of keeping fairness among memcgs that
> > > is, for try_to_free_mem_cgroup_pages -> shrink_node_memcgs ->
> > > shrink_lruvec -> lru_gen_shrink_lruvec -> try_to_shrink_lruvec, the
> > > !root_reclaim(sc) check was there for reclaim fairness, which was
> > > necessary before commit 'b82b530740b9' ("mm: vmscan: restore
> > > incremental cgroup iteration") because the fairness depended on
> > > attempted proportional reclaim from every memcg under the target
> > > memcg. However after commit 'b82b530740b9' there is no longer a need
> > > to visit every memcg to ensure fairness. Let's have try_to_shrink_lruvec
> > > bail out when the nr_reclaimed achieved.
> >
> > I think we need some clarification here. Does the code
> >
> > nr_to_scan = apply_proportional_protection(memcg, sc, nr_to_scan);
> >
> > still serve a purpose, or has it become less useful after your patch?
> proportional protection is still useful for calculating the nr_to_scan
> when 'memory.min/low' is configured in the hierarchy.
>
Right, thanks! Also, the patch looks sensible to me,
Reviewed-by: Barry Song <baohua@xxxxxxxxxx>