diff mbox

[1/6] cgroup: subsys->attach_task() should be called after migration

Message ID 1314138000-2049-2-git-send-email-tj@kernel.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Tejun Heo Aug. 23, 2011, 10:19 p.m. UTC
cgroup_attach_task() calls subsys->attach_task() after
cgroup_task_migrate(); however, cgroup_attach_proc() calls it before
migration.  This actually affects some of the users.  Update
cgroup_attach_proc() such that ->attach_task() is called after
migration.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Paul Menage <paul@paulmenage.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/cgroup.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Comments

Frederic Weisbecker Aug. 24, 2011, 12:32 a.m. UTC | #1
On Wed, Aug 24, 2011 at 12:19:55AM +0200, Tejun Heo wrote:
> cgroup_attach_task() calls subsys->attach_task() after
> cgroup_task_migrate(); however, cgroup_attach_proc() calls it before
> migration.  This actually affects some of the users.  Update
> cgroup_attach_proc() such that ->attach_task() is called after
> migration.

There have been a patch posted recently:

        "[PATCH][BUGFIX] cgroups: fix ordering of calls in cgroup_attach_proc"

that not only fixes that ordering but also only attach the task if the
migration happened correctly (task not exited).

Can somebody queue it for 3.2 ?
Li Zefan Aug. 24, 2011, 1:31 a.m. UTC | #2
> There have been a patch posted recently:
> 
>         "[PATCH][BUGFIX] cgroups: fix ordering of calls in cgroup_attach_proc"
> 
> that not only fixes that ordering but also only attach the task if the
> migration happened correctly (task not exited).
> 
> Can somebody queue it for 3.2 ?
> 

cgroup patches normally go through -mm tree.
diff mbox

Patch

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 1d2b6ce..a606fa2 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2135,14 +2135,16 @@  int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
 		oldcgrp = task_cgroup_from_root(tsk, root);
 		if (cgrp == oldcgrp)
 			continue;
+
+		/* if the thread is PF_EXITING, it can just get skipped. */
+		retval = cgroup_task_migrate(cgrp, oldcgrp, tsk, true);
+		BUG_ON(retval != 0 && retval != -ESRCH);
+
 		/* attach each task to each subsystem */
 		for_each_subsys(root, ss) {
 			if (ss->attach_task)
 				ss->attach_task(cgrp, tsk);
 		}
-		/* if the thread is PF_EXITING, it can just get skipped. */
-		retval = cgroup_task_migrate(cgrp, oldcgrp, tsk, true);
-		BUG_ON(retval != 0 && retval != -ESRCH);
 	}
 	/* nothing is sensitive to fork() after this point. */