summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/memcontrol.h5
-rw-r--r--mm/memcontrol.c21
-rw-r--r--mm/slab.h4
3 files changed, 8 insertions, 22 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 7c95af8d552c..18ccb2988979 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -403,8 +403,9 @@ void memcg_update_array_size(int num_groups);
403struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep); 403struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep);
404void __memcg_kmem_put_cache(struct kmem_cache *cachep); 404void __memcg_kmem_put_cache(struct kmem_cache *cachep);
405 405
406int __memcg_charge_slab(struct kmem_cache *cachep, gfp_t gfp, int order); 406int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
407void __memcg_uncharge_slab(struct kmem_cache *cachep, int order); 407 unsigned long nr_pages);
408void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned long nr_pages);
408 409
409int __memcg_cleanup_cache_params(struct kmem_cache *s); 410int __memcg_cleanup_cache_params(struct kmem_cache *s);
410 411
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8b58701b9647..e229e3ad615c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2495,8 +2495,8 @@ static struct kmem_cache *memcg_params_to_cache(struct memcg_cache_params *p)
2495 return cache_from_memcg_idx(cachep, memcg_cache_id(p->memcg)); 2495 return cache_from_memcg_idx(cachep, memcg_cache_id(p->memcg));
2496} 2496}
2497 2497
2498static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, 2498int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
2499 unsigned long nr_pages) 2499 unsigned long nr_pages)
2500{ 2500{
2501 struct page_counter *counter; 2501 struct page_counter *counter;
2502 int ret = 0; 2502 int ret = 0;
@@ -2533,8 +2533,7 @@ static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
2533 return ret; 2533 return ret;
2534} 2534}
2535 2535
2536static void memcg_uncharge_kmem(struct mem_cgroup *memcg, 2536void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned long nr_pages)
2537 unsigned long nr_pages)
2538{ 2537{
2539 page_counter_uncharge(&memcg->memory, nr_pages); 2538 page_counter_uncharge(&memcg->memory, nr_pages);
2540 if (do_swap_account) 2539 if (do_swap_account)
@@ -2767,20 +2766,6 @@ static void memcg_schedule_register_cache(struct mem_cgroup *memcg,
2767 current->memcg_kmem_skip_account = 0; 2766 current->memcg_kmem_skip_account = 0;
2768} 2767}
2769 2768
2770int __memcg_charge_slab(struct kmem_cache *cachep, gfp_t gfp, int order)
2771{
2772 unsigned int nr_pages = 1 << order;
2773
2774 return memcg_charge_kmem(cachep->memcg_params->memcg, gfp, nr_pages);
2775}
2776
2777void __memcg_uncharge_slab(struct kmem_cache *cachep, int order)
2778{
2779 unsigned int nr_pages = 1 << order;
2780
2781 memcg_uncharge_kmem(cachep->memcg_params->memcg, nr_pages);
2782}
2783
2784/* 2769/*
2785 * Return the kmem_cache we're supposed to use for a slab allocation. 2770 * Return the kmem_cache we're supposed to use for a slab allocation.
2786 * We try to use the current memcg's version of the cache. 2771 * We try to use the current memcg's version of the cache.
diff --git a/mm/slab.h b/mm/slab.h
index 1cf4005482dd..90430d6f665e 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -235,7 +235,7 @@ static __always_inline int memcg_charge_slab(struct kmem_cache *s,
235 return 0; 235 return 0;
236 if (is_root_cache(s)) 236 if (is_root_cache(s))
237 return 0; 237 return 0;
238 return __memcg_charge_slab(s, gfp, order); 238 return memcg_charge_kmem(s->memcg_params->memcg, gfp, 1 << order);
239} 239}
240 240
241static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order) 241static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order)
@@ -244,7 +244,7 @@ static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order)
244 return; 244 return;
245 if (is_root_cache(s)) 245 if (is_root_cache(s))
246 return; 246 return;
247 __memcg_uncharge_slab(s, order); 247 memcg_uncharge_kmem(s->memcg_params->memcg, 1 << order);
248} 248}
249#else 249#else
250static inline bool is_root_cache(struct kmem_cache *s) 250static inline bool is_root_cache(struct kmem_cache *s)