Commit 4077960e authored by Balbir Singh's avatar Balbir Singh Committed by Linus Torvalds

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: default avatarBalbir 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8bab8dde
...@@ -533,6 +533,9 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, ...@@ -533,6 +533,9 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
unsigned long nr_retries = MEM_CGROUP_RECLAIM_RETRIES; unsigned long nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
struct mem_cgroup_per_zone *mz; struct mem_cgroup_per_zone *mz;
if (mem_cgroup_subsys.disabled)
return 0;
/* /*
* Should page_cgroup's go to their own slab? * Should page_cgroup's go to their own slab?
* One could optimize the performance of the charging routine * One could optimize the performance of the charging routine
...@@ -665,6 +668,9 @@ void mem_cgroup_uncharge_page(struct page *page) ...@@ -665,6 +668,9 @@ void mem_cgroup_uncharge_page(struct page *page)
struct mem_cgroup_per_zone *mz; struct mem_cgroup_per_zone *mz;
unsigned long flags; unsigned long flags;
if (mem_cgroup_subsys.disabled)
return;
/* /*
* Check if our page_cgroup is valid * Check if our page_cgroup is valid
*/ */
...@@ -705,6 +711,9 @@ int mem_cgroup_prepare_migration(struct page *page) ...@@ -705,6 +711,9 @@ int mem_cgroup_prepare_migration(struct page *page)
{ {
struct page_cgroup *pc; struct page_cgroup *pc;
if (mem_cgroup_subsys.disabled)
return 0;
lock_page_cgroup(page); lock_page_cgroup(page);
pc = page_get_page_cgroup(page); pc = page_get_page_cgroup(page);
if (pc) if (pc)
...@@ -803,6 +812,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *mem) ...@@ -803,6 +812,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *mem)
int ret = -EBUSY; int ret = -EBUSY;
int node, zid; int node, zid;
if (mem_cgroup_subsys.disabled)
return 0;
css_get(&mem->css); css_get(&mem->css);
/* /*
* page reclaim code (kswapd etc..) will move pages between * page reclaim code (kswapd etc..) will move pages between
...@@ -1053,6 +1065,8 @@ static void mem_cgroup_destroy(struct cgroup_subsys *ss, ...@@ -1053,6 +1065,8 @@ static void mem_cgroup_destroy(struct cgroup_subsys *ss,
static int mem_cgroup_populate(struct cgroup_subsys *ss, static int mem_cgroup_populate(struct cgroup_subsys *ss,
struct cgroup *cont) struct cgroup *cont)
{ {
if (mem_cgroup_subsys.disabled)
return 0;
return cgroup_add_files(cont, ss, mem_cgroup_files, return cgroup_add_files(cont, ss, mem_cgroup_files,
ARRAY_SIZE(mem_cgroup_files)); ARRAY_SIZE(mem_cgroup_files));
} }
...@@ -1065,6 +1079,9 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss, ...@@ -1065,6 +1079,9 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
struct mm_struct *mm; struct mm_struct *mm;
struct mem_cgroup *mem, *old_mem; struct mem_cgroup *mem, *old_mem;
if (mem_cgroup_subsys.disabled)
return;
mm = get_task_mm(p); mm = get_task_mm(p);
if (mm == NULL) if (mm == NULL)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment