aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/memcontrol.h
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-12-18 17:23:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 18:02:15 -0500
commitebe945c27628fca03723582eba138acc2e2f3d15 (patch)
tree5998e8dd874aedf3b8873d0ffeaf658d10505655 /include/linux/memcontrol.h
parent92e793495597af4135d94314113bf13eafb0e663 (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 'include/linux/memcontrol.h')
-rw-r--r--include/linux/memcontrol.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index ea02ff970836..0108a56f814e 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -422,6 +422,12 @@ static inline void sock_release_memcg(struct sock *sk)
422extern struct static_key memcg_kmem_enabled_key; 422extern struct static_key memcg_kmem_enabled_key;
423 423
424extern int memcg_limited_groups_array_size; 424extern int memcg_limited_groups_array_size;
425
426/*
427 * Helper macro to loop through all memcg-specific caches. Callers must still
428 * check if the cache is valid (it is either valid or NULL).
429 * the slab_mutex must be held when looping through those caches
430 */
425#define for_each_memcg_cache_index(_idx) \ 431#define for_each_memcg_cache_index(_idx) \
426 for ((_idx) = 0; i < memcg_limited_groups_array_size; (_idx)++) 432 for ((_idx) = 0; i < memcg_limited_groups_array_size; (_idx)++)
427 433