@@ -2355,38 +2355,38 @@ struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset,
2355
2355
}
2356
2356
2357
2357
/**
2358
- * cgroup_taskset_migrate - migrate a taskset to a cgroup
2358
+ * cgroup_taskset_migrate - migrate a taskset
2359
2359
* @tset: taget taskset
2360
- * @dst_cgrp: destination cgroup
2360
+ * @root: cgroup root the migration is taking place on
2361
2361
*
2362
- * Migrate tasks in @tset to @dst_cgrp. This function fails iff one of the
2363
- * ->can_attach callbacks fails and guarantees that either all or none of
2364
- * the tasks in @tset are migrated. @tset is consumed regardless of
2365
- * success.
2362
+ * Migrate tasks in @tset as setup by migration preparation functions.
2363
+ * This function fails iff one of the ->can_attach callbacks fails and
2364
+ * guarantees that either all or none of the tasks in @tset are migrated.
2365
+ * @tset is consumed regardless of success.
2366
2366
*/
2367
2367
static int cgroup_taskset_migrate (struct cgroup_taskset * tset ,
2368
- struct cgroup * dst_cgrp )
2368
+ struct cgroup_root * root )
2369
2369
{
2370
- struct cgroup_subsys_state * css , * failed_css = NULL ;
2370
+ struct cgroup_subsys * ss ;
2371
2371
struct task_struct * task , * tmp_task ;
2372
2372
struct css_set * cset , * tmp_cset ;
2373
- int i , ret ;
2373
+ int ssid , failed_ssid , ret ;
2374
2374
2375
2375
/* methods shouldn't be called if no task is actually migrating */
2376
2376
if (list_empty (& tset -> src_csets ))
2377
2377
return 0 ;
2378
2378
2379
2379
/* check that we can legitimately attach to the cgroup */
2380
- for_each_e_css ( css , i , dst_cgrp ) {
2381
- if (css -> ss -> can_attach ) {
2382
- tset -> ssid = i ;
2383
- ret = css -> ss -> can_attach (tset );
2380
+ do_each_subsys_mask ( ss , ssid , root -> subsys_mask ) {
2381
+ if (ss -> can_attach ) {
2382
+ tset -> ssid = ssid ;
2383
+ ret = ss -> can_attach (tset );
2384
2384
if (ret ) {
2385
- failed_css = css ;
2385
+ failed_ssid = ssid ;
2386
2386
goto out_cancel_attach ;
2387
2387
}
2388
2388
}
2389
- }
2389
+ } while_each_subsys_mask ();
2390
2390
2391
2391
/*
2392
2392
* Now that we're guaranteed success, proceed to move all tasks to
@@ -2413,25 +2413,25 @@ static int cgroup_taskset_migrate(struct cgroup_taskset *tset,
2413
2413
*/
2414
2414
tset -> csets = & tset -> dst_csets ;
2415
2415
2416
- for_each_e_css ( css , i , dst_cgrp ) {
2417
- if (css -> ss -> attach ) {
2418
- tset -> ssid = i ;
2419
- css -> ss -> attach (tset );
2416
+ do_each_subsys_mask ( ss , ssid , root -> subsys_mask ) {
2417
+ if (ss -> attach ) {
2418
+ tset -> ssid = ssid ;
2419
+ ss -> attach (tset );
2420
2420
}
2421
- }
2421
+ } while_each_subsys_mask ();
2422
2422
2423
2423
ret = 0 ;
2424
2424
goto out_release_tset ;
2425
2425
2426
2426
out_cancel_attach :
2427
- for_each_e_css ( css , i , dst_cgrp ) {
2428
- if (css == failed_css )
2427
+ do_each_subsys_mask ( ss , ssid , root -> subsys_mask ) {
2428
+ if (ssid == failed_ssid )
2429
2429
break ;
2430
- if (css -> ss -> cancel_attach ) {
2431
- tset -> ssid = i ;
2432
- css -> ss -> cancel_attach (tset );
2430
+ if (ss -> cancel_attach ) {
2431
+ tset -> ssid = ssid ;
2432
+ ss -> cancel_attach (tset );
2433
2433
}
2434
- }
2434
+ } while_each_subsys_mask ();
2435
2435
out_release_tset :
2436
2436
spin_lock_bh (& css_set_lock );
2437
2437
list_splice_init (& tset -> dst_csets , & tset -> src_csets );
@@ -2586,11 +2586,11 @@ static int cgroup_migrate_prepare_dst(struct cgroup *dst_cgrp,
2586
2586
* cgroup_migrate - migrate a process or task to a cgroup
2587
2587
* @leader: the leader of the process or the task to migrate
2588
2588
* @threadgroup: whether @leader points to the whole process or a single task
2589
- * @cgrp: the destination cgroup
2589
+ * @root: cgroup root migration is taking place on
2590
2590
*
2591
- * Migrate a process or task denoted by @leader to @cgrp . If migrating a
2592
- * process, the caller must be holding cgroup_threadgroup_rwsem. The
2593
- * caller is also responsible for invoking cgroup_migrate_add_src() and
2591
+ * Migrate a process or task denoted by @leader. If migrating a process,
2592
+ * the caller must be holding cgroup_threadgroup_rwsem. The caller is also
2593
+ * responsible for invoking cgroup_migrate_add_src() and
2594
2594
* cgroup_migrate_prepare_dst() on the targets before invoking this
2595
2595
* function and following up with cgroup_migrate_finish().
2596
2596
*
@@ -2601,7 +2601,7 @@ static int cgroup_migrate_prepare_dst(struct cgroup *dst_cgrp,
2601
2601
* actually starting migrating.
2602
2602
*/
2603
2603
static int cgroup_migrate (struct task_struct * leader , bool threadgroup ,
2604
- struct cgroup * cgrp )
2604
+ struct cgroup_root * root )
2605
2605
{
2606
2606
struct cgroup_taskset tset = CGROUP_TASKSET_INIT (tset );
2607
2607
struct task_struct * task ;
@@ -2622,7 +2622,7 @@ static int cgroup_migrate(struct task_struct *leader, bool threadgroup,
2622
2622
rcu_read_unlock ();
2623
2623
spin_unlock_bh (& css_set_lock );
2624
2624
2625
- return cgroup_taskset_migrate (& tset , cgrp );
2625
+ return cgroup_taskset_migrate (& tset , root );
2626
2626
}
2627
2627
2628
2628
/**
@@ -2659,7 +2659,7 @@ static int cgroup_attach_task(struct cgroup *dst_cgrp,
2659
2659
/* prepare dst csets and commit */
2660
2660
ret = cgroup_migrate_prepare_dst (dst_cgrp , & preloaded_csets );
2661
2661
if (!ret )
2662
- ret = cgroup_migrate (leader , threadgroup , dst_cgrp );
2662
+ ret = cgroup_migrate (leader , threadgroup , dst_cgrp -> root );
2663
2663
2664
2664
cgroup_migrate_finish (& preloaded_csets );
2665
2665
return ret ;
@@ -2934,7 +2934,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp)
2934
2934
}
2935
2935
spin_unlock_bh (& css_set_lock );
2936
2936
2937
- ret = cgroup_taskset_migrate (& tset , cgrp );
2937
+ ret = cgroup_taskset_migrate (& tset , cgrp -> root );
2938
2938
out_finish :
2939
2939
cgroup_migrate_finish (& preloaded_csets );
2940
2940
percpu_up_write (& cgroup_threadgroup_rwsem );
@@ -4172,7 +4172,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
4172
4172
css_task_iter_end (& it );
4173
4173
4174
4174
if (task ) {
4175
- ret = cgroup_migrate (task , false, to );
4175
+ ret = cgroup_migrate (task , false, to -> root );
4176
4176
put_task_struct (task );
4177
4177
}
4178
4178
} while (task && !ret );
0 commit comments