提交 389b9c1b 编写于 作者: T Tejun Heo

cgroup: keep css_set and task lists in chronological order

css task iteration will be updated to not leak cgroup internal locking
to iterator users.  In preparation, update css_set and task lists to
be in chronological order.

For tasks, as migration path is already using list_splice_tail_init(),
only cgroup_enable_task_cg_lists() and cgroup_post_fork() need
updating.  For css_sets, link_css_set() is the only place which needs
to be updated.
Signed-off-by: NTejun Heo <tj@kernel.org>
上级 91486f61
...@@ -914,12 +914,11 @@ static void link_css_set(struct list_head *tmp_links, struct css_set *cset, ...@@ -914,12 +914,11 @@ static void link_css_set(struct list_head *tmp_links, struct css_set *cset,
link->cset = cset; link->cset = cset;
link->cgrp = cgrp; link->cgrp = cgrp;
list_move(&link->cset_link, &cgrp->cset_links);
/* /*
* Always add links to the tail of the list so that the list * Always add links to the tail of the lists so that the lists are
* is sorted by order of hierarchy creation * in choronological order.
*/ */
list_move_tail(&link->cset_link, &cgrp->cset_links);
list_add_tail(&link->cgrp_link, &cset->cgrp_links); list_add_tail(&link->cgrp_link, &cset->cgrp_links);
if (cgroup_parent(cgrp)) if (cgroup_parent(cgrp))
...@@ -1780,7 +1779,7 @@ static void cgroup_enable_task_cg_lists(void) ...@@ -1780,7 +1779,7 @@ static void cgroup_enable_task_cg_lists(void)
if (!css_set_populated(cset)) if (!css_set_populated(cset))
css_set_update_populated(cset, true); css_set_update_populated(cset, true);
list_add(&p->cg_list, &cset->tasks); list_add_tail(&p->cg_list, &cset->tasks);
get_css_set(cset); get_css_set(cset);
} }
spin_unlock_irq(&p->sighand->siglock); spin_unlock_irq(&p->sighand->siglock);
...@@ -5480,7 +5479,7 @@ void cgroup_post_fork(struct task_struct *child, ...@@ -5480,7 +5479,7 @@ void cgroup_post_fork(struct task_struct *child,
cset = task_css_set(current); cset = task_css_set(current);
if (list_empty(&child->cg_list)) { if (list_empty(&child->cg_list)) {
rcu_assign_pointer(child->cgroups, cset); rcu_assign_pointer(child->cgroups, cset);
list_add(&child->cg_list, &cset->tasks); list_add_tail(&child->cg_list, &cset->tasks);
get_css_set(cset); get_css_set(cset);
} }
up_write(&css_set_rwsem); up_write(&css_set_rwsem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册