cgroup: Clean up css_set task traversal
css_task_iter stores pointer to head of each iterable list, this dates
back to commit 0f0a2b4fa6
("cgroup: reorganize css_task_iter") when we
did not store cur_cset. Let us utilize list heads directly in cur_cset
and streamline css_task_iter_advance_css_set a bit. This is no
intentional function change.
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
@@ -58,9 +58,6 @@ struct css_task_iter {
|
|||||||
struct list_head *tcset_head;
|
struct list_head *tcset_head;
|
||||||
|
|
||||||
struct list_head *task_pos;
|
struct list_head *task_pos;
|
||||||
struct list_head *tasks_head;
|
|
||||||
struct list_head *mg_tasks_head;
|
|
||||||
struct list_head *dying_tasks_head;
|
|
||||||
|
|
||||||
struct list_head *cur_tasks_head;
|
struct list_head *cur_tasks_head;
|
||||||
struct css_set *cur_cset;
|
struct css_set *cur_cset;
|
||||||
|
@@ -4391,29 +4391,24 @@ static void css_task_iter_advance_css_set(struct css_task_iter *it)
|
|||||||
|
|
||||||
lockdep_assert_held(&css_set_lock);
|
lockdep_assert_held(&css_set_lock);
|
||||||
|
|
||||||
/* Advance to the next non-empty css_set */
|
/* Advance to the next non-empty css_set and find first non-empty tasks list*/
|
||||||
do {
|
while ((cset = css_task_iter_next_css_set(it))) {
|
||||||
cset = css_task_iter_next_css_set(it);
|
if (!list_empty(&cset->tasks)) {
|
||||||
if (!cset) {
|
it->cur_tasks_head = &cset->tasks;
|
||||||
it->task_pos = NULL;
|
break;
|
||||||
return;
|
} else if (!list_empty(&cset->mg_tasks)) {
|
||||||
|
it->cur_tasks_head = &cset->mg_tasks;
|
||||||
|
break;
|
||||||
|
} else if (!list_empty(&cset->dying_tasks)) {
|
||||||
|
it->cur_tasks_head = &cset->dying_tasks;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} while (!css_set_populated(cset) && list_empty(&cset->dying_tasks));
|
|
||||||
|
|
||||||
if (!list_empty(&cset->tasks)) {
|
|
||||||
it->task_pos = cset->tasks.next;
|
|
||||||
it->cur_tasks_head = &cset->tasks;
|
|
||||||
} else if (!list_empty(&cset->mg_tasks)) {
|
|
||||||
it->task_pos = cset->mg_tasks.next;
|
|
||||||
it->cur_tasks_head = &cset->mg_tasks;
|
|
||||||
} else {
|
|
||||||
it->task_pos = cset->dying_tasks.next;
|
|
||||||
it->cur_tasks_head = &cset->dying_tasks;
|
|
||||||
}
|
}
|
||||||
|
if (!cset) {
|
||||||
it->tasks_head = &cset->tasks;
|
it->task_pos = NULL;
|
||||||
it->mg_tasks_head = &cset->mg_tasks;
|
return;
|
||||||
it->dying_tasks_head = &cset->dying_tasks;
|
}
|
||||||
|
it->task_pos = it->cur_tasks_head->next;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't keep css_sets locked across iteration steps and thus
|
* We don't keep css_sets locked across iteration steps and thus
|
||||||
@@ -4458,24 +4453,24 @@ static void css_task_iter_advance(struct css_task_iter *it)
|
|||||||
repeat:
|
repeat:
|
||||||
if (it->task_pos) {
|
if (it->task_pos) {
|
||||||
/*
|
/*
|
||||||
* Advance iterator to find next entry. cset->tasks is
|
* Advance iterator to find next entry. We go through cset
|
||||||
* consumed first and then ->mg_tasks. After ->mg_tasks,
|
* tasks, mg_tasks and dying_tasks, when consumed we move onto
|
||||||
* we move onto the next cset.
|
* the next cset.
|
||||||
*/
|
*/
|
||||||
if (it->flags & CSS_TASK_ITER_SKIPPED)
|
if (it->flags & CSS_TASK_ITER_SKIPPED)
|
||||||
it->flags &= ~CSS_TASK_ITER_SKIPPED;
|
it->flags &= ~CSS_TASK_ITER_SKIPPED;
|
||||||
else
|
else
|
||||||
it->task_pos = it->task_pos->next;
|
it->task_pos = it->task_pos->next;
|
||||||
|
|
||||||
if (it->task_pos == it->tasks_head) {
|
if (it->task_pos == &it->cur_cset->tasks) {
|
||||||
it->task_pos = it->mg_tasks_head->next;
|
it->cur_tasks_head = &it->cur_cset->mg_tasks;
|
||||||
it->cur_tasks_head = it->mg_tasks_head;
|
it->task_pos = it->cur_tasks_head->next;
|
||||||
}
|
}
|
||||||
if (it->task_pos == it->mg_tasks_head) {
|
if (it->task_pos == &it->cur_cset->mg_tasks) {
|
||||||
it->task_pos = it->dying_tasks_head->next;
|
it->cur_tasks_head = &it->cur_cset->dying_tasks;
|
||||||
it->cur_tasks_head = it->dying_tasks_head;
|
it->task_pos = it->cur_tasks_head->next;
|
||||||
}
|
}
|
||||||
if (it->task_pos == it->dying_tasks_head)
|
if (it->task_pos == &it->cur_cset->dying_tasks)
|
||||||
css_task_iter_advance_css_set(it);
|
css_task_iter_advance_css_set(it);
|
||||||
} else {
|
} else {
|
||||||
/* called from start, proceed to the first cset */
|
/* called from start, proceed to the first cset */
|
||||||
@@ -4493,12 +4488,12 @@ repeat:
|
|||||||
goto repeat;
|
goto repeat;
|
||||||
|
|
||||||
/* and dying leaders w/o live member threads */
|
/* and dying leaders w/o live member threads */
|
||||||
if (it->cur_tasks_head == it->dying_tasks_head &&
|
if (it->cur_tasks_head == &it->cur_cset->dying_tasks &&
|
||||||
!atomic_read(&task->signal->live))
|
!atomic_read(&task->signal->live))
|
||||||
goto repeat;
|
goto repeat;
|
||||||
} else {
|
} else {
|
||||||
/* skip all dying ones */
|
/* skip all dying ones */
|
||||||
if (it->cur_tasks_head == it->dying_tasks_head)
|
if (it->cur_tasks_head == &it->cur_cset->dying_tasks)
|
||||||
goto repeat;
|
goto repeat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user