Commit dbcf73e2 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds

memcg: rename some cache id related variables

memcg_limited_groups_array_size, which defines the size of memcg_caches
arrays, sounds rather cumbersome.  Also it doesn't point anyhow that
it's related to kmem/caches stuff.  So let's rename it to
memcg_nr_cache_ids.  It's concise and points us directly to
memcg_cache_id.

Also, rename kmem_limited_groups to memcg_cache_ida.
Signed-off-by: default avatarVladimir Davydov <vdavydov@parallels.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Greg Thelen <gthelen@google.com>
Cc: Glauber Costa <glommer@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cb731d6c
...@@ -398,7 +398,7 @@ static inline void sock_release_memcg(struct sock *sk) ...@@ -398,7 +398,7 @@ static inline void sock_release_memcg(struct sock *sk)
#ifdef CONFIG_MEMCG_KMEM #ifdef CONFIG_MEMCG_KMEM
extern struct static_key memcg_kmem_enabled_key; extern struct static_key memcg_kmem_enabled_key;
extern int memcg_limited_groups_array_size; extern int memcg_nr_cache_ids;
/* /*
* Helper macro to loop through all memcg-specific caches. Callers must still * Helper macro to loop through all memcg-specific caches. Callers must still
...@@ -406,7 +406,7 @@ extern int memcg_limited_groups_array_size; ...@@ -406,7 +406,7 @@ extern int memcg_limited_groups_array_size;
* the slab_mutex must be held when looping through those caches * the slab_mutex must be held when looping through those caches
*/ */
#define for_each_memcg_cache_index(_idx) \ #define for_each_memcg_cache_index(_idx) \
for ((_idx) = 0; (_idx) < memcg_limited_groups_array_size; (_idx)++) for ((_idx) = 0; (_idx) < memcg_nr_cache_ids; (_idx)++)
static inline bool memcg_kmem_enabled(void) static inline bool memcg_kmem_enabled(void)
{ {
......
...@@ -538,12 +538,11 @@ static void disarm_sock_keys(struct mem_cgroup *memcg) ...@@ -538,12 +538,11 @@ static void disarm_sock_keys(struct mem_cgroup *memcg)
* memcgs, and none but the 200th is kmem-limited, we'd have to have a * memcgs, and none but the 200th is kmem-limited, we'd have to have a
* 200 entry array for that. * 200 entry array for that.
* *
* The current size of the caches array is stored in * The current size of the caches array is stored in memcg_nr_cache_ids. It
* memcg_limited_groups_array_size. It will double each time we have to * will double each time we have to increase it.
* increase it.
*/ */
static DEFINE_IDA(kmem_limited_groups); static DEFINE_IDA(memcg_cache_ida);
int memcg_limited_groups_array_size; int memcg_nr_cache_ids;
/* /*
* MIN_SIZE is different than 1, because we would like to avoid going through * MIN_SIZE is different than 1, because we would like to avoid going through
...@@ -2538,12 +2537,12 @@ static int memcg_alloc_cache_id(void) ...@@ -2538,12 +2537,12 @@ static int memcg_alloc_cache_id(void)
int id, size; int id, size;
int err; int err;
id = ida_simple_get(&kmem_limited_groups, id = ida_simple_get(&memcg_cache_ida,
0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL); 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL);
if (id < 0) if (id < 0)
return id; return id;
if (id < memcg_limited_groups_array_size) if (id < memcg_nr_cache_ids)
return id; return id;
/* /*
...@@ -2559,7 +2558,7 @@ static int memcg_alloc_cache_id(void) ...@@ -2559,7 +2558,7 @@ static int memcg_alloc_cache_id(void)
err = memcg_update_all_caches(size); err = memcg_update_all_caches(size);
if (err) { if (err) {
ida_simple_remove(&kmem_limited_groups, id); ida_simple_remove(&memcg_cache_ida, id);
return err; return err;
} }
return id; return id;
...@@ -2567,7 +2566,7 @@ static int memcg_alloc_cache_id(void) ...@@ -2567,7 +2566,7 @@ static int memcg_alloc_cache_id(void)
static void memcg_free_cache_id(int id) static void memcg_free_cache_id(int id)
{ {
ida_simple_remove(&kmem_limited_groups, id); ida_simple_remove(&memcg_cache_ida, id);
} }
/* /*
...@@ -2577,7 +2576,7 @@ static void memcg_free_cache_id(int id) ...@@ -2577,7 +2576,7 @@ static void memcg_free_cache_id(int id)
*/ */
void memcg_update_array_size(int num) void memcg_update_array_size(int num)
{ {
memcg_limited_groups_array_size = num; memcg_nr_cache_ids = num;
} }
struct memcg_kmem_cache_create_work { struct memcg_kmem_cache_create_work {
......
...@@ -116,7 +116,7 @@ static int memcg_alloc_cache_params(struct mem_cgroup *memcg, ...@@ -116,7 +116,7 @@ static int memcg_alloc_cache_params(struct mem_cgroup *memcg,
if (!memcg) { if (!memcg) {
size = offsetof(struct memcg_cache_params, memcg_caches); size = offsetof(struct memcg_cache_params, memcg_caches);
size += memcg_limited_groups_array_size * sizeof(void *); size += memcg_nr_cache_ids * sizeof(void *);
} else } else
size = sizeof(struct memcg_cache_params); size = sizeof(struct memcg_cache_params);
...@@ -154,7 +154,7 @@ static int memcg_update_cache_params(struct kmem_cache *s, int num_memcgs) ...@@ -154,7 +154,7 @@ static int memcg_update_cache_params(struct kmem_cache *s, int num_memcgs)
cur_params = s->memcg_params; cur_params = s->memcg_params;
memcpy(new_params->memcg_caches, cur_params->memcg_caches, memcpy(new_params->memcg_caches, cur_params->memcg_caches,
memcg_limited_groups_array_size * sizeof(void *)); memcg_nr_cache_ids * sizeof(void *));
new_params->is_root_cache = true; new_params->is_root_cache = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment