aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/memcontrol.h
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2014-06-04 19:06:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:53:56 -0400
commit5dfb417509921eb90ee123a4d1525e8916b4ace4 (patch)
tree3ca55eb4452bf4d5f2a5ebbf835488ac4343fd30 /include/linux/memcontrol.h
parent8eae1492675d0ffc12189f8db573624413232e15 (diff)
sl[au]b: charge slabs to kmemcg explicitly
We have only a few places where we actually want to charge kmem so instead of intruding into the general page allocation path with __GFP_KMEMCG it's better to explictly charge kmem there. All kmem charges will be easier to follow that way. This is a step towards removing __GFP_KMEMCG. It removes __GFP_KMEMCG from memcg caches' allocflags. Instead it makes slab allocation path call memcg_charge_kmem directly getting memcg to charge from the cache's memcg params. This also eliminates any possibility of misaccounting an allocation going from one memcg's cache to another memcg, because now we always charge slabs against the memcg the cache belongs to. That's why this patch removes the big comment to memcg_kmem_get_cache. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Acked-by: Greg Thelen <gthelen@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Glauber Costa <glommer@gmail.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Pekka Enberg <penberg@kernel.org> 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.h15
1 files changed, 4 insertions, 11 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index b569b8be5c5a..96e5d2573eb0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -506,6 +506,9 @@ void memcg_update_array_size(int num_groups);
506struct kmem_cache * 506struct kmem_cache *
507__memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp); 507__memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp);
508 508
509int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, u64 size);
510void memcg_uncharge_kmem(struct mem_cgroup *memcg, u64 size);
511
509void mem_cgroup_destroy_cache(struct kmem_cache *cachep); 512void mem_cgroup_destroy_cache(struct kmem_cache *cachep);
510int __kmem_cache_destroy_memcg_children(struct kmem_cache *s); 513int __kmem_cache_destroy_memcg_children(struct kmem_cache *s);
511 514
@@ -583,17 +586,7 @@ memcg_kmem_commit_charge(struct page *page, struct mem_cgroup *memcg, int order)
583 * @cachep: the original global kmem cache 586 * @cachep: the original global kmem cache
584 * @gfp: allocation flags. 587 * @gfp: allocation flags.
585 * 588 *
586 * This function assumes that the task allocating, which determines the memcg 589 * All memory allocated from a per-memcg cache is charged to the owner memcg.
587 * in the page allocator, belongs to the same cgroup throughout the whole
588 * process. Misacounting can happen if the task calls memcg_kmem_get_cache()
589 * while belonging to a cgroup, and later on changes. This is considered
590 * acceptable, and should only happen upon task migration.
591 *
592 * Before the cache is created by the memcg core, there is also a possible
593 * imbalance: the task belongs to a memcg, but the cache being allocated from
594 * is the global cache, since the child cache is not yet guaranteed to be
595 * ready. This case is also fine, since in this case the GFP_KMEMCG will not be
596 * passed and the page allocator will not attempt any cgroup accounting.
597 */ 590 */
598static __always_inline struct kmem_cache * 591static __always_inline struct kmem_cache *
599memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp) 592memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)