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/mmzone.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/mmzone.h')
-rw-r--r-- | include/linux/mmzone.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index da2d053a95f1..35a7b5e19465 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -601,8 +601,11 @@ typedef struct pglist_data { | |||
601 | struct zone node_zones[MAX_NR_ZONES]; | 601 | struct zone node_zones[MAX_NR_ZONES]; |
602 | struct zonelist node_zonelists[MAX_ZONELISTS]; | 602 | struct zonelist node_zonelists[MAX_ZONELISTS]; |
603 | int nr_zones; | 603 | int nr_zones; |
604 | #ifdef CONFIG_FLAT_NODE_MEM_MAP | 604 | #ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */ |
605 | struct page *node_mem_map; | 605 | struct page *node_mem_map; |
606 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR | ||
607 | struct page_cgroup *node_page_cgroup; | ||
608 | #endif | ||
606 | #endif | 609 | #endif |
607 | struct bootmem_data *bdata; | 610 | struct bootmem_data *bdata; |
608 | #ifdef CONFIG_MEMORY_HOTPLUG | 611 | #ifdef CONFIG_MEMORY_HOTPLUG |
@@ -931,6 +934,7 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn) | |||
931 | #endif | 934 | #endif |
932 | 935 | ||
933 | struct page; | 936 | struct page; |
937 | struct page_cgroup; | ||
934 | struct mem_section { | 938 | struct mem_section { |
935 | /* | 939 | /* |
936 | * This is, logically, a pointer to an array of struct | 940 | * This is, logically, a pointer to an array of struct |
@@ -948,6 +952,14 @@ struct mem_section { | |||
948 | 952 | ||
949 | /* See declaration of similar field in struct zone */ | 953 | /* See declaration of similar field in struct zone */ |
950 | unsigned long *pageblock_flags; | 954 | unsigned long *pageblock_flags; |
955 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR | ||
956 | /* | ||
957 | * If !SPARSEMEM, pgdat doesn't have page_cgroup pointer. We use | ||
958 | * section. (see memcontrol.h/page_cgroup.h about this.) | ||
959 | */ | ||
960 | struct page_cgroup *page_cgroup; | ||
961 | unsigned long pad; | ||
962 | #endif | ||
951 | }; | 963 | }; |
952 | 964 | ||
953 | #ifdef CONFIG_SPARSEMEM_EXTREME | 965 | #ifdef CONFIG_SPARSEMEM_EXTREME |