aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-04-04 17:29:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-04 17:46:26 -0400
commit4077960e2a38ec59096ff993cd080056e17f3707 (patch)
treeffc0bdd5e74b2247add9fb30f455ee57cf648a41
parent8bab8dded67d026c39367bbd5e27d2f6c556c38e (diff)
memory controller: make memory resource control aware of boot options
A boot option for the memory controller was discussed on lkml. It is a good idea to add it, since it saves memory for people who want to turn off the memory controller. By default the option is on for the following two reasons: 1. It provides compatibility with the current scheme where the memory controller turns on if the config option is enabled 2. It allows for wider testing of the memory controller, once the config option is enabled We still allow the create, destroy callbacks to succeed, since they are not aware of boot options. We do not populate the directory will memory resource controller specific files. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hugh@veritas.com> Cc: Sudhir Kumar <skumar@linux.vnet.ibm.com> Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memcontrol.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 9b648bd63451..23b5fa4cabd8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -533,6 +533,9 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
533 unsigned long nr_retries = MEM_CGROUP_RECLAIM_RETRIES; 533 unsigned long nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
534 struct mem_cgroup_per_zone *mz; 534 struct mem_cgroup_per_zone *mz;
535 535
536 if (mem_cgroup_subsys.disabled)
537 return 0;
538
536 /* 539 /*
537 * Should page_cgroup's go to their own slab? 540 * Should page_cgroup's go to their own slab?
538 * One could optimize the performance of the charging routine 541 * One could optimize the performance of the charging routine
@@ -665,6 +668,9 @@ void mem_cgroup_uncharge_page(struct page *page)
665 struct mem_cgroup_per_zone *mz; 668 struct mem_cgroup_per_zone *mz;
666 unsigned long flags; 669 unsigned long flags;
667 670
671 if (mem_cgroup_subsys.disabled)
672 return;
673
668 /* 674 /*
669 * Check if our page_cgroup is valid 675 * Check if our page_cgroup is valid
670 */ 676 */
@@ -705,6 +711,9 @@ int mem_cgroup_prepare_migration(struct page *page)
705{ 711{
706 struct page_cgroup *pc; 712 struct page_cgroup *pc;
707 713
714 if (mem_cgroup_subsys.disabled)
715 return 0;
716
708 lock_page_cgroup(page); 717 lock_page_cgroup(page);
709 pc = page_get_page_cgroup(page); 718 pc = page_get_page_cgroup(page);
710 if (pc) 719 if (pc)
@@ -803,6 +812,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *mem)
803 int ret = -EBUSY; 812 int ret = -EBUSY;
804 int node, zid; 813 int node, zid;
805 814
815 if (mem_cgroup_subsys.disabled)
816 return 0;
817
806 css_get(&mem->css); 818 css_get(&mem->css);
807 /* 819 /*
808 * page reclaim code (kswapd etc..) will move pages between 820 * page reclaim code (kswapd etc..) will move pages between
@@ -1053,6 +1065,8 @@ static void mem_cgroup_destroy(struct cgroup_subsys *ss,
1053static int mem_cgroup_populate(struct cgroup_subsys *ss, 1065static int mem_cgroup_populate(struct cgroup_subsys *ss,
1054 struct cgroup *cont) 1066 struct cgroup *cont)
1055{ 1067{
1068 if (mem_cgroup_subsys.disabled)
1069 return 0;
1056 return cgroup_add_files(cont, ss, mem_cgroup_files, 1070 return cgroup_add_files(cont, ss, mem_cgroup_files,
1057 ARRAY_SIZE(mem_cgroup_files)); 1071 ARRAY_SIZE(mem_cgroup_files));
1058} 1072}
@@ -1065,6 +1079,9 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
1065 struct mm_struct *mm; 1079 struct mm_struct *mm;
1066 struct mem_cgroup *mem, *old_mem; 1080 struct mem_cgroup *mem, *old_mem;
1067 1081
1082 if (mem_cgroup_subsys.disabled)
1083 return;
1084
1068 mm = get_task_mm(p); 1085 mm = get_task_mm(p);
1069 if (mm == NULL) 1086 if (mm == NULL)
1070 return; 1087 return;