aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:25 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:25 -0400
commit492eb21b98f88e411a8bb43d6edcd7d7022add10 (patch)
treeda06df9485fd607762fdec06169f7d9f601e3cf6 /kernel
parentf48e3924dca268c677c4e338e5d91ad9e6fe6b9e (diff)
cgroup: make hierarchy iterators deal with cgroup_subsys_state instead of cgroup
cgroup is currently in the process of transitioning to using css (cgroup_subsys_state) as the primary handle instead of cgroup in subsystem API. For hierarchy iterators, this is beneficial because * In most cases, css is the only thing subsystems care about anyway. * On the planned unified hierarchy, iterations for different subsystems will need to skip over different subtrees of the hierarchy depending on which subsystems are enabled on each cgroup. Passing around css makes it unnecessary to explicitly specify the subsystem in question as css is intersection between cgroup and subsystem * For the planned unified hierarchy, css's would need to be created and destroyed dynamically independent from cgroup hierarchy. Having cgroup core manage css iteration makes enforcing deref rules a lot easier. Most subsystem conversions are straight-forward. Noteworthy changes are * blkio: cgroup_to_blkcg() is no longer used. Removed. * freezer: cgroup_freezer() is no longer used. Removed. * devices: cgroup_to_devcgroup() is no longer used. Removed. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Aristeu Rozanski <aris@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Matt Helsley <matthltc@us.ibm.com> Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c131
-rw-r--r--kernel/cgroup_freezer.c25
-rw-r--r--kernel/cpuset.c58
3 files changed, 112 insertions, 102 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2b7354faaca7..91eac33fac86 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2814,8 +2814,8 @@ static void cgroup_cfts_prepare(void)
2814 /* 2814 /*
2815 * Thanks to the entanglement with vfs inode locking, we can't walk 2815 * Thanks to the entanglement with vfs inode locking, we can't walk
2816 * the existing cgroups under cgroup_mutex and create files. 2816 * the existing cgroups under cgroup_mutex and create files.
2817 * Instead, we use cgroup_for_each_descendant_pre() and drop RCU 2817 * Instead, we use css_for_each_descendant_pre() and drop RCU read
2818 * read lock before calling cgroup_addrm_files(). 2818 * lock before calling cgroup_addrm_files().
2819 */ 2819 */
2820 mutex_lock(&cgroup_mutex); 2820 mutex_lock(&cgroup_mutex);
2821} 2821}
@@ -2825,10 +2825,11 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add)
2825{ 2825{
2826 LIST_HEAD(pending); 2826 LIST_HEAD(pending);
2827 struct cgroup_subsys *ss = cfts[0].ss; 2827 struct cgroup_subsys *ss = cfts[0].ss;
2828 struct cgroup *cgrp, *root = &ss->root->top_cgroup; 2828 struct cgroup *root = &ss->root->top_cgroup;
2829 struct super_block *sb = ss->root->sb; 2829 struct super_block *sb = ss->root->sb;
2830 struct dentry *prev = NULL; 2830 struct dentry *prev = NULL;
2831 struct inode *inode; 2831 struct inode *inode;
2832 struct cgroup_subsys_state *css;
2832 u64 update_before; 2833 u64 update_before;
2833 int ret = 0; 2834 int ret = 0;
2834 2835
@@ -2861,7 +2862,9 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add)
2861 2862
2862 /* add/rm files for all cgroups created before */ 2863 /* add/rm files for all cgroups created before */
2863 rcu_read_lock(); 2864 rcu_read_lock();
2864 cgroup_for_each_descendant_pre(cgrp, root) { 2865 css_for_each_descendant_pre(css, cgroup_css(root, ss->subsys_id)) {
2866 struct cgroup *cgrp = css->cgroup;
2867
2865 if (cgroup_is_dead(cgrp)) 2868 if (cgroup_is_dead(cgrp))
2866 continue; 2869 continue;
2867 2870
@@ -3037,17 +3040,21 @@ static void cgroup_enable_task_cg_lists(void)
3037} 3040}
3038 3041
3039/** 3042/**
3040 * cgroup_next_child - find the next child of a given cgroup 3043 * css_next_child - find the next child of a given css
3041 * @pos: the current position (%NULL to initiate traversal) 3044 * @pos_css: the current position (%NULL to initiate traversal)
3042 * @cgrp: cgroup whose descendants to walk 3045 * @parent_css: css whose children to walk
3043 * 3046 *
3044 * This function returns the next child of @cgrp and should be called under 3047 * This function returns the next child of @parent_css and should be called
3045 * RCU read lock. The only requirement is that @cgrp and @pos are 3048 * under RCU read lock. The only requirement is that @parent_css and
3046 * accessible. The next sibling is guaranteed to be returned regardless of 3049 * @pos_css are accessible. The next sibling is guaranteed to be returned
3047 * their states. 3050 * regardless of their states.
3048 */ 3051 */
3049struct cgroup *cgroup_next_child(struct cgroup *pos, struct cgroup *cgrp) 3052struct cgroup_subsys_state *
3053css_next_child(struct cgroup_subsys_state *pos_css,
3054 struct cgroup_subsys_state *parent_css)
3050{ 3055{
3056 struct cgroup *pos = pos_css ? pos_css->cgroup : NULL;
3057 struct cgroup *cgrp = parent_css->cgroup;
3051 struct cgroup *next; 3058 struct cgroup *next;
3052 3059
3053 WARN_ON_ONCE(!rcu_read_lock_held()); 3060 WARN_ON_ONCE(!rcu_read_lock_held());
@@ -3081,59 +3088,64 @@ struct cgroup *cgroup_next_child(struct cgroup *pos, struct cgroup *cgrp)
3081 break; 3088 break;
3082 } 3089 }
3083 3090
3084 if (&next->sibling != &cgrp->children) 3091 if (&next->sibling == &cgrp->children)
3085 return next; 3092 return NULL;
3086 return NULL; 3093
3094 if (parent_css->ss)
3095 return cgroup_css(next, parent_css->ss->subsys_id);
3096 else
3097 return &next->dummy_css;
3087} 3098}
3088EXPORT_SYMBOL_GPL(cgroup_next_child); 3099EXPORT_SYMBOL_GPL(css_next_child);
3089 3100
3090/** 3101/**
3091 * cgroup_next_descendant_pre - find the next descendant for pre-order walk 3102 * css_next_descendant_pre - find the next descendant for pre-order walk
3092 * @pos: the current position (%NULL to initiate traversal) 3103 * @pos: the current position (%NULL to initiate traversal)
3093 * @cgroup: cgroup whose descendants to walk 3104 * @root: css whose descendants to walk
3094 * 3105 *
3095 * To be used by cgroup_for_each_descendant_pre(). Find the next 3106 * To be used by css_for_each_descendant_pre(). Find the next descendant
3096 * descendant to visit for pre-order traversal of @cgroup's descendants. 3107 * to visit for pre-order traversal of @root's descendants.
3097 * 3108 *
3098 * While this function requires RCU read locking, it doesn't require the 3109 * While this function requires RCU read locking, it doesn't require the
3099 * whole traversal to be contained in a single RCU critical section. This 3110 * whole traversal to be contained in a single RCU critical section. This
3100 * function will return the correct next descendant as long as both @pos 3111 * function will return the correct next descendant as long as both @pos
3101 * and @cgroup are accessible and @pos is a descendant of @cgroup. 3112 * and @root are accessible and @pos is a descendant of @root.
3102 */ 3113 */
3103struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos, 3114struct cgroup_subsys_state *
3104 struct cgroup *cgroup) 3115css_next_descendant_pre(struct cgroup_subsys_state *pos,
3116 struct cgroup_subsys_state *root)
3105{ 3117{
3106 struct cgroup *next; 3118 struct cgroup_subsys_state *next;
3107 3119
3108 WARN_ON_ONCE(!rcu_read_lock_held()); 3120 WARN_ON_ONCE(!rcu_read_lock_held());
3109 3121
3110 /* if first iteration, pretend we just visited @cgroup */ 3122 /* if first iteration, pretend we just visited @root */
3111 if (!pos) 3123 if (!pos)
3112 pos = cgroup; 3124 pos = root;
3113 3125
3114 /* visit the first child if exists */ 3126 /* visit the first child if exists */
3115 next = cgroup_next_child(NULL, pos); 3127 next = css_next_child(NULL, pos);
3116 if (next) 3128 if (next)
3117 return next; 3129 return next;
3118 3130
3119 /* no child, visit my or the closest ancestor's next sibling */ 3131 /* no child, visit my or the closest ancestor's next sibling */
3120 while (pos != cgroup) { 3132 while (pos != root) {
3121 next = cgroup_next_child(pos, pos->parent); 3133 next = css_next_child(pos, css_parent(pos));
3122 if (next) 3134 if (next)
3123 return next; 3135 return next;
3124 pos = pos->parent; 3136 pos = css_parent(pos);
3125 } 3137 }
3126 3138
3127 return NULL; 3139 return NULL;
3128} 3140}
3129EXPORT_SYMBOL_GPL(cgroup_next_descendant_pre); 3141EXPORT_SYMBOL_GPL(css_next_descendant_pre);
3130 3142
3131/** 3143/**
3132 * cgroup_rightmost_descendant - return the rightmost descendant of a cgroup 3144 * css_rightmost_descendant - return the rightmost descendant of a css
3133 * @pos: cgroup of interest 3145 * @pos: css of interest
3134 * 3146 *
3135 * Return the rightmost descendant of @pos. If there's no descendant, 3147 * Return the rightmost descendant of @pos. If there's no descendant, @pos
3136 * @pos is returned. This can be used during pre-order traversal to skip 3148 * is returned. This can be used during pre-order traversal to skip
3137 * subtree of @pos. 3149 * subtree of @pos.
3138 * 3150 *
3139 * While this function requires RCU read locking, it doesn't require the 3151 * While this function requires RCU read locking, it doesn't require the
@@ -3141,9 +3153,10 @@ EXPORT_SYMBOL_GPL(cgroup_next_descendant_pre);
3141 * function will return the correct rightmost descendant as long as @pos is 3153 * function will return the correct rightmost descendant as long as @pos is
3142 * accessible. 3154 * accessible.
3143 */ 3155 */
3144struct cgroup *cgroup_rightmost_descendant(struct cgroup *pos) 3156struct cgroup_subsys_state *
3157css_rightmost_descendant(struct cgroup_subsys_state *pos)
3145{ 3158{
3146 struct cgroup *last, *tmp; 3159 struct cgroup_subsys_state *last, *tmp;
3147 3160
3148 WARN_ON_ONCE(!rcu_read_lock_held()); 3161 WARN_ON_ONCE(!rcu_read_lock_held());
3149 3162
@@ -3151,62 +3164,64 @@ struct cgroup *cgroup_rightmost_descendant(struct cgroup *pos)
3151 last = pos; 3164 last = pos;
3152 /* ->prev isn't RCU safe, walk ->next till the end */ 3165 /* ->prev isn't RCU safe, walk ->next till the end */
3153 pos = NULL; 3166 pos = NULL;
3154 cgroup_for_each_child(tmp, last) 3167 css_for_each_child(tmp, last)
3155 pos = tmp; 3168 pos = tmp;
3156 } while (pos); 3169 } while (pos);
3157 3170
3158 return last; 3171 return last;
3159} 3172}
3160EXPORT_SYMBOL_GPL(cgroup_rightmost_descendant); 3173EXPORT_SYMBOL_GPL(css_rightmost_descendant);
3161 3174
3162static struct cgroup *cgroup_leftmost_descendant(struct cgroup *pos) 3175static struct cgroup_subsys_state *
3176css_leftmost_descendant(struct cgroup_subsys_state *pos)
3163{ 3177{
3164 struct cgroup *last; 3178 struct cgroup_subsys_state *last;
3165 3179
3166 do { 3180 do {
3167 last = pos; 3181 last = pos;
3168 pos = cgroup_next_child(NULL, pos); 3182 pos = css_next_child(NULL, pos);
3169 } while (pos); 3183 } while (pos);
3170 3184
3171 return last; 3185 return last;
3172} 3186}
3173 3187
3174/** 3188/**
3175 * cgroup_next_descendant_post - find the next descendant for post-order walk 3189 * css_next_descendant_post - find the next descendant for post-order walk
3176 * @pos: the current position (%NULL to initiate traversal) 3190 * @pos: the current position (%NULL to initiate traversal)
3177 * @cgroup: cgroup whose descendants to walk 3191 * @root: css whose descendants to walk
3178 * 3192 *
3179 * To be used by cgroup_for_each_descendant_post(). Find the next 3193 * To be used by css_for_each_descendant_post(). Find the next descendant
3180 * descendant to visit for post-order traversal of @cgroup's descendants. 3194 * to visit for post-order traversal of @root's descendants.
3181 * 3195 *
3182 * While this function requires RCU read locking, it doesn't require the 3196 * While this function requires RCU read locking, it doesn't require the
3183 * whole traversal to be contained in a single RCU critical section. This 3197 * whole traversal to be contained in a single RCU critical section. This
3184 * function will return the correct next descendant as long as both @pos 3198 * function will return the correct next descendant as long as both @pos
3185 * and @cgroup are accessible and @pos is a descendant of @cgroup. 3199 * and @cgroup are accessible and @pos is a descendant of @cgroup.
3186 */ 3200 */
3187struct cgroup *cgroup_next_descendant_post(struct cgroup *pos, 3201struct cgroup_subsys_state *
3188 struct cgroup *cgroup) 3202css_next_descendant_post(struct cgroup_subsys_state *pos,
3203 struct cgroup_subsys_state *root)
3189{ 3204{
3190 struct cgroup *next; 3205 struct cgroup_subsys_state *next;
3191 3206
3192 WARN_ON_ONCE(!rcu_read_lock_held()); 3207 WARN_ON_ONCE(!rcu_read_lock_held());
3193 3208
3194 /* if first iteration, visit the leftmost descendant */ 3209 /* if first iteration, visit the leftmost descendant */
3195 if (!pos) { 3210 if (!pos) {
3196 next = cgroup_leftmost_descendant(cgroup); 3211 next = css_leftmost_descendant(root);
3197 return next != cgroup ? next : NULL; 3212 return next != root ? next : NULL;
3198 } 3213 }
3199 3214
3200 /* if there's an unvisited sibling, visit its leftmost descendant */ 3215 /* if there's an unvisited sibling, visit its leftmost descendant */
3201 next = cgroup_next_child(pos, pos->parent); 3216 next = css_next_child(pos, css_parent(pos));
3202 if (next) 3217 if (next)
3203 return cgroup_leftmost_descendant(next); 3218 return css_leftmost_descendant(next);
3204 3219
3205 /* no sibling left, visit parent */ 3220 /* no sibling left, visit parent */
3206 next = pos->parent; 3221 next = css_parent(pos);
3207 return next != cgroup ? next : NULL; 3222 return next != root ? next : NULL;
3208} 3223}
3209EXPORT_SYMBOL_GPL(cgroup_next_descendant_post); 3224EXPORT_SYMBOL_GPL(css_next_descendant_post);
3210 3225
3211void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it) 3226void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it)
3212 __acquires(css_set_lock) 3227 __acquires(css_set_lock)
@@ -4549,9 +4564,9 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
4549 /* 4564 /*
4550 * Mark @cgrp dead. This prevents further task migration and child 4565 * Mark @cgrp dead. This prevents further task migration and child
4551 * creation by disabling cgroup_lock_live_group(). Note that 4566 * creation by disabling cgroup_lock_live_group(). Note that
4552 * CGRP_DEAD assertion is depended upon by cgroup_next_child() to 4567 * CGRP_DEAD assertion is depended upon by css_next_child() to
4553 * resume iteration after dropping RCU read lock. See 4568 * resume iteration after dropping RCU read lock. See
4554 * cgroup_next_child() for details. 4569 * css_next_child() for details.
4555 */ 4570 */
4556 set_bit(CGRP_DEAD, &cgrp->flags); 4571 set_bit(CGRP_DEAD, &cgrp->flags);
4557 4572
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 19613ba51444..98ca48d9ceb4 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -50,11 +50,6 @@ static inline struct freezer *css_freezer(struct cgroup_subsys_state *css)
50 return css ? container_of(css, struct freezer, css) : NULL; 50 return css ? container_of(css, struct freezer, css) : NULL;
51} 51}
52 52
53static inline struct freezer *cgroup_freezer(struct cgroup *cgroup)
54{
55 return css_freezer(cgroup_css(cgroup, freezer_subsys_id));
56}
57
58static inline struct freezer *task_freezer(struct task_struct *task) 53static inline struct freezer *task_freezer(struct task_struct *task)
59{ 54{
60 return css_freezer(task_css(task, freezer_subsys_id)); 55 return css_freezer(task_css(task, freezer_subsys_id));
@@ -120,7 +115,7 @@ static int freezer_css_online(struct cgroup_subsys_state *css)
120 /* 115 /*
121 * The following double locking and freezing state inheritance 116 * The following double locking and freezing state inheritance
122 * guarantee that @cgroup can never escape ancestors' freezing 117 * guarantee that @cgroup can never escape ancestors' freezing
123 * states. See cgroup_for_each_descendant_pre() for details. 118 * states. See css_for_each_descendant_pre() for details.
124 */ 119 */
125 if (parent) 120 if (parent)
126 spin_lock_irq(&parent->lock); 121 spin_lock_irq(&parent->lock);
@@ -262,7 +257,7 @@ out:
262static void update_if_frozen(struct cgroup_subsys_state *css) 257static void update_if_frozen(struct cgroup_subsys_state *css)
263{ 258{
264 struct freezer *freezer = css_freezer(css); 259 struct freezer *freezer = css_freezer(css);
265 struct cgroup *pos; 260 struct cgroup_subsys_state *pos;
266 struct cgroup_iter it; 261 struct cgroup_iter it;
267 struct task_struct *task; 262 struct task_struct *task;
268 263
@@ -275,8 +270,8 @@ static void update_if_frozen(struct cgroup_subsys_state *css)
275 goto out_unlock; 270 goto out_unlock;
276 271
277 /* are all (live) children frozen? */ 272 /* are all (live) children frozen? */
278 cgroup_for_each_child(pos, css->cgroup) { 273 css_for_each_child(pos, css) {
279 struct freezer *child = cgroup_freezer(pos); 274 struct freezer *child = css_freezer(pos);
280 275
281 if ((child->state & CGROUP_FREEZER_ONLINE) && 276 if ((child->state & CGROUP_FREEZER_ONLINE) &&
282 !(child->state & CGROUP_FROZEN)) 277 !(child->state & CGROUP_FROZEN))
@@ -309,13 +304,13 @@ out_unlock:
309static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft, 304static int freezer_read(struct cgroup_subsys_state *css, struct cftype *cft,
310 struct seq_file *m) 305 struct seq_file *m)
311{ 306{
312 struct cgroup *pos; 307 struct cgroup_subsys_state *pos;
313 308
314 rcu_read_lock(); 309 rcu_read_lock();
315 310
316 /* update states bottom-up */ 311 /* update states bottom-up */
317 cgroup_for_each_descendant_post(pos, css->cgroup) 312 css_for_each_descendant_post(pos, css)
318 update_if_frozen(cgroup_css(pos, freezer_subsys_id)); 313 update_if_frozen(pos);
319 update_if_frozen(css); 314 update_if_frozen(css);
320 315
321 rcu_read_unlock(); 316 rcu_read_unlock();
@@ -396,7 +391,7 @@ static void freezer_apply_state(struct freezer *freezer, bool freeze,
396 */ 391 */
397static void freezer_change_state(struct freezer *freezer, bool freeze) 392static void freezer_change_state(struct freezer *freezer, bool freeze)
398{ 393{
399 struct cgroup *pos; 394 struct cgroup_subsys_state *pos;
400 395
401 /* update @freezer */ 396 /* update @freezer */
402 spin_lock_irq(&freezer->lock); 397 spin_lock_irq(&freezer->lock);
@@ -409,8 +404,8 @@ static void freezer_change_state(struct freezer *freezer, bool freeze)
409 * CGROUP_FREEZING_PARENT. 404 * CGROUP_FREEZING_PARENT.
410 */ 405 */
411 rcu_read_lock(); 406 rcu_read_lock();
412 cgroup_for_each_descendant_pre(pos, freezer->css.cgroup) { 407 css_for_each_descendant_pre(pos, &freezer->css) {
413 struct freezer *pos_f = cgroup_freezer(pos); 408 struct freezer *pos_f = css_freezer(pos);
414 struct freezer *parent = parent_freezer(pos_f); 409 struct freezer *parent = parent_freezer(pos_f);
415 410
416 /* 411 /*
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 89b76e1d3aa1..be4f5036ea5e 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -210,29 +210,29 @@ static struct cpuset top_cpuset = {
210/** 210/**
211 * cpuset_for_each_child - traverse online children of a cpuset 211 * cpuset_for_each_child - traverse online children of a cpuset
212 * @child_cs: loop cursor pointing to the current child 212 * @child_cs: loop cursor pointing to the current child
213 * @pos_cgrp: used for iteration 213 * @pos_css: used for iteration
214 * @parent_cs: target cpuset to walk children of 214 * @parent_cs: target cpuset to walk children of
215 * 215 *
216 * Walk @child_cs through the online children of @parent_cs. Must be used 216 * Walk @child_cs through the online children of @parent_cs. Must be used
217 * with RCU read locked. 217 * with RCU read locked.
218 */ 218 */
219#define cpuset_for_each_child(child_cs, pos_cgrp, parent_cs) \ 219#define cpuset_for_each_child(child_cs, pos_css, parent_cs) \
220 cgroup_for_each_child((pos_cgrp), (parent_cs)->css.cgroup) \ 220 css_for_each_child((pos_css), &(parent_cs)->css) \
221 if (is_cpuset_online(((child_cs) = cgroup_cs((pos_cgrp))))) 221 if (is_cpuset_online(((child_cs) = css_cs((pos_css)))))
222 222
223/** 223/**
224 * cpuset_for_each_descendant_pre - pre-order walk of a cpuset's descendants 224 * cpuset_for_each_descendant_pre - pre-order walk of a cpuset's descendants
225 * @des_cs: loop cursor pointing to the current descendant 225 * @des_cs: loop cursor pointing to the current descendant
226 * @pos_cgrp: used for iteration 226 * @pos_css: used for iteration
227 * @root_cs: target cpuset to walk ancestor of 227 * @root_cs: target cpuset to walk ancestor of
228 * 228 *
229 * Walk @des_cs through the online descendants of @root_cs. Must be used 229 * Walk @des_cs through the online descendants of @root_cs. Must be used
230 * with RCU read locked. The caller may modify @pos_cgrp by calling 230 * with RCU read locked. The caller may modify @pos_css by calling
231 * cgroup_rightmost_descendant() to skip subtree. 231 * css_rightmost_descendant() to skip subtree.
232 */ 232 */
233#define cpuset_for_each_descendant_pre(des_cs, pos_cgrp, root_cs) \ 233#define cpuset_for_each_descendant_pre(des_cs, pos_css, root_cs) \
234 cgroup_for_each_descendant_pre((pos_cgrp), (root_cs)->css.cgroup) \ 234 css_for_each_descendant_pre((pos_css), &(root_cs)->css) \
235 if (is_cpuset_online(((des_cs) = cgroup_cs((pos_cgrp))))) 235 if (is_cpuset_online(((des_cs) = css_cs((pos_css)))))
236 236
237/* 237/*
238 * There are two global mutexes guarding cpuset structures - cpuset_mutex 238 * There are two global mutexes guarding cpuset structures - cpuset_mutex
@@ -430,7 +430,7 @@ static void free_trial_cpuset(struct cpuset *trial)
430 430
431static int validate_change(struct cpuset *cur, struct cpuset *trial) 431static int validate_change(struct cpuset *cur, struct cpuset *trial)
432{ 432{
433 struct cgroup *cgrp; 433 struct cgroup_subsys_state *css;
434 struct cpuset *c, *par; 434 struct cpuset *c, *par;
435 int ret; 435 int ret;
436 436
@@ -438,7 +438,7 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
438 438
439 /* Each of our child cpusets must be a subset of us */ 439 /* Each of our child cpusets must be a subset of us */
440 ret = -EBUSY; 440 ret = -EBUSY;
441 cpuset_for_each_child(c, cgrp, cur) 441 cpuset_for_each_child(c, css, cur)
442 if (!is_cpuset_subset(c, trial)) 442 if (!is_cpuset_subset(c, trial))
443 goto out; 443 goto out;
444 444
@@ -459,7 +459,7 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
459 * overlap 459 * overlap
460 */ 460 */
461 ret = -EINVAL; 461 ret = -EINVAL;
462 cpuset_for_each_child(c, cgrp, par) { 462 cpuset_for_each_child(c, css, par) {
463 if ((is_cpu_exclusive(trial) || is_cpu_exclusive(c)) && 463 if ((is_cpu_exclusive(trial) || is_cpu_exclusive(c)) &&
464 c != cur && 464 c != cur &&
465 cpumask_intersects(trial->cpus_allowed, c->cpus_allowed)) 465 cpumask_intersects(trial->cpus_allowed, c->cpus_allowed))
@@ -508,13 +508,13 @@ static void update_domain_attr_tree(struct sched_domain_attr *dattr,
508 struct cpuset *root_cs) 508 struct cpuset *root_cs)
509{ 509{
510 struct cpuset *cp; 510 struct cpuset *cp;
511 struct cgroup *pos_cgrp; 511 struct cgroup_subsys_state *pos_css;
512 512
513 rcu_read_lock(); 513 rcu_read_lock();
514 cpuset_for_each_descendant_pre(cp, pos_cgrp, root_cs) { 514 cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
515 /* skip the whole subtree if @cp doesn't have any CPU */ 515 /* skip the whole subtree if @cp doesn't have any CPU */
516 if (cpumask_empty(cp->cpus_allowed)) { 516 if (cpumask_empty(cp->cpus_allowed)) {
517 pos_cgrp = cgroup_rightmost_descendant(pos_cgrp); 517 pos_css = css_rightmost_descendant(pos_css);
518 continue; 518 continue;
519 } 519 }
520 520
@@ -589,7 +589,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
589 struct sched_domain_attr *dattr; /* attributes for custom domains */ 589 struct sched_domain_attr *dattr; /* attributes for custom domains */
590 int ndoms = 0; /* number of sched domains in result */ 590 int ndoms = 0; /* number of sched domains in result */
591 int nslot; /* next empty doms[] struct cpumask slot */ 591 int nslot; /* next empty doms[] struct cpumask slot */
592 struct cgroup *pos_cgrp; 592 struct cgroup_subsys_state *pos_css;
593 593
594 doms = NULL; 594 doms = NULL;
595 dattr = NULL; 595 dattr = NULL;
@@ -618,7 +618,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
618 csn = 0; 618 csn = 0;
619 619
620 rcu_read_lock(); 620 rcu_read_lock();
621 cpuset_for_each_descendant_pre(cp, pos_cgrp, &top_cpuset) { 621 cpuset_for_each_descendant_pre(cp, pos_css, &top_cpuset) {
622 /* 622 /*
623 * Continue traversing beyond @cp iff @cp has some CPUs and 623 * Continue traversing beyond @cp iff @cp has some CPUs and
624 * isn't load balancing. The former is obvious. The 624 * isn't load balancing. The former is obvious. The
@@ -635,7 +635,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
635 csa[csn++] = cp; 635 csa[csn++] = cp;
636 636
637 /* skip @cp's subtree */ 637 /* skip @cp's subtree */
638 pos_cgrp = cgroup_rightmost_descendant(pos_cgrp); 638 pos_css = css_rightmost_descendant(pos_css);
639 } 639 }
640 rcu_read_unlock(); 640 rcu_read_unlock();
641 641
@@ -886,16 +886,16 @@ static void update_tasks_cpumask_hier(struct cpuset *root_cs,
886 bool update_root, struct ptr_heap *heap) 886 bool update_root, struct ptr_heap *heap)
887{ 887{
888 struct cpuset *cp; 888 struct cpuset *cp;
889 struct cgroup *pos_cgrp; 889 struct cgroup_subsys_state *pos_css;
890 890
891 if (update_root) 891 if (update_root)
892 update_tasks_cpumask(root_cs, heap); 892 update_tasks_cpumask(root_cs, heap);
893 893
894 rcu_read_lock(); 894 rcu_read_lock();
895 cpuset_for_each_descendant_pre(cp, pos_cgrp, root_cs) { 895 cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
896 /* skip the whole subtree if @cp have some CPU */ 896 /* skip the whole subtree if @cp have some CPU */
897 if (!cpumask_empty(cp->cpus_allowed)) { 897 if (!cpumask_empty(cp->cpus_allowed)) {
898 pos_cgrp = cgroup_rightmost_descendant(pos_cgrp); 898 pos_css = css_rightmost_descendant(pos_css);
899 continue; 899 continue;
900 } 900 }
901 if (!css_tryget(&cp->css)) 901 if (!css_tryget(&cp->css))
@@ -1143,16 +1143,16 @@ static void update_tasks_nodemask_hier(struct cpuset *root_cs,
1143 bool update_root, struct ptr_heap *heap) 1143 bool update_root, struct ptr_heap *heap)
1144{ 1144{
1145 struct cpuset *cp; 1145 struct cpuset *cp;
1146 struct cgroup *pos_cgrp; 1146 struct cgroup_subsys_state *pos_css;
1147 1147
1148 if (update_root) 1148 if (update_root)
1149 update_tasks_nodemask(root_cs, heap); 1149 update_tasks_nodemask(root_cs, heap);
1150 1150
1151 rcu_read_lock(); 1151 rcu_read_lock();
1152 cpuset_for_each_descendant_pre(cp, pos_cgrp, root_cs) { 1152 cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
1153 /* skip the whole subtree if @cp have some CPU */ 1153 /* skip the whole subtree if @cp have some CPU */
1154 if (!nodes_empty(cp->mems_allowed)) { 1154 if (!nodes_empty(cp->mems_allowed)) {
1155 pos_cgrp = cgroup_rightmost_descendant(pos_cgrp); 1155 pos_css = css_rightmost_descendant(pos_css);
1156 continue; 1156 continue;
1157 } 1157 }
1158 if (!css_tryget(&cp->css)) 1158 if (!css_tryget(&cp->css))
@@ -1973,7 +1973,7 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
1973 struct cpuset *cs = css_cs(css); 1973 struct cpuset *cs = css_cs(css);
1974 struct cpuset *parent = parent_cs(cs); 1974 struct cpuset *parent = parent_cs(cs);
1975 struct cpuset *tmp_cs; 1975 struct cpuset *tmp_cs;
1976 struct cgroup *pos_cgrp; 1976 struct cgroup_subsys_state *pos_css;
1977 1977
1978 if (!parent) 1978 if (!parent)
1979 return 0; 1979 return 0;
@@ -2005,7 +2005,7 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
2005 * (and likewise for mems) to the new cgroup. 2005 * (and likewise for mems) to the new cgroup.
2006 */ 2006 */
2007 rcu_read_lock(); 2007 rcu_read_lock();
2008 cpuset_for_each_child(tmp_cs, pos_cgrp, parent) { 2008 cpuset_for_each_child(tmp_cs, pos_css, parent) {
2009 if (is_mem_exclusive(tmp_cs) || is_cpu_exclusive(tmp_cs)) { 2009 if (is_mem_exclusive(tmp_cs) || is_cpu_exclusive(tmp_cs)) {
2010 rcu_read_unlock(); 2010 rcu_read_unlock();
2011 goto out_unlock; 2011 goto out_unlock;
@@ -2252,10 +2252,10 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
2252 /* if cpus or mems changed, we need to propagate to descendants */ 2252 /* if cpus or mems changed, we need to propagate to descendants */
2253 if (cpus_updated || mems_updated) { 2253 if (cpus_updated || mems_updated) {
2254 struct cpuset *cs; 2254 struct cpuset *cs;
2255 struct cgroup *pos_cgrp; 2255 struct cgroup_subsys_state *pos_css;
2256 2256
2257 rcu_read_lock(); 2257 rcu_read_lock();
2258 cpuset_for_each_descendant_pre(cs, pos_cgrp, &top_cpuset) { 2258 cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) {
2259 if (!css_tryget(&cs->css)) 2259 if (!css_tryget(&cs->css))
2260 continue; 2260 continue;
2261 rcu_read_unlock(); 2261 rcu_read_unlock();