[PATCH][BUGFIX] cgroups: fix ordering of calls in cgroup_attach_proc
Ben Blum
bblum at andrew.cmu.edu
Mon Aug 15 16:11:56 PDT 2011
Fix ordering of cgroup_task_migrate and attach_task in cgroup_attach_proc.
Signed-off-by: Ben Blum <bblum at andrew.cmu.edu>
---
kernel/cgroup.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff -u a/kernel/cgroup.c b/kernel/cgroup.c
--- a/kernel/cgroup.c 2011-08-15 19:05:37.308401219 -0400
+++ b/kernel/cgroup.c 2011-08-15 19:07:47.376775142 -0400
@@ -2132,14 +2132,17 @@
oldcgrp = task_cgroup_from_root(tsk, root);
if (cgrp == oldcgrp)
continue;
- /* 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);
+ if (retval == 0) {
+ /* attach each task to each subsystem */
+ for_each_subsys(root, ss) {
+ if (ss->attach_task)
+ ss->attach_task(cgrp, tsk);
+ }
+ } else {
+ BUG_ON(retval != -ESRCH);
+ }
}
/* nothing is sensitive to fork() after this point. */
More information about the Containers
mailing list