memcontrol: use simple_malloc()/simple_free()
Subsystems (2)
PATCH 3/7 memcontrol: use simple_malloc()/simple_free()
use simple_malloc()/simple_free() instead of current codes.
---
mm/memcontrol.c +2 -9
@@ -1062,11 +1062,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) {struct mem_cgroup *mem; -if (sizeof (*mem) <PAGE_SIZE ) - mem =kmalloc (sizeof (*mem),GFP_KERNEL ); -else - mem =vmalloc (sizeof (*mem)); - + mem =simple_malloc (sizeof (*mem));if (mem)memset (mem,0 ,sizeof (*mem));return mem;
@@ -1074,10 +1070,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)static void mem_cgroup_free (struct mem_cgroup *mem) { -if (sizeof (*mem) <PAGE_SIZE ) -kfree (mem); -else -vfree (mem); +simple_free (mem); }
Quoted 1 line · Lai Jiangshan
use simple_malloc()/simple_free() instead of current codes.
struct mem_cgroup can't reach the size when kmalloc starts failing.
Quoted 25 lines
mm/memcontrol.c +2
-9@@ -1062,11 +1062,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) {struct mem_cgroup *mem; -if (sizeof (*mem) <PAGE_SIZE ) - mem =kmalloc (sizeof (*mem),GFP_KERNEL ); -else - mem =vmalloc (sizeof (*mem)); - + mem =simple_malloc (sizeof (*mem));if (mem)memset (mem,0 ,sizeof (*mem));return mem;@@ -1074,10 +1070,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)static void mem_cgroup_free (struct mem_cgroup *mem) { -if (sizeof (*mem) <PAGE_SIZE ) -kfree (mem); -else -vfree (mem); +simple_free (mem); }
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · Lai Jiangshan
use simple_malloc()/simple_free() instead of current codes.
struct
mem_cgroupcan't reach the size when kmalloc starts failing.
Or it probably can with big NR_CPUS.
struct mem_cgroup_stat {
struct mem_cgroup_stat_cpu cpustat[NR_CPUS];
};Quoted 25 lines
Quoted 25 lines
mm/memcontrol.c +2
-9@@ -1062,11 +1062,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) {struct mem_cgroup *mem; -if (sizeof (*mem) <PAGE_SIZE ) - mem =kmalloc (sizeof (*mem),GFP_KERNEL ); -else - mem =vmalloc (sizeof (*mem)); - + mem =simple_malloc (sizeof (*mem));if (mem)memset (mem,0 ,sizeof (*mem));return mem;@@ -1074,10 +1070,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)static void mem_cgroup_free (struct mem_cgroup *mem) { -if (sizeof (*mem) <PAGE_SIZE ) -kfree (mem); -else -vfree (mem); +simple_free (mem); }
Quoted 11 lines · On Sun, 16 Nov 2008 07:54:04 +0300 Alexey Dobriyan <[email protected]> wrote:
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · Lai Jiangshan
use simple_malloc()/simple_free() instead of current codes.
struct
mem_cgroupcan't reach the size when kmalloc starts failing.Or it probably can with big
NR_CPUS.struct mem_cgroup_stat { struct mem_cgroup_stat_cpu cpustat[NR_CPUS]; };
It's now changed. see mmotm.
Thanks,
-Kame
Quoted 27 lines
Quoted 26 lines
Quoted 26 lines
mm/memcontrol.c +2
-9@@ -1062,11 +1062,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) {struct mem_cgroup *mem; -if (sizeof (*mem) <PAGE_SIZE ) - mem =kmalloc (sizeof (*mem),GFP_KERNEL ); -else - mem =vmalloc (sizeof (*mem)); - + mem =simple_malloc (sizeof (*mem));if (mem)memset (mem,0 ,sizeof (*mem));return mem;@@ -1074,10 +1070,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)static void mem_cgroup_free (struct mem_cgroup *mem) { -if (sizeof (*mem) <PAGE_SIZE ) -kfree (mem); -else -vfree (mem); +simple_free (mem); }
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · Lai Jiangshan
use simple_malloc()/simple_free() instead of current codes.
struct
mem_cgroupcan't reach the size when kmalloc starts failing.
Good catch! Thanx!
compiler will optimize it and select the correct way. using "simple_malloc()/simple_free()" here is no sense.
Quoted 29 lines
Quoted 26 lines
mm/memcontrol.c +2
-9@@ -1062,11 +1062,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) {struct mem_cgroup *mem; -if (sizeof (*mem) <PAGE_SIZE ) - mem =kmalloc (sizeof (*mem),GFP_KERNEL ); -else - mem =vmalloc (sizeof (*mem)); - + mem =simple_malloc (sizeof (*mem));if (mem)memset (mem,0 ,sizeof (*mem));return mem;@@ -1074,10 +1070,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)static void mem_cgroup_free (struct mem_cgroup *mem) { -if (sizeof (*mem) <PAGE_SIZE ) -kfree (mem); -else -vfree (mem); +simple_free (mem); }
From: Alexey Dobriyan <[email protected]>
Date: Sun, 16 Nov 2008 07:51:28 +0300
Quoted 4 lines · Lai Jiangshan
Quoted 1 line
use simple_malloc()/simple_free() instead of current codes.
struct
mem_cgroupcan't reach the size when kmalloc starts failing.
That's not the point.
When you got past a page, kmalloc/gfp allocations are less reliable, and people also want NUMA spreading when possible.
That's why we use PAGE_SIZE as the table vmalloc() breakpoint. We do this in many places already, with the exact same heuristics, and for the exact same reasons.