aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/*