aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2014-01-23 18:52:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:36:50 -0500
commit8ff69e2c85f84b6b371e3c1d01207e73c0500125 (patch)
tree7a499bd6b46d154be870584ccd99a23c6612587c
parent01cc2e58697e34c6ee9a40fb6cebc18bf5a1923f (diff)
memcg: do not use vmalloc for mem_cgroup allocations
The vmalloc was introduced by 33327948782b ("memcgroup: use vmalloc for mem_cgroup allocation"), because at that time MAX_NUMNODES was used for defining the per-node array in the mem_cgroup structure so that the structure could be huge even if the system had the only NUMA node. The situation was significantly improved by commit 45cf7ebd5a03 ("memcg: reduce the size of struct memcg 244-fold"), which made the size of the mem_cgroup structure calculated dynamically depending on the real number of NUMA nodes installed on the system (nr_node_ids), so now there is no point in using vmalloc here: the structure is allocated rarely and on most systems its size is about 1K. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Glauber Costa <glommer@openvz.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Balbir Singh <bsingharora@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memcontrol.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 67dd2a881433..7890ce9d6bd1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -49,7 +49,6 @@
49#include <linux/sort.h> 49#include <linux/sort.h>
50#include <linux/fs.h> 50#include <linux/fs.h>
51#include <linux/seq_file.h> 51#include <linux/seq_file.h>
52#include <linux/vmalloc.h>
53#include <linux/vmpressure.h> 52#include <linux/vmpressure.h>
54#include <linux/mm_inline.h> 53#include <linux/mm_inline.h>
55#include <linux/page_cgroup.h> 54#include <linux/page_cgroup.h>
@@ -381,12 +380,6 @@ struct mem_cgroup {
381 /* WARNING: nodeinfo must be the last member here */ 380 /* WARNING: nodeinfo must be the last member here */
382}; 381};
383 382
384static size_t memcg_size(void)
385{
386 return sizeof(struct mem_cgroup) +
387 nr_node_ids * sizeof(struct mem_cgroup_per_node *);
388}
389
390/* internal only representation about the status of kmem accounting. */ 383/* internal only representation about the status of kmem accounting. */
391enum { 384enum {
392 KMEM_ACCOUNTED_ACTIVE = 0, /* accounted by this cgroup itself */ 385 KMEM_ACCOUNTED_ACTIVE = 0, /* accounted by this cgroup itself */
@@ -6405,14 +6398,12 @@ static void free_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
6405static struct mem_cgroup *mem_cgroup_alloc(void) 6398static struct mem_cgroup *mem_cgroup_alloc(void)
6406{ 6399{
6407 struct mem_cgroup *memcg; 6400 struct mem_cgroup *memcg;
6408 size_t size = memcg_size(); 6401 size_t size;
6409 6402
6410 /* Can be very big if nr_node_ids is very big */ 6403 size = sizeof(struct mem_cgroup);
6411 if (size < PAGE_SIZE) 6404 size += nr_node_ids * sizeof(struct mem_cgroup_per_node *);
6412 memcg = kzalloc(size, GFP_KERNEL);
6413 else
6414 memcg = vzalloc(size);
6415 6405
6406 memcg = kzalloc(size, GFP_KERNEL);
6416 if (!memcg) 6407 if (!memcg)
6417 return NULL; 6408 return NULL;
6418 6409
@@ -6423,10 +6414,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
6423 return memcg; 6414 return memcg;
6424 6415
6425out_free: 6416out_free:
6426 if (size < PAGE_SIZE) 6417 kfree(memcg);
6427 kfree(memcg);
6428 else
6429 vfree(memcg);
6430 return NULL; 6418 return NULL;
6431} 6419}
6432 6420
@@ -6444,7 +6432,6 @@ out_free:
6444static void __mem_cgroup_free(struct mem_cgroup *memcg) 6432static void __mem_cgroup_free(struct mem_cgroup *memcg)
6445{ 6433{
6446 int node; 6434 int node;
6447 size_t size = memcg_size();
6448 6435
6449 mem_cgroup_remove_from_trees(memcg); 6436 mem_cgroup_remove_from_trees(memcg);
6450 6437
@@ -6465,10 +6452,7 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg)
6465 * the cgroup_lock. 6452 * the cgroup_lock.
6466 */ 6453 */
6467 disarm_static_keys(memcg); 6454 disarm_static_keys(memcg);
6468 if (size < PAGE_SIZE) 6455 kfree(memcg);
6469 kfree(memcg);
6470 else
6471 vfree(memcg);
6472} 6456}
6473 6457
6474/* 6458/*