|author||Balbir Singh <email@example.com>||2008-04-29 01:00:16 -0700|
|committer||Linus Torvalds <firstname.lastname@example.org>||2008-04-29 08:06:10 -0700|
cgroups: add an owner to the mm_struct
Remove the mem_cgroup member from mm_struct and instead adds an owner. This approach was suggested by Paul Menage. The advantage of this approach is that, once the mm->owner is known, using the subsystem id, the cgroup can be determined. It also allows several control groups that are virtually grouped by mm_struct, to exist independent of the memory controller i.e., without adding mem_cgroup's for each controller, to mm_struct. A new config option CONFIG_MM_OWNER is added and the memory resource controller selects this config option. This patch also adds cgroup callbacks to notify subsystems when mm->owner changes. The mm_cgroup_changed callback is called with the task_lock() of the new task held and is called just prior to changing the mm->owner. I am indebted to Paul Menage for the several reviews of this patchset and helping me make it lighter and simpler. This patch was tested on a powerpc box, it was compiled with both the MM_OWNER config turned on and off. After the thread group leader exits, it's moved to init_css_state by cgroup_exit(), thus all future charges from runnings threads would be redirected to the init_css_set's subsystem. Signed-off-by: Balbir Singh <email@example.com> Cc: Pavel Emelianov <firstname.lastname@example.org> Cc: Hugh Dickins <email@example.com> Cc: Sudhir Kumar <firstname.lastname@example.org> Cc: YAMAMOTO Takashi <email@example.com> Cc: Hirokazu Takahashi <firstname.lastname@example.org> Cc: David Rientjes <email@example.com>, Cc: Balbir Singh <firstname.lastname@example.org> Acked-by: KAMEZAWA Hiroyuki <email@example.com> Acked-by: Pekka Enberg <firstname.lastname@example.org> Reviewed-by: Paul Menage <email@example.com> Cc: Oleg Nesterov <firstname.lastname@example.org> Signed-off-by: Andrew Morton <email@example.com> Signed-off-by: Linus Torvalds <firstname.lastname@example.org>
Diffstat (limited to 'init')
2 files changed, 8 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index a3457926342..98fa96eac41 100644
@@ -378,9 +378,13 @@ config RESOURCE_COUNTERS
infrastructure that works with cgroups
depends on CGROUPS
bool "Memory Resource Controller for Control Groups"
depends on CGROUPS && RESOURCE_COUNTERS
+ select MM_OWNER
Provides a memory resource controller that manages both page cache and
@@ -393,6 +397,9 @@ config CGROUP_MEM_RES_CTLR
Only enable when you're ok with these trade offs and really
sure you need the memory resource controller.
+ This config option also selects MM_OWNER config option, which
+ could in turn add some fork/exit overhead.
diff --git a/init/main.c b/init/main.c
index 1116d2f40cc..c62c98f381f 100644
@@ -559,6 +559,7 @@ asmlinkage void __init start_kernel(void)
+ mm_init_owner(&init_mm, &init_task);