aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-12-18 17:23:03 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 18:02:14 -0500
commit943a451a87d229ca564a27274b58eaeae35fde5d (patch)
tree607a0bc1aba3911602dec1448be2ace190b5c1eb /mm/memcontrol.c
parent749c54151a6e5b229e4ae067dbc651e54b161fbc (diff)
slab: propagate tunable values
SLAB allows us to tune a particular cache behavior with tunables. When creating a new memcg cache copy, we'd like to preserve any tunables the parent cache already had. This could be done by an explicit call to do_tune_cpucache() after the cache is created. But this is not very convenient now that the caches are created from common code, since this function is SLAB-specific. Another method of doing that is taking advantage of the fact that do_tune_cpucache() is always called from enable_cpucache(), which is called at cache initialization. We can just preset the values, and then things work as expected. It can also happen that a root cache has its tunables updated during normal system operation. In this case, we will propagate the change to all caches that are already active. This change will require us to move the assignment of root_cache in memcg_params a bit earlier. We need this to be already set - which memcg_kmem_register_cache will do - when we reach __kmem_cache_create() Signed-off-by: Glauber Costa <glommer@parallels.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Rientjes <rientjes@google.com> Cc: Frederic Weisbecker <fweisbec@redhat.com> Cc: Greg Thelen <gthelen@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: JoonSoo Kim <js1304@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Michal Hocko <mhocko@suse.cz> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Rik van Riel <riel@redhat.com> Cc: Suleiman Souhlal <suleiman@google.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 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a32d83c2e353..f3009b4bae51 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3012,7 +3012,8 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups)
3012 return 0; 3012 return 0;
3013} 3013}
3014 3014
3015int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s) 3015int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
3016 struct kmem_cache *root_cache)
3016{ 3017{
3017 size_t size = sizeof(struct memcg_cache_params); 3018 size_t size = sizeof(struct memcg_cache_params);
3018 3019
@@ -3026,8 +3027,10 @@ int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s)
3026 if (!s->memcg_params) 3027 if (!s->memcg_params)
3027 return -ENOMEM; 3028 return -ENOMEM;
3028 3029
3029 if (memcg) 3030 if (memcg) {
3030 s->memcg_params->memcg = memcg; 3031 s->memcg_params->memcg = memcg;
3032 s->memcg_params->root_cache = root_cache;
3033 }
3031 return 0; 3034 return 0;
3032} 3035}
3033 3036
@@ -3186,7 +3189,7 @@ static struct kmem_cache *kmem_cache_dup(struct mem_cgroup *memcg,
3186 return NULL; 3189 return NULL;
3187 3190
3188 new = kmem_cache_create_memcg(memcg, name, s->object_size, s->align, 3191 new = kmem_cache_create_memcg(memcg, name, s->object_size, s->align,
3189 (s->flags & ~SLAB_PANIC), s->ctor); 3192 (s->flags & ~SLAB_PANIC), s->ctor, s);
3190 3193
3191 if (new) 3194 if (new)
3192 new->allocflags |= __GFP_KMEMCG; 3195 new->allocflags |= __GFP_KMEMCG;
@@ -3226,7 +3229,6 @@ static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
3226 } 3229 }
3227 3230
3228 mem_cgroup_get(memcg); 3231 mem_cgroup_get(memcg);
3229 new_cachep->memcg_params->root_cache = cachep;
3230 atomic_set(&new_cachep->memcg_params->nr_pages , 0); 3232 atomic_set(&new_cachep->memcg_params->nr_pages , 0);
3231 3233
3232 cachep->memcg_params->memcg_caches[idx] = new_cachep; 3234 cachep->memcg_params->memcg_caches[idx] = new_cachep;