aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0edc186cd545..d48163b26196 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2857,27 +2857,30 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,
2857 */ 2857 */
2858static void css_advance_task_iter(struct css_task_iter *it) 2858static void css_advance_task_iter(struct css_task_iter *it)
2859{ 2859{
2860 struct list_head *l = it->cset_link; 2860 struct list_head *l = it->cset_pos;
2861 struct cgrp_cset_link *link; 2861 struct cgrp_cset_link *link;
2862 struct css_set *cset; 2862 struct css_set *cset;
2863 2863
2864 /* Advance to the next non-empty css_set */ 2864 /* Advance to the next non-empty css_set */
2865 do { 2865 do {
2866 l = l->next; 2866 l = l->next;
2867 if (l == &it->origin_css->cgroup->cset_links) { 2867 if (l == it->cset_head) {
2868 it->cset_link = NULL; 2868 it->cset_pos = NULL;
2869 return; 2869 return;
2870 } 2870 }
2871 link = list_entry(l, struct cgrp_cset_link, cset_link); 2871 link = list_entry(l, struct cgrp_cset_link, cset_link);
2872 cset = link->cset; 2872 cset = link->cset;
2873 } while (list_empty(&cset->tasks) && list_empty(&cset->mg_tasks)); 2873 } while (list_empty(&cset->tasks) && list_empty(&cset->mg_tasks));
2874 2874
2875 it->cset_link = l; 2875 it->cset_pos = l;
2876 2876
2877 if (!list_empty(&cset->tasks)) 2877 if (!list_empty(&cset->tasks))
2878 it->task = cset->tasks.next; 2878 it->task_pos = cset->tasks.next;
2879 else 2879 else
2880 it->task = cset->mg_tasks.next; 2880 it->task_pos = cset->mg_tasks.next;
2881
2882 it->tasks_head = &cset->tasks;
2883 it->mg_tasks_head = &cset->mg_tasks;
2881} 2884}
2882 2885
2883/** 2886/**
@@ -2903,8 +2906,8 @@ void css_task_iter_start(struct cgroup_subsys_state *css,
2903 2906
2904 down_read(&css_set_rwsem); 2907 down_read(&css_set_rwsem);
2905 2908
2906 it->origin_css = css; 2909 it->cset_pos = &css->cgroup->cset_links;
2907 it->cset_link = &css->cgroup->cset_links; 2910 it->cset_head = it->cset_pos;
2908 2911
2909 css_advance_task_iter(it); 2912 css_advance_task_iter(it);
2910} 2913}
@@ -2920,12 +2923,10 @@ void css_task_iter_start(struct cgroup_subsys_state *css,
2920struct task_struct *css_task_iter_next(struct css_task_iter *it) 2923struct task_struct *css_task_iter_next(struct css_task_iter *it)
2921{ 2924{
2922 struct task_struct *res; 2925 struct task_struct *res;
2923 struct list_head *l = it->task; 2926 struct list_head *l = it->task_pos;
2924 struct cgrp_cset_link *link = list_entry(it->cset_link,
2925 struct cgrp_cset_link, cset_link);
2926 2927
2927 /* If the iterator cg is NULL, we have no tasks */ 2928 /* If the iterator cg is NULL, we have no tasks */
2928 if (!it->cset_link) 2929 if (!it->cset_pos)
2929 return NULL; 2930 return NULL;
2930 res = list_entry(l, struct task_struct, cg_list); 2931 res = list_entry(l, struct task_struct, cg_list);
2931 2932
@@ -2936,13 +2937,13 @@ struct task_struct *css_task_iter_next(struct css_task_iter *it)
2936 */ 2937 */
2937 l = l->next; 2938 l = l->next;
2938 2939
2939 if (l == &link->cset->tasks) 2940 if (l == it->tasks_head)
2940 l = link->cset->mg_tasks.next; 2941 l = it->mg_tasks_head->next;
2941 2942
2942 if (l == &link->cset->mg_tasks) 2943 if (l == it->mg_tasks_head)
2943 css_advance_task_iter(it); 2944 css_advance_task_iter(it);
2944 else 2945 else
2945 it->task = l; 2946 it->task_pos = l;
2946 2947
2947 return res; 2948 return res;
2948} 2949}