• Vladimir Davydov's avatar
    fs: shrinker: always scan at least one object of each type · 49e7e7ff
    Vladimir Davydov authored
    In super_cache_scan() we divide the number of objects of particular type
    by the total number of objects in order to distribute pressure among As a
    result, in some corner cases we can get nr_to_scan=0 even if there are
    some objects to reclaim, e.g.  dentries=1, inodes=1, fs_objects=1,
    nr_to_scan=1/3=0.
    
    This is unacceptable for per memcg kmem accounting, because this means
    that some objects may never get reclaimed after memcg death, preventing it
    from being freed.
    
    This patch therefore assures that super_cache_scan() will scan at least
    one object of each type if any.
    
    [akpm@linux-foundation.org: add comment]
    Signed-off-by: default avatarVladimir Davydov <vdavydov@parallels.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@suse.cz>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: Dave Chinner <david@fromorbit.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    49e7e7ff
super.c 35.3 KB