diff options
author | Tejun Heo <tj@kernel.org> | 2015-10-15 16:41:51 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2015-10-15 16:41:51 -0400 |
commit | 389b9c1bc927c8194a49f5f0c7e069ed0ec79b9e (patch) | |
tree | 67c3faae1cd833128a515a19e212bdee4d48b36f /kernel/cgroup.c | |
parent | 91486f61f486662c27ef86dd910f875832e3a5de (diff) |
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: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 61ee85ded6ae..52444673e9a2 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -914,12 +914,11 @@ static void link_css_set(struct list_head *tmp_links, struct css_set *cset, | |||
914 | link->cset = cset; | 914 | link->cset = cset; |
915 | link->cgrp = cgrp; | 915 | link->cgrp = cgrp; |
916 | 916 | ||
917 | list_move(&link->cset_link, &cgrp->cset_links); | ||
918 | |||
919 | /* | 917 | /* |
920 | * Always add links to the tail of the list so that the list | 918 | * Always add links to the tail of the lists so that the lists are |
921 | * is sorted by order of hierarchy creation | 919 | * in choronological order. |
922 | */ | 920 | */ |
921 | list_move_tail(&link->cset_link, &cgrp->cset_links); | ||
923 | list_add_tail(&link->cgrp_link, &cset->cgrp_links); | 922 | list_add_tail(&link->cgrp_link, &cset->cgrp_links); |
924 | 923 | ||
925 | if (cgroup_parent(cgrp)) | 924 | if (cgroup_parent(cgrp)) |
@@ -1780,7 +1779,7 @@ static void cgroup_enable_task_cg_lists(void) | |||
1780 | 1779 | ||
1781 | if (!css_set_populated(cset)) | 1780 | if (!css_set_populated(cset)) |
1782 | css_set_update_populated(cset, true); | 1781 | css_set_update_populated(cset, true); |
1783 | list_add(&p->cg_list, &cset->tasks); | 1782 | list_add_tail(&p->cg_list, &cset->tasks); |
1784 | get_css_set(cset); | 1783 | get_css_set(cset); |
1785 | } | 1784 | } |
1786 | spin_unlock_irq(&p->sighand->siglock); | 1785 | spin_unlock_irq(&p->sighand->siglock); |
@@ -5480,7 +5479,7 @@ void cgroup_post_fork(struct task_struct *child, | |||
5480 | cset = task_css_set(current); | 5479 | cset = task_css_set(current); |
5481 | if (list_empty(&child->cg_list)) { | 5480 | if (list_empty(&child->cg_list)) { |
5482 | rcu_assign_pointer(child->cgroups, cset); | 5481 | rcu_assign_pointer(child->cgroups, cset); |
5483 | list_add(&child->cg_list, &cset->tasks); | 5482 | list_add_tail(&child->cg_list, &cset->tasks); |
5484 | get_css_set(cset); | 5483 | get_css_set(cset); |
5485 | } | 5484 | } |
5486 | up_write(&css_set_rwsem); | 5485 | up_write(&css_set_rwsem); |