summaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2015-02-12 17:58:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-12 21:54:08 -0500
commit503c358cf1925853195ee39ec437e51138bbb7df (patch)
tree14aebe291975ec4353f21068990ebfec503ed63f /fs/dcache.c
parent10c1045f28e86ac90589a188f0be2d7a4347efdf (diff)
list_lru: introduce list_lru_shrink_{count,walk}
Kmem accounting of memcg is unusable now, because it lacks slab shrinker support. That means when we hit the limit we will get ENOMEM w/o any chance to recover. What we should do then is to call shrink_slab, which would reclaim old inode/dentry caches from this cgroup. This is what this patch set is intended to do. Basically, it does two things. First, it introduces the notion of per-memcg slab shrinker. A shrinker that wants to reclaim objects per cgroup should mark itself as SHRINKER_MEMCG_AWARE. Then it will be passed the memory cgroup to scan from in shrink_control->memcg. For such shrinkers shrink_slab iterates over the whole cgroup subtree under the target cgroup and calls the shrinker for each kmem-active memory cgroup. Secondly, this patch set makes the list_lru structure per-memcg. It's done transparently to list_lru users - everything they have to do is to tell list_lru_init that they want memcg-aware list_lru. Then the list_lru will automatically distribute objects among per-memcg lists basing on which cgroup the object is accounted to. This way to make FS shrinkers (icache, dcache) memcg-aware we only need to make them use memcg-aware list_lru, and this is what this patch set does. As before, this patch set only enables per-memcg kmem reclaim when the pressure goes from memory.limit, not from memory.kmem.limit. Handling memory.kmem.limit is going to be tricky due to GFP_NOFS allocations, and it is still unclear whether we will have this knob in the unified hierarchy. This patch (of 9): NUMA aware slab shrinkers use the list_lru structure to distribute objects coming from different NUMA nodes to different lists. Whenever such a shrinker needs to count or scan objects from a particular node, it issues commands like this: count = list_lru_count_node(lru, sc->nid); freed = list_lru_walk_node(lru, sc->nid, isolate_func, isolate_arg, &sc->nr_to_scan); where sc is an instance of the shrink_control structure passed to it from vmscan. To simplify this, let's add special list_lru functions to be used by shrinkers, list_lru_shrink_count() and list_lru_shrink_walk(), which consolidate the nid and nr_to_scan arguments in the shrink_control structure. This will also allow us to avoid patching shrinkers that use list_lru when we make shrink_slab() per-memcg - all we will have to do is extend the shrink_control structure to include the target memcg and make list_lru_shrink_{count,walk} handle this appropriately. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Suggested-by: Dave Chinner <david@fromorbit.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Greg Thelen <gthelen@google.com> Cc: Glauber Costa <glommer@gmail.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index e368d4f412f9..56c5da89f58a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -930,24 +930,22 @@ dentry_lru_isolate(struct list_head *item, spinlock_t *lru_lock, void *arg)
930/** 930/**
931 * prune_dcache_sb - shrink the dcache 931 * prune_dcache_sb - shrink the dcache
932 * @sb: superblock 932 * @sb: superblock
933 * @nr_to_scan : number of entries to try to free 933 * @sc: shrink control, passed to list_lru_shrink_walk()
934 * @nid: which node to scan for freeable entities
935 * 934 *
936 * Attempt to shrink the superblock dcache LRU by @nr_to_scan entries. This is 935 * Attempt to shrink the superblock dcache LRU by @sc->nr_to_scan entries. This
937 * done when we need more memory an called from the superblock shrinker 936 * is done when we need more memory and called from the superblock shrinker
938 * function. 937 * function.
939 * 938 *
940 * This function may fail to free any resources if all the dentries are in 939 * This function may fail to free any resources if all the dentries are in
941 * use. 940 * use.
942 */ 941 */
943long prune_dcache_sb(struct super_block *sb, unsigned long nr_to_scan, 942long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc)
944 int nid)
945{ 943{
946 LIST_HEAD(dispose); 944 LIST_HEAD(dispose);
947 long freed; 945 long freed;
948 946
949 freed = list_lru_walk_node(&sb->s_dentry_lru, nid, dentry_lru_isolate, 947 freed = list_lru_shrink_walk(&sb->s_dentry_lru, sc,
950 &dispose, &nr_to_scan); 948 dentry_lru_isolate, &dispose);
951 shrink_dentry_list(&dispose); 949 shrink_dentry_list(&dispose);
952 return freed; 950 return freed;
953} 951}