Skip to content

Commit

Permalink
Merge branch 'for-3.12-fixes' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/tj/cgroup

Pull cgroup fixes from Tejun Heo:
 "Two late fixes for cgroup.

  One fixes descendant walk introduced during this rc1 cycle.  The other
  fixes a post 3.9 bug during task attach which can lead to hang.  Both
  fixes are critical and the fixes are relatively straight-forward"

* 'for-3.12-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: fix to break the while loop in cgroup_attach_task() correctly
  cgroup: fix cgroup post-order descendant walk of empty subtree
  • Loading branch information
Linus Torvalds committed Oct 22, 2013
2 parents 0df651a + ea84753 commit ee7eafc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2039,23 +2039,23 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,

/* @tsk either already exited or can't exit until the end */
if (tsk->flags & PF_EXITING)
continue;
goto next;

/* as per above, nr_threads may decrease, but not increase. */
BUG_ON(i >= group_size);
ent.task = tsk;
ent.cgrp = task_cgroup_from_root(tsk, root);
/* nothing to do if this task is already in the cgroup */
if (ent.cgrp == cgrp)
continue;
goto next;
/*
* saying GFP_ATOMIC has no effect here because we did prealloc
* earlier, but it's good form to communicate our expectations.
*/
retval = flex_array_put(group, i, &ent, GFP_ATOMIC);
BUG_ON(retval != 0);
i++;

next:
if (!threadgroup)
break;
} while_each_thread(leader, tsk);
Expand Down Expand Up @@ -3188,11 +3188,9 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,

WARN_ON_ONCE(!rcu_read_lock_held());

/* if first iteration, visit the leftmost descendant */
if (!pos) {
next = css_leftmost_descendant(root);
return next != root ? next : NULL;
}
/* if first iteration, visit leftmost descendant which may be @root */
if (!pos)
return css_leftmost_descendant(root);

/* if we visited @root, we're done */
if (pos == root)
Expand Down

0 comments on commit ee7eafc

Please sign in to comment.