Skip to content
  • Johannes Weiner's avatar
    mm: vmscan: detect file thrashing at the reclaim root · b910718a
    Johannes Weiner authored
    We use refault information to determine whether the cache workingset is
    stable or transitioning, and dynamically adjust the inactive:active file
    LRU ratio so as to maximize protection from one-off cache during stable
    periods, and minimize IO during transitions.
    
    With cgroups and their nested LRU lists, we currently don't do this
    correctly.  While recursive cgroup reclaim establishes a relative LRU
    order among the pages of all involved cgroups, refaults only affect the
    local LRU order in the cgroup in which they are occuring.  As a result,
    cache transitions can take longer in a cgrouped system as the active pages
    of sibling cgroups aren't challenged when they should be.
    
    [ Right now, this is somewhat theoretical, because the siblings, under
      continued regular reclaim pressure, should eventually run out of
      inactive pages - and since inactive:active *size* balancing is also
      done on a cgroup-local level, we will challenge the active pages
      eventually in most cases. But the next patch will move that relative
      size enforcement to the reclaim root as well, and then this patch
      here will be necessary to propagate refault pressure to siblings. ]
    
    This patch moves refault detection to the root of reclaim.  Instead of
    remembering the cgroup owner of an evicted page, remember the cgroup that
    caused the reclaim to happen.  When refaults later occur, they'll
    correctly influence the cross-cgroup LRU order that reclaim follows.
    
    I.e.  if global reclaim kicked out pages in some subgroup A/B/C, the
    refault of those pages will challenge the global LRU order, and not just
    the local order down inside C.
    
    [hannes@cmpxchg.org:  use page_memcg() instead of another lookup]
      Link: http://lkml.kernel.org/r/20191115160722.GA309754@cmpxchg.org
    Link: http://lkml.kernel.org/r/20191107205334.158354-3-hannes@cmpxchg.org
    
    
    Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
    Reviewed-by: default avatarSuren Baghdasaryan <surenb@google.com>
    Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Rik van Riel <riel@surriel.com>
    Cc: Shakeel Butt <shakeelb@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    b910718a