diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2008-10-18 23:28:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 11:52:39 -0400 |
commit | 52d4b9ac0b985168009c2a57098324e67bae171f (patch) | |
tree | b3e3b854166930af893be90ea30a7ab0d65c59e7 /include/linux/memcontrol.h | |
parent | c05555b572921c464d064d9267f7f7bc06d424fa (diff) |
memcg: allocate all page_cgroup at boot
Allocate all page_cgroup at boot and remove page_cgroup poitner from
struct page. This patch adds an interface as
struct page_cgroup *lookup_page_cgroup(struct page*)
All FLATMEM/DISCONTIGMEM/SPARSEMEM and MEMORY_HOTPLUG is supported.
Remove page_cgroup pointer reduces the amount of memory by
- 4 bytes per PAGE_SIZE.
- 8 bytes per PAGE_SIZE
if memory controller is disabled. (even if configured.)
On usual 8GB x86-32 server, this saves 8MB of NORMAL_ZONE memory.
On my x86-64 server with 48GB of memory, this saves 96MB of memory.
I think this reduction makes sense.
By pre-allocation, kmalloc/kfree in charge/uncharge are removed.
This means
- we're not necessary to be afraid of kmalloc faiulre.
(this can happen because of gfp_mask type.)
- we can avoid calling kmalloc/kfree.
- we can avoid allocating tons of small objects which can be fragmented.
- we can know what amount of memory will be used for this extra-lru handling.
I added printk message as
"allocated %ld bytes of page_cgroup"
"please try cgroup_disable=memory option if you don't want"
maybe enough informative for users.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/memcontrol.h')
-rw-r--r-- | include/linux/memcontrol.h | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ee1b2fcb4410..1fbe14d39521 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -27,9 +27,6 @@ struct mm_struct; | |||
27 | 27 | ||
28 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR | 28 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR |
29 | 29 | ||
30 | #define page_reset_bad_cgroup(page) ((page)->page_cgroup = 0) | ||
31 | |||
32 | extern struct page_cgroup *page_get_page_cgroup(struct page *page); | ||
33 | extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm, | 30 | extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm, |
34 | gfp_t gfp_mask); | 31 | gfp_t gfp_mask); |
35 | extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, | 32 | extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, |
@@ -72,16 +69,8 @@ extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, | |||
72 | extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone, | 69 | extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone, |
73 | int priority, enum lru_list lru); | 70 | int priority, enum lru_list lru); |
74 | 71 | ||
75 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ | ||
76 | static inline void page_reset_bad_cgroup(struct page *page) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | static inline struct page_cgroup *page_get_page_cgroup(struct page *page) | ||
81 | { | ||
82 | return NULL; | ||
83 | } | ||
84 | 72 | ||
73 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ | ||
85 | static inline int mem_cgroup_charge(struct page *page, | 74 | static inline int mem_cgroup_charge(struct page *page, |
86 | struct mm_struct *mm, gfp_t gfp_mask) | 75 | struct mm_struct *mm, gfp_t gfp_mask) |
87 | { | 76 | { |