aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.h
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-12-18 17:22:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 18:02:14 -0500
commit1f458cbf122288b23620ee822e19bcbb76c8d6ec (patch)
treefa434b9ff6d6bdfd2daaf24fd7812cc975cba7b7 /mm/slab.h
parentd79923fad95b0cdf7770e024677180c734cb7148 (diff)
memcg: destroy memcg caches
Implement destruction of memcg caches. Right now, only caches where our reference counter is the last remaining are deleted. If there are any other reference counters around, we just leave the caches lying around until they go away. When that happens, a destruction function is called from the cache code. Caches are only destroyed in process context, so we queue them up for later processing in the general case. 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/slab.h')
-rw-r--r--mm/slab.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/slab.h b/mm/slab.h
index c95e922b166d..43d8a38b534f 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -117,6 +117,21 @@ static inline bool cache_match_memcg(struct kmem_cache *cachep,
117 (cachep->memcg_params->memcg == memcg); 117 (cachep->memcg_params->memcg == memcg);
118} 118}
119 119
120static inline void memcg_bind_pages(struct kmem_cache *s, int order)
121{
122 if (!is_root_cache(s))
123 atomic_add(1 << order, &s->memcg_params->nr_pages);
124}
125
126static inline void memcg_release_pages(struct kmem_cache *s, int order)
127{
128 if (is_root_cache(s))
129 return;
130
131 if (atomic_sub_and_test((1 << order), &s->memcg_params->nr_pages))
132 mem_cgroup_destroy_cache(s);
133}
134
120static inline bool slab_equal_or_root(struct kmem_cache *s, 135static inline bool slab_equal_or_root(struct kmem_cache *s,
121 struct kmem_cache *p) 136 struct kmem_cache *p)
122{ 137{
@@ -135,6 +150,14 @@ static inline bool cache_match_memcg(struct kmem_cache *cachep,
135 return true; 150 return true;
136} 151}
137 152
153static inline void memcg_bind_pages(struct kmem_cache *s, int order)
154{
155}
156
157static inline void memcg_release_pages(struct kmem_cache *s, int order)
158{
159}
160
138static inline bool slab_equal_or_root(struct kmem_cache *s, 161static inline bool slab_equal_or_root(struct kmem_cache *s,
139 struct kmem_cache *p) 162 struct kmem_cache *p)
140{ 163{