On Mon, Aug 12, 2019 at 09:07:27PM +0000, Roman Gushchin wrote: > On Mon, Aug 12, 2019 at 03:23:16PM -0400, Johannes Weiner wrote: > > @@ -2679,7 +2675,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > > nr_reclaimed = sc->nr_reclaimed; > > nr_scanned = sc->nr_scanned; > > > > - memcg = mem_cgroup_iter(root, NULL, &reclaim); > > + memcg = mem_cgroup_iter(root, NULL, NULL); > > I wonder if we can remove the shared memcg tree walking at all? It seems that > the only use case left is the soft limit, and the same logic can be applied > to it. The we potentially can remove a lot of code in mem_cgroup_iter(). > Just an idea... It's so tempting! But soft limit reclaim starts at priority 0 right out of the gate, so overreclaim is an actual concern there. We could try to rework it, but it'll be hard to avoid regressions given how awkward the semantics and behavior around the soft limit already are. > > do { > > unsigned long lru_pages; > > unsigned long reclaimed; > > @@ -2724,21 +2720,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > > sc->nr_scanned - scanned, > > sc->nr_reclaimed - reclaimed); > > > > - /* > > - * Kswapd have to scan all memory cgroups to fulfill > > - * the overall scan target for the node. > > - * > > - * Limit reclaim, on the other hand, only cares about > > - * nr_to_reclaim pages to be reclaimed and it will > > - * retry with decreasing priority if one round over the > > - * whole hierarchy is not sufficient. > > - */ > > - if (!current_is_kswapd() && > > - sc->nr_reclaimed >= sc->nr_to_reclaim) { > > - mem_cgroup_iter_break(root, memcg); > > - break; > > - } > > - } while ((memcg = mem_cgroup_iter(root, memcg, &reclaim))); > > + } while ((memcg = mem_cgroup_iter(root, memcg, NULL))); > > > > if (reclaim_state) { > > sc->nr_reclaimed += reclaim_state->reclaimed_slab; > > -- > > 2.22.0 > > > > Otherwise looks good to me! > > Reviewed-by: Roman Gushchin <guro@xxxxxx> Thanks!