Skip to content

Commit bbe5ab8

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Simplify setsched decision check in task iteration loop of cpuset_can_attach()
Centralize the check required to run security_task_setscheduler() in the task iteration loop of cpuset_can_attach() outside of the loop as it has no dependency on the characteristics of the tasks themselves. There is no functional change. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 4c56a8a commit bbe5ab8

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

kernel/cgroup/cpuset.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,7 @@ static int cpuset_can_attach(struct cgroup_taskset *tset)
29882988
struct cgroup_subsys_state *css;
29892989
struct cpuset *cs, *oldcs;
29902990
struct task_struct *task;
2991-
bool cpus_updated, mems_updated;
2991+
bool setsched_check;
29922992
int ret;
29932993

29942994
/* used later by cpuset_attach() */
@@ -3003,20 +3003,21 @@ static int cpuset_can_attach(struct cgroup_taskset *tset)
30033003
if (ret)
30043004
goto out_unlock;
30053005

3006-
cpus_updated = !cpumask_equal(cs->effective_cpus, oldcs->effective_cpus);
3007-
mems_updated = !nodes_equal(cs->effective_mems, oldcs->effective_mems);
3006+
/*
3007+
* Skip rights over task setsched check in v2 when nothing changes,
3008+
* migration permission derives from hierarchy ownership in
3009+
* cgroup_procs_write_permission()).
3010+
*/
3011+
setsched_check = !cpuset_v2() ||
3012+
!cpumask_equal(cs->effective_cpus, oldcs->effective_cpus) ||
3013+
!nodes_equal(cs->effective_mems, oldcs->effective_mems);
30083014

30093015
cgroup_taskset_for_each(task, css, tset) {
30103016
ret = task_can_attach(task);
30113017
if (ret)
30123018
goto out_unlock;
30133019

3014-
/*
3015-
* Skip rights over task check in v2 when nothing changes,
3016-
* migration permission derives from hierarchy ownership in
3017-
* cgroup_procs_write_permission()).
3018-
*/
3019-
if (!cpuset_v2() || (cpus_updated || mems_updated)) {
3020+
if (setsched_check) {
30203021
ret = security_task_setscheduler(task);
30213022
if (ret)
30223023
goto out_unlock;

0 commit comments

Comments
 (0)