Re: [PATCH 5/8] mm: vmscan: replace shrink_node() loop with a retry jump

From: Johannes Weiner
Date: Tue Oct 22 2019 - 17:43:08 EST


On Tue, Oct 22, 2019 at 07:56:33PM +0000, Roman Gushchin wrote:
> On Tue, Oct 22, 2019 at 10:48:00AM -0400, Johannes Weiner wrote:
> > - /* Record the group's reclaim efficiency */
> > - vmpressure(sc->gfp_mask, memcg, false,
> > - sc->nr_scanned - scanned,
> > - sc->nr_reclaimed - reclaimed);
> > -
> > - } while ((memcg = mem_cgroup_iter(root, memcg, NULL)));
> > + reclaimed = sc->nr_reclaimed;
> > + scanned = sc->nr_scanned;
> > + shrink_node_memcg(pgdat, memcg, sc);
> >
> > - if (reclaim_state) {
> > - sc->nr_reclaimed += reclaim_state->reclaimed_slab;
> > - reclaim_state->reclaimed_slab = 0;
> > - }
> > + shrink_slab(sc->gfp_mask, pgdat->node_id, memcg,
> > + sc->priority);
> >
> > - /* Record the subtree's reclaim efficiency */
> > - vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
> > - sc->nr_scanned - nr_scanned,
> > - sc->nr_reclaimed - nr_reclaimed);
> > + /* Record the group's reclaim efficiency */
> > + vmpressure(sc->gfp_mask, memcg, false,
> > + sc->nr_scanned - scanned,
> > + sc->nr_reclaimed - reclaimed);
>
> It doesn't look as a trivial change. I'd add some comments to the commit message
> why it's safe to do.

It's an equivalent change - it's just really misleading because the
+++ lines are not the counter-part of the --- lines here!

There are two vmpressure calls in this function: one against the
individual cgroups, and one against the tree. The diff puts them
adjacent here, but the counter-part for the --- lines is here:

> > + /* Record the subtree's reclaim efficiency */
> > + vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
> > + sc->nr_scanned - nr_scanned,
> > + sc->nr_reclaimed - nr_reclaimed);

And the counter-part to the +++ lines is further up (beginning of the
quoted diff).