Skip to content

Commit

Permalink
memcg: zap __memcg_{charge,uncharge}_slab
Browse files Browse the repository at this point in the history
They are simple wrappers around memcg_{charge,uncharge}_kmem, so let's
zap them and call these functions directly.

Signed-off-by: Vladimir Davydov <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Vladimir Davydov authored and torvalds committed Feb 10, 2015
1 parent 4c5018c commit dbf22eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
5 changes: 3 additions & 2 deletions include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ void memcg_update_array_size(int num_groups);
struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep);
void __memcg_kmem_put_cache(struct kmem_cache *cachep);

int __memcg_charge_slab(struct kmem_cache *cachep, gfp_t gfp, int order);
void __memcg_uncharge_slab(struct kmem_cache *cachep, int order);
int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
unsigned long nr_pages);
void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned long nr_pages);

int __memcg_cleanup_cache_params(struct kmem_cache *s);

Expand Down
21 changes: 3 additions & 18 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,8 +2495,8 @@ static struct kmem_cache *memcg_params_to_cache(struct memcg_cache_params *p)
return cache_from_memcg_idx(cachep, memcg_cache_id(p->memcg));
}

static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
unsigned long nr_pages)
int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
unsigned long nr_pages)
{
struct page_counter *counter;
int ret = 0;
Expand Down Expand Up @@ -2533,8 +2533,7 @@ static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
return ret;
}

static void memcg_uncharge_kmem(struct mem_cgroup *memcg,
unsigned long nr_pages)
void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned long nr_pages)
{
page_counter_uncharge(&memcg->memory, nr_pages);
if (do_swap_account)
Expand Down Expand Up @@ -2767,20 +2766,6 @@ static void memcg_schedule_register_cache(struct mem_cgroup *memcg,
current->memcg_kmem_skip_account = 0;
}

int __memcg_charge_slab(struct kmem_cache *cachep, gfp_t gfp, int order)
{
unsigned int nr_pages = 1 << order;

return memcg_charge_kmem(cachep->memcg_params->memcg, gfp, nr_pages);
}

void __memcg_uncharge_slab(struct kmem_cache *cachep, int order)
{
unsigned int nr_pages = 1 << order;

memcg_uncharge_kmem(cachep->memcg_params->memcg, nr_pages);
}

/*
* Return the kmem_cache we're supposed to use for a slab allocation.
* We try to use the current memcg's version of the cache.
Expand Down
4 changes: 2 additions & 2 deletions mm/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static __always_inline int memcg_charge_slab(struct kmem_cache *s,
return 0;
if (is_root_cache(s))
return 0;
return __memcg_charge_slab(s, gfp, order);
return memcg_charge_kmem(s->memcg_params->memcg, gfp, 1 << order);
}

static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order)
Expand All @@ -244,7 +244,7 @@ static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order)
return;
if (is_root_cache(s))
return;
__memcg_uncharge_slab(s, order);
memcg_uncharge_kmem(s->memcg_params->memcg, 1 << order);
}
#else
static inline bool is_root_cache(struct kmem_cache *s)
Expand Down

0 comments on commit dbf22eb

Please sign in to comment.