Skip to content

Commit 18bc242

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Streamline rm_siblings_excl_cpus()
If exclusive_cpus is set, effective_xcpus must be a subset of exclusive_cpus. Currently, rm_siblings_excl_cpus() checks both exclusive_cpus and effective_xcpus consecutively. It is simpler to check only exclusive_cpus if non-empty or just effective_xcpus otherwise. No functional change is expected. Signed-off-by: Waiman Long <longman@redhat.com> Reviewed-by: Chen Ridong <chenridong@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 269679b commit 18bc242

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

kernel/cgroup/cpuset.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,23 +1355,29 @@ static int rm_siblings_excl_cpus(struct cpuset *parent, struct cpuset *cs,
13551355
int retval = 0;
13561356

13571357
if (cpumask_empty(excpus))
1358-
return retval;
1358+
return 0;
13591359

13601360
/*
1361-
* Exclude exclusive CPUs from siblings
1361+
* Remove exclusive CPUs from siblings
13621362
*/
13631363
rcu_read_lock();
13641364
cpuset_for_each_child(sibling, css, parent) {
1365+
struct cpumask *sibling_xcpus;
1366+
13651367
if (sibling == cs)
13661368
continue;
13671369

1368-
if (cpumask_intersects(excpus, sibling->exclusive_cpus)) {
1369-
cpumask_andnot(excpus, excpus, sibling->exclusive_cpus);
1370-
retval++;
1371-
continue;
1372-
}
1373-
if (cpumask_intersects(excpus, sibling->effective_xcpus)) {
1374-
cpumask_andnot(excpus, excpus, sibling->effective_xcpus);
1370+
/*
1371+
* If exclusive_cpus is defined, effective_xcpus will always
1372+
* be a subset. Otherwise, effective_xcpus will only be set
1373+
* in a valid partition root.
1374+
*/
1375+
sibling_xcpus = cpumask_empty(sibling->exclusive_cpus)
1376+
? sibling->effective_xcpus
1377+
: sibling->exclusive_cpus;
1378+
1379+
if (cpumask_intersects(excpus, sibling_xcpus)) {
1380+
cpumask_andnot(excpus, excpus, sibling_xcpus);
13751381
retval++;
13761382
}
13771383
}

0 commit comments

Comments
 (0)