Skip to content
  • Rik van Riel's avatar
    mm: workingset: only do workingset activations on reads · f0281a00
    Rik van Riel authored
    This is a follow-up to
    
      http://www.spinics.net/lists/linux-mm/msg101739.html
    
    
    
    where Andres reported his database workingset being pushed out by the
    minimum size enforcement of the inactive file list - currently 50% of
    cache - as well as repeatedly written file pages that are never actually
    read.
    
    Two changes fell out of the discussions.  The first change observes that
    pages that are only ever written don't benefit from caching beyond what
    the writeback cache does for partial page writes, and so we shouldn't
    promote them to the active file list where they compete with pages whose
    cached data is actually accessed repeatedly.  This change comes in two
    patches - one for in-cache write accesses and one for refaults triggered
    by writes, neither of which should promote a cache page.
    
    Second, with the refault detection we don't need to set 50% of the cache
    aside for used-once cache anymore since we can detect frequently used
    pages even when they are evicted between accesses.  We can allow the
    active list to be bigger and thus protect a bigger workingset that isn't
    challenged by streamers.  Depending on the access patterns, this can
    increase major faults during workingset transitions for better
    performance during stable phases.
    
    This patch (of 3):
    
    When rewriting a page, the data in that page is replaced with new data.
    This means that evicting something else from the active file list, in
    order to cache data that will be replaced by something else, is likely
    to be a waste of memory.
    
    It is better to save the active list for frequently read pages, because
    reads actually use the data that is in the page.
    
    This patch ignores partial writes, because it is unclear whether the
    complexity of identifying those is worth any potential performance gain
    obtained from better caching pages that see repeated partial writes at
    large enough intervals to not get caught by the use-twice promotion code
    used for the inactive file list.
    
    Signed-off-by: default avatarRik van Riel <riel@redhat.com>
    Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
    Reported-by: default avatarAndres Freund <andres@anarazel.de>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f0281a00