summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2015-02-12 14:59:17 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-12 18:54:09 -0800
commit49e7e7ff8d551b5b1e2f8da8497b9058cfa25672 (patch)
treeaa671bba976ba7bc0837785a49d5d83c5fc99c98 /fs
parent2acb60a0461fec8a4516686c913a295ce872697f (diff)
fs: shrinker: always scan at least one object of each type
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: Vladimir 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/super.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/super.c b/fs/super.c
index 482b4071f4de..a89d6250bab8 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -91,14 +91,17 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
/*
* prune the dcache first as the icache is pinned by it, then
* prune the icache, followed by the filesystem specific caches
+ *
+ * Ensure that we always scan at least one object - memcg kmem
+ * accounting uses this to fully empty the caches.
*/
- sc->nr_to_scan = dentries;
+ sc->nr_to_scan = dentries + 1;
freed = prune_dcache_sb(sb, sc);
- sc->nr_to_scan = inodes;
+ sc->nr_to_scan = inodes + 1;
freed += prune_icache_sb(sb, sc);
if (fs_objects) {
- sc->nr_to_scan = fs_objects;
+ sc->nr_to_scan = fs_objects + 1;
freed += sb->s_op->free_cached_objects(sb, sc);
}