Skip to content
  • Andrey Ryabinin's avatar
    mm/vmscan: don't change pgdat state on base of a single LRU list state · d108c772
    Andrey Ryabinin authored
    We have separate LRU list for each memory cgroup.  Memory reclaim
    iterates over cgroups and calls shrink_inactive_list() every inactive
    LRU list.  Based on the state of a single LRU shrink_inactive_list() may
    flag the whole node as dirty,congested or under writeback.  This is
    obviously wrong and hurtful.  It's especially hurtful when we have
    possibly small congested cgroup in system.  Than *all* direct reclaims
    waste time by sleeping in wait_iff_congested().  And the more memcgs in
    the system we have the longer memory allocation stall is, because
    wait_iff_congested() called on each lru-list scan.
    
    Sum reclaim stats across all visited LRUs on node and flag node as
    dirty, congested or under writeback based on that sum.  Also call
    congestion_wait(), wait_iff_congested() once per pgdat scan, instead of
    once per lru-list scan.
    
    This only fixes the problem for global reclaim case.  Per-cgroup reclaim
    may alter global pgdat flags too, which is wrong.  But that is separate
    issue and will be addressed in the next patch.
    
    This change will not have any effect on a systems with all workload
    concentrated in a single cgroup.
    
    [aryabinin@virtuozzo.com: check nr_writeback against all nr_taken, not just file]
      Link: http://lkml.kernel.org/r/20180406180254.8970-1-aryabinin@virtuozzo.com
    Link: http://lkml.kernel.org/r/20180323152029.11084-4-aryabinin@virtuozzo.com
    
    
    Signed-off-by: default avatarAndrey Ryabinin <aryabinin@virtuozzo.com>
    Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    d108c772