aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 37b6d534b0ca..98a8045e2149 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1761,7 +1761,14 @@ static void cgroup_task_migrate(struct cgroup *old_cgrp,
1761 1761
1762 get_css_set(new_cset); 1762 get_css_set(new_cset);
1763 rcu_assign_pointer(tsk->cgroups, new_cset); 1763 rcu_assign_pointer(tsk->cgroups, new_cset);
1764 list_move(&tsk->cg_list, &new_cset->mg_tasks); 1764
1765 /*
1766 * Use move_tail so that cgroup_taskset_first() still returns the
1767 * leader after migration. This works because cgroup_migrate()
1768 * ensures that the dst_cset of the leader is the first on the
1769 * tset's dst_csets list.
1770 */
1771 list_move_tail(&tsk->cg_list, &new_cset->mg_tasks);
1765 1772
1766 /* 1773 /*
1767 * We just gained a reference on old_cset by taking it from the 1774 * We just gained a reference on old_cset by taking it from the
@@ -1936,9 +1943,16 @@ static int cgroup_migrate(struct cgroup *cgrp, struct task_struct *leader,
1936 if (!cset->mg_src_cgrp) 1943 if (!cset->mg_src_cgrp)
1937 goto next; 1944 goto next;
1938 1945
1939 list_move(&task->cg_list, &cset->mg_tasks); 1946 /*
1940 list_move(&cset->mg_node, &tset.src_csets); 1947 * cgroup_taskset_first() must always return the leader.
1941 list_move(&cset->mg_dst_cset->mg_node, &tset.dst_csets); 1948 * Take care to avoid disturbing the ordering.
1949 */
1950 list_move_tail(&task->cg_list, &cset->mg_tasks);
1951 if (list_empty(&cset->mg_node))
1952 list_add_tail(&cset->mg_node, &tset.src_csets);
1953 if (list_empty(&cset->mg_dst_cset->mg_node))
1954 list_move_tail(&cset->mg_dst_cset->mg_node,
1955 &tset.dst_csets);
1942 next: 1956 next:
1943 if (!threadgroup) 1957 if (!threadgroup)
1944 break; 1958 break;
@@ -1999,7 +2013,7 @@ out_release_tset:
1999 down_write(&css_set_rwsem); 2013 down_write(&css_set_rwsem);
2000 list_splice_init(&tset.dst_csets, &tset.src_csets); 2014 list_splice_init(&tset.dst_csets, &tset.src_csets);
2001 list_for_each_entry_safe(cset, tmp_cset, &tset.src_csets, mg_node) { 2015 list_for_each_entry_safe(cset, tmp_cset, &tset.src_csets, mg_node) {
2002 list_splice_init(&cset->mg_tasks, &cset->tasks); 2016 list_splice_tail_init(&cset->mg_tasks, &cset->tasks);
2003 list_del_init(&cset->mg_node); 2017 list_del_init(&cset->mg_node);
2004 } 2018 }
2005 up_write(&css_set_rwsem); 2019 up_write(&css_set_rwsem);