diff options
-rw-r--r-- | include/linux/memcontrol.h | 5 | ||||
-rw-r--r-- | mm/memcontrol.c | 21 | ||||
-rw-r--r-- | mm/slab.h | 4 |
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); | |||
403 | struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep); | 403 | struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep); |
404 | void __memcg_kmem_put_cache(struct kmem_cache *cachep); | 404 | void __memcg_kmem_put_cache(struct kmem_cache *cachep); |
405 | 405 | ||
406 | int __memcg_charge_slab(struct kmem_cache *cachep, gfp_t gfp, int order); | 406 | int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, |
407 | void __memcg_uncharge_slab(struct kmem_cache *cachep, int order); | 407 | unsigned long nr_pages); |
408 | void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned long nr_pages); | ||
408 | 409 | ||
409 | int __memcg_cleanup_cache_params(struct kmem_cache *s); | 410 | int __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 | ||
2498 | static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, | 2498 | int 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 | ||
2536 | static void memcg_uncharge_kmem(struct mem_cgroup *memcg, | 2536 | void 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 | ||
2770 | int __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 | |||
2777 | void __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. |
@@ -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 | ||
241 | static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order) | 241 | static __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 |
250 | static inline bool is_root_cache(struct kmem_cache *s) | 250 | static inline bool is_root_cache(struct kmem_cache *s) |