diff options
author | Glauber Costa <glommer@parallels.com> | 2012-12-18 17:22:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-18 18:02:14 -0500 |
commit | d79923fad95b0cdf7770e024677180c734cb7148 (patch) | |
tree | e7cf6e9fb151d3c0d5c773fa1ba723a71b1e9329 /mm/slub.c | |
parent | b9ce5ef49f00daf2254c6953c8d31f79aabccd34 (diff) |
sl[au]b: allocate objects from memcg cache
We are able to match a cache allocation to a particular memcg. If the
task doesn't change groups during the allocation itself - a rare event,
this will give us a good picture about who is the first group to touch a
cache page.
This patch uses the now available infrastructure by calling
memcg_kmem_get_cache() before all the cache allocations.
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/slub.c')
-rw-r--r-- | mm/slub.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1405,7 +1405,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page) | |||
1405 | reset_page_mapcount(page); | 1405 | reset_page_mapcount(page); |
1406 | if (current->reclaim_state) | 1406 | if (current->reclaim_state) |
1407 | current->reclaim_state->reclaimed_slab += pages; | 1407 | current->reclaim_state->reclaimed_slab += pages; |
1408 | __free_pages(page, order); | 1408 | __free_memcg_kmem_pages(page, order); |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | #define need_reserve_slab_rcu \ | 1411 | #define need_reserve_slab_rcu \ |
@@ -2323,6 +2323,7 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, | |||
2323 | if (slab_pre_alloc_hook(s, gfpflags)) | 2323 | if (slab_pre_alloc_hook(s, gfpflags)) |
2324 | return NULL; | 2324 | return NULL; |
2325 | 2325 | ||
2326 | s = memcg_kmem_get_cache(s, gfpflags); | ||
2326 | redo: | 2327 | redo: |
2327 | 2328 | ||
2328 | /* | 2329 | /* |
@@ -3284,7 +3285,7 @@ static void *kmalloc_large_node(size_t size, gfp_t flags, int node) | |||
3284 | struct page *page; | 3285 | struct page *page; |
3285 | void *ptr = NULL; | 3286 | void *ptr = NULL; |
3286 | 3287 | ||
3287 | flags |= __GFP_COMP | __GFP_NOTRACK; | 3288 | flags |= __GFP_COMP | __GFP_NOTRACK | __GFP_KMEMCG; |
3288 | page = alloc_pages_node(node, flags, get_order(size)); | 3289 | page = alloc_pages_node(node, flags, get_order(size)); |
3289 | if (page) | 3290 | if (page) |
3290 | ptr = page_address(page); | 3291 | ptr = page_address(page); |
@@ -3390,7 +3391,7 @@ void kfree(const void *x) | |||
3390 | if (unlikely(!PageSlab(page))) { | 3391 | if (unlikely(!PageSlab(page))) { |
3391 | BUG_ON(!PageCompound(page)); | 3392 | BUG_ON(!PageCompound(page)); |
3392 | kmemleak_free(x); | 3393 | kmemleak_free(x); |
3393 | __free_pages(page, compound_order(page)); | 3394 | __free_memcg_kmem_pages(page, compound_order(page)); |
3394 | return; | 3395 | return; |
3395 | } | 3396 | } |
3396 | slab_free(page->slab_cache, page, object, _RET_IP_); | 3397 | slab_free(page->slab_cache, page, object, _RET_IP_); |