From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sd0109e.au.ibm.com (d23rh905.au.ibm.com [202.81.18.225]) by e23smtp01.au.ibm.com (8.13.1/8.13.1) with ESMTP id l7OFKqJI007395 for ; Sat, 25 Aug 2007 01:20:52 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by sd0109e.au.ibm.com (8.13.8/8.13.8/NCO v8.5) with ESMTP id l7OFOMkv117150 for ; Sat, 25 Aug 2007 01:24:22 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l7OGKmAY006200 for ; Sat, 25 Aug 2007 02:20:48 +1000 From: Balbir Singh Date: Fri, 24 Aug 2007 20:50:43 +0530 Message-Id: <20070824152043.16582.37727.sendpatchset@balbir-laptop> In-Reply-To: <20070824151948.16582.34424.sendpatchset@balbir-laptop> References: <20070824151948.16582.34424.sendpatchset@balbir-laptop> Subject: [-mm PATCH 5/10] Memory controller task migration (v7) Sender: owner-linux-mm@kvack.org Return-Path: To: Andrew Morton Cc: Paul Menage , Linux Kernel Mailing List , Linux Containers , YAMAMOTO Takashi , Peter Zijlstra , Eric W Biederman , Linux MM Mailing List , Nick Piggin , Vaidyanathan Srinivasan , Pavel Emelianov , Dhaval Giani , Balbir Singh , Dave Hansen , KAMEZAWA Hiroyuki List-ID: Allow tasks to migrate from one container to the other. We migrate mm_struct's mem_container only when the thread group id migrates. Signed-off-by: Balbir Singh --- mm/memcontrol.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff -puN mm/memcontrol.c~mem-control-task-migration mm/memcontrol.c --- linux-2.6.23-rc2-mm2/mm/memcontrol.c~mem-control-task-migration 2007-08-24 20:46:07.000000000 +0530 +++ linux-2.6.23-rc2-mm2-balbir/mm/memcontrol.c 2007-08-24 20:46:07.000000000 +0530 @@ -326,11 +326,46 @@ static int mem_container_populate(struct ARRAY_SIZE(mem_container_files)); } +static void mem_container_move_task(struct container_subsys *ss, + struct container *cont, + struct container *old_cont, + struct task_struct *p) +{ + struct mm_struct *mm; + struct mem_container *mem, *old_mem; + + mm = get_task_mm(p); + if (mm == NULL) + return; + + mem = mem_container_from_cont(cont); + old_mem = mem_container_from_cont(old_cont); + + if (mem == old_mem) + goto out; + + /* + * Only thread group leaders are allowed to migrate, the mm_struct is + * in effect owned by the leader + */ + if (p->tgid != p->pid) + goto out; + + css_get(&mem->css); + rcu_assign_pointer(mm->mem_container, mem); + css_put(&old_mem->css); + +out: + mmput(mm); + return; +} + struct container_subsys mem_container_subsys = { .name = "memory", .subsys_id = mem_container_subsys_id, .create = mem_container_create, .destroy = mem_container_destroy, .populate = mem_container_populate, + .attach = mem_container_move_task, .early_init = 1, }; _ -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org