diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2015-02-12 17:58:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 21:54:09 -0500 |
commit | dbcf73e26cd0b3d66e6db65ab595e664a55e58ff (patch) | |
tree | b4b57e45b717d18b5f6ae2663797a6c73cf7175d | |
parent | cb731d6c62bbc2f890b08ea3d0386d5dad887326 (diff) |
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: Vladimir 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/memcontrol.h | 4 | ||||
-rw-r--r-- | mm/memcontrol.c | 19 | ||||
-rw-r--r-- | mm/slab_common.c | 4 |
3 files changed, 13 insertions, 14 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 54992fe0959f..2607c91230af 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -398,7 +398,7 @@ static inline void sock_release_memcg(struct sock *sk) | |||
398 | #ifdef CONFIG_MEMCG_KMEM | 398 | #ifdef CONFIG_MEMCG_KMEM |
399 | extern struct static_key memcg_kmem_enabled_key; | 399 | extern struct static_key memcg_kmem_enabled_key; |
400 | 400 | ||
401 | extern int memcg_limited_groups_array_size; | 401 | extern int memcg_nr_cache_ids; |
402 | 402 | ||
403 | /* | 403 | /* |
404 | * Helper macro to loop through all memcg-specific caches. Callers must still | 404 | * Helper macro to loop through all memcg-specific caches. Callers must still |
@@ -406,7 +406,7 @@ extern int memcg_limited_groups_array_size; | |||
406 | * the slab_mutex must be held when looping through those caches | 406 | * the slab_mutex must be held when looping through those caches |
407 | */ | 407 | */ |
408 | #define for_each_memcg_cache_index(_idx) \ | 408 | #define for_each_memcg_cache_index(_idx) \ |
409 | for ((_idx) = 0; (_idx) < memcg_limited_groups_array_size; (_idx)++) | 409 | for ((_idx) = 0; (_idx) < memcg_nr_cache_ids; (_idx)++) |
410 | 410 | ||
411 | static inline bool memcg_kmem_enabled(void) | 411 | static inline bool memcg_kmem_enabled(void) |
412 | { | 412 | { |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3c2a1a8286ac..8608fa543b84 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -538,12 +538,11 @@ static void disarm_sock_keys(struct mem_cgroup *memcg) | |||
538 | * memcgs, and none but the 200th is kmem-limited, we'd have to have a | 538 | * memcgs, and none but the 200th is kmem-limited, we'd have to have a |
539 | * 200 entry array for that. | 539 | * 200 entry array for that. |
540 | * | 540 | * |
541 | * The current size of the caches array is stored in | 541 | * The current size of the caches array is stored in memcg_nr_cache_ids. It |
542 | * memcg_limited_groups_array_size. It will double each time we have to | 542 | * will double each time we have to increase it. |
543 | * increase it. | ||
544 | */ | 543 | */ |
545 | static DEFINE_IDA(kmem_limited_groups); | 544 | static DEFINE_IDA(memcg_cache_ida); |
546 | int memcg_limited_groups_array_size; | 545 | int memcg_nr_cache_ids; |
547 | 546 | ||
548 | /* | 547 | /* |
549 | * MIN_SIZE is different than 1, because we would like to avoid going through | 548 | * 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 | int id, size; | 2537 | int id, size; |
2539 | int err; | 2538 | int err; |
2540 | 2539 | ||
2541 | id = ida_simple_get(&kmem_limited_groups, | 2540 | id = ida_simple_get(&memcg_cache_ida, |
2542 | 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL); | 2541 | 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL); |
2543 | if (id < 0) | 2542 | if (id < 0) |
2544 | return id; | 2543 | return id; |
2545 | 2544 | ||
2546 | if (id < memcg_limited_groups_array_size) | 2545 | if (id < memcg_nr_cache_ids) |
2547 | return id; | 2546 | return id; |
2548 | 2547 | ||
2549 | /* | 2548 | /* |
@@ -2559,7 +2558,7 @@ static int memcg_alloc_cache_id(void) | |||
2559 | 2558 | ||
2560 | err = memcg_update_all_caches(size); | 2559 | err = memcg_update_all_caches(size); |
2561 | if (err) { | 2560 | if (err) { |
2562 | ida_simple_remove(&kmem_limited_groups, id); | 2561 | ida_simple_remove(&memcg_cache_ida, id); |
2563 | return err; | 2562 | return err; |
2564 | } | 2563 | } |
2565 | return id; | 2564 | return id; |
@@ -2567,7 +2566,7 @@ static int memcg_alloc_cache_id(void) | |||
2567 | 2566 | ||
2568 | static void memcg_free_cache_id(int id) | 2567 | static void memcg_free_cache_id(int id) |
2569 | { | 2568 | { |
2570 | ida_simple_remove(&kmem_limited_groups, id); | 2569 | ida_simple_remove(&memcg_cache_ida, id); |
2571 | } | 2570 | } |
2572 | 2571 | ||
2573 | /* | 2572 | /* |
@@ -2577,7 +2576,7 @@ static void memcg_free_cache_id(int id) | |||
2577 | */ | 2576 | */ |
2578 | void memcg_update_array_size(int num) | 2577 | void memcg_update_array_size(int num) |
2579 | { | 2578 | { |
2580 | memcg_limited_groups_array_size = num; | 2579 | memcg_nr_cache_ids = num; |
2581 | } | 2580 | } |
2582 | 2581 | ||
2583 | struct memcg_kmem_cache_create_work { | 2582 | struct memcg_kmem_cache_create_work { |
diff --git a/mm/slab_common.c b/mm/slab_common.c index 6e1e4cf65836..f8899eedab68 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -116,7 +116,7 @@ static int memcg_alloc_cache_params(struct mem_cgroup *memcg, | |||
116 | 116 | ||
117 | if (!memcg) { | 117 | if (!memcg) { |
118 | size = offsetof(struct memcg_cache_params, memcg_caches); | 118 | size = offsetof(struct memcg_cache_params, memcg_caches); |
119 | size += memcg_limited_groups_array_size * sizeof(void *); | 119 | size += memcg_nr_cache_ids * sizeof(void *); |
120 | } else | 120 | } else |
121 | size = sizeof(struct memcg_cache_params); | 121 | size = sizeof(struct memcg_cache_params); |
122 | 122 | ||
@@ -154,7 +154,7 @@ static int memcg_update_cache_params(struct kmem_cache *s, int num_memcgs) | |||
154 | 154 | ||
155 | cur_params = s->memcg_params; | 155 | cur_params = s->memcg_params; |
156 | memcpy(new_params->memcg_caches, cur_params->memcg_caches, | 156 | memcpy(new_params->memcg_caches, cur_params->memcg_caches, |
157 | memcg_limited_groups_array_size * sizeof(void *)); | 157 | memcg_nr_cache_ids * sizeof(void *)); |
158 | 158 | ||
159 | new_params->is_root_cache = true; | 159 | new_params->is_root_cache = true; |
160 | 160 | ||