Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee7eafc9 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 0df651a0 ea84753c
Loading
Loading
Loading
Loading
+6 −8
Original line number Original line Diff line number Diff line
@@ -2039,7 +2039,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,


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


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

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


	WARN_ON_ONCE(!rcu_read_lock_held());
	WARN_ON_ONCE(!rcu_read_lock_held());


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


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