On Fri, Jan 29, 2021 at 7:13 AM Vlastimil Babka <vbabka@xxxxxxx> wrote: > > On 1/28/21 12:33 AM, Yang Shi wrote: > > Use per memcg's nr_deferred for memcg aware shrinkers. The shrinker's nr_deferred > > will be used in the following cases: > > 1. Non memcg aware shrinkers > > 2. !CONFIG_MEMCG > > 3. memcg is disabled by boot parameter > > > > Signed-off-by: Yang Shi <shy828301@xxxxxxxxx> > > --- > > mm/vmscan.c | 87 ++++++++++++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 73 insertions(+), 14 deletions(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 20be0db291fe..e1f8960f5cf6 100644 > > ... > > > @@ -653,14 +717,9 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, > > next_deferred = 0; > > /* > > * move the unused scan count back into the shrinker in a > > - * manner that handles concurrent updates. If we exhausted the > > - * scan, there is no need to do an update. > > + * manner that handles concurrent updates. > > */ > > - if (next_deferred > 0) > > - new_nr = atomic_long_add_return(next_deferred, > > - &shrinker->nr_deferred[nid]); > > - else > > - new_nr = atomic_long_read(&shrinker->nr_deferred[nid]); > > Why not keep this write avoidance if next_deferred == 0 in the new helper? Because IMHO the write avoidance may not make too much difference since nr_deferred was updated for the most cases per my tracing result. So I thought this would make the code more clean. > > > + new_nr = set_nr_deferred(next_deferred, shrinker, shrinkctl); > > > > trace_mm_shrink_slab_end(shrinker, shrinkctl->nid, freed, nr, new_nr, total_scan); > > return freed; > > >