Skip to content

Commit 6da580e

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Don't allow creation of local partition over a remote one
Currently, we don't allow the creation of a remote partition underneath another local or remote partition. However, it is currently possible to create a new local partition with an existing remote partition underneath it if top_cpuset is the parent. However, the current cpuset code does not set the effective exclusive CPUs correctly to account for those that are taken by the remote partition. Changing the code to properly account for those remote partition CPUs under all possible circumstances can be complex. It is much easier to not allow such a configuration which is not that useful. So forbid that by making sure that exclusive_cpus mask doesn't overlap with subpartitions_cpus and invalidate the partition if that happens. Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent f62a5d3 commit 6da580e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

kernel/cgroup/cpuset-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum prs_errcode {
3333
PERR_CPUSEMPTY,
3434
PERR_HKEEPING,
3535
PERR_ACCESS,
36+
PERR_REMOTE,
3637
};
3738

3839
/* bits in struct cpuset flags field */

kernel/cgroup/cpuset.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static const char * const perr_strings[] = {
6161
[PERR_CPUSEMPTY] = "cpuset.cpus and cpuset.cpus.exclusive are empty",
6262
[PERR_HKEEPING] = "partition config conflicts with housekeeping setup",
6363
[PERR_ACCESS] = "Enable partition not permitted",
64+
[PERR_REMOTE] = "Have remote partition underneath",
6465
};
6566

6667
/*
@@ -2855,6 +2856,19 @@ static int update_prstate(struct cpuset *cs, int new_prs)
28552856
goto out;
28562857
}
28572858

2859+
/*
2860+
* We don't support the creation of a new local partition with
2861+
* a remote partition underneath it. This unsupported
2862+
* setting can happen only if parent is the top_cpuset because
2863+
* a remote partition cannot be created underneath an existing
2864+
* local or remote partition.
2865+
*/
2866+
if ((parent == &top_cpuset) &&
2867+
cpumask_intersects(cs->exclusive_cpus, subpartitions_cpus)) {
2868+
err = PERR_REMOTE;
2869+
goto out;
2870+
}
2871+
28582872
/*
28592873
* If parent is valid partition, enable local partiion.
28602874
* Otherwise, enable a remote partition.

0 commit comments

Comments
 (0)