diff options
author | Glauber Costa <glommer@parallels.com> | 2012-12-18 17:23:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-18 18:02:15 -0500 |
commit | ebe945c27628fca03723582eba138acc2e2f3d15 (patch) | |
tree | 5998e8dd874aedf3b8873d0ffeaf658d10505655 /mm | |
parent | 92e793495597af4135d94314113bf13eafb0e663 (diff) |
memcg: add comments clarifying aspects of cache attribute propagation
This patch clarifies two aspects of cache attribute propagation.
First, the expected context for the for_each_memcg_cache macro in
memcontrol.h. The usages already in the codebase are safe. In mm/slub.c,
it is trivially safe because the lock is acquired right before the loop.
In mm/slab.c, it is less so: the lock is acquired by an outer function a
few steps back in the stack, so a VM_BUG_ON() is added to make sure it is
indeed safe.
A comment is also added to detail why we are returning the value of the
parent cache and ignoring the children's when we propagate the attributes.
Signed-off-by: Glauber Costa <glommer@parallels.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slab.c | 1 | ||||
-rw-r--r-- | mm/slub.c | 21 |
2 files changed, 18 insertions, 4 deletions
@@ -4099,6 +4099,7 @@ static int do_tune_cpucache(struct kmem_cache *cachep, int limit, | |||
4099 | if ((ret < 0) || !is_root_cache(cachep)) | 4099 | if ((ret < 0) || !is_root_cache(cachep)) |
4100 | return ret; | 4100 | return ret; |
4101 | 4101 | ||
4102 | VM_BUG_ON(!mutex_is_locked(&slab_mutex)); | ||
4102 | for_each_memcg_cache_index(i) { | 4103 | for_each_memcg_cache_index(i) { |
4103 | c = cache_from_memcg(cachep, i); | 4104 | c = cache_from_memcg(cachep, i); |
4104 | if (c) | 4105 | if (c) |
@@ -5108,12 +5108,25 @@ static ssize_t slab_attr_store(struct kobject *kobj, | |||
5108 | if (s->max_attr_size < len) | 5108 | if (s->max_attr_size < len) |
5109 | s->max_attr_size = len; | 5109 | s->max_attr_size = len; |
5110 | 5110 | ||
5111 | /* | ||
5112 | * This is a best effort propagation, so this function's return | ||
5113 | * value will be determined by the parent cache only. This is | ||
5114 | * basically because not all attributes will have a well | ||
5115 | * defined semantics for rollbacks - most of the actions will | ||
5116 | * have permanent effects. | ||
5117 | * | ||
5118 | * Returning the error value of any of the children that fail | ||
5119 | * is not 100 % defined, in the sense that users seeing the | ||
5120 | * error code won't be able to know anything about the state of | ||
5121 | * the cache. | ||
5122 | * | ||
5123 | * Only returning the error code for the parent cache at least | ||
5124 | * has well defined semantics. The cache being written to | ||
5125 | * directly either failed or succeeded, in which case we loop | ||
5126 | * through the descendants with best-effort propagation. | ||
5127 | */ | ||
5111 | for_each_memcg_cache_index(i) { | 5128 | for_each_memcg_cache_index(i) { |
5112 | struct kmem_cache *c = cache_from_memcg(s, i); | 5129 | struct kmem_cache *c = cache_from_memcg(s, i); |
5113 | /* | ||
5114 | * This function's return value is determined by the | ||
5115 | * parent cache only | ||
5116 | */ | ||
5117 | if (c) | 5130 | if (c) |
5118 | attribute->store(c, buf, len); | 5131 | attribute->store(c, buf, len); |
5119 | } | 5132 | } |