@@ -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. */
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(-)