[PATCH] cgroup/cpuset: Make cpuset.cpus.effective independent of cpuset.cpus

Petr Malat
2024-03-21T21:39:58Z

Requiring cpuset.cpus.effective to be a subset of cpuset.cpus makes it
hard to use as one is forced to configure cpuset.cpus of current and all
ancestor cgroups, which requires a knowledge about all other units
sharing the same cgroup subtree. Also, it doesn't allow using empty
cpuset.cpus.

Do not require cpuset.cpus.effective to be a subset of cpuset.cpus and
create remote cgroup only if cpuset.cpus is empty, to make it easier for
the user to control which cgroup is being created.

Signed-off-by: Petr Malat <oss@malat.biz>
---
kernel/cgroup/cpuset.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index b8000240a1476..72ec7ef0eabc8 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1459,7 +1459,7 @@ static bool compute_effective_exclusive_cpumask(struct cpuset *cs,
xcpus = cs->effective_xcpus;

if (!cpumask_empty(cs->exclusive_cpus))
- cpumask_and(xcpus, cs->exclusive_cpus, cs->cpus_allowed);
+ cpumask_copy(xcpus, cs->exclusive_cpus);
else
cpumask_copy(xcpus, cs->cpus_allowed);

@@ -2987,18 +2987,13 @@ static int update_prstate(struct cpuset *cs, int new_prs)
* cpus_allowed cannot be empty.
*/
if (cpumask_empty(cs->cpus_allowed)) {
+ if (remote_partition_enable(cs, &tmpmask))
+ goto out;
err = PERR_CPUSEMPTY;
- goto out;
+ } else {
+ err = update_parent_effective_cpumask(cs,
+ partcmd_enable, NULL, &tmpmask);
}
-
- err = update_parent_effective_cpumask(cs, partcmd_enable,
- NULL, &tmpmask);
- /*
- * If an attempt to become local partition root fails,
- * try to become a remote partition root instead.
- */
- if (err && remote_partition_enable(cs, &tmpmask))
- err = 0;
} else if (old_prs && new_prs) {
/*
* A change in load balance state only, no change in cpumasks.
--
2.42.0