linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Odin Ugedal <odin@uged.al>
To: tj@kernel.org, lizefan.x@bytedance.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	Odin Ugedal <odin@uged.al>
Subject: [PATCH 2/2] cgroup2: cpuset: Always allow setting empty cpuset
Date: Tue, 13 Apr 2021 11:02:35 +0200	[thread overview]
Message-ID: <20210413090235.1903026-3-odin@uged.al> (raw)
In-Reply-To: <20210413090235.1903026-1-odin@uged.al>

Due to how cpuset works in v2, there is no need to disallow setting an
empty cpuset when tasks are attached. In v2, the effective cpuset of a
cgroup is the intersection between the effective value of the parent and
the cpuset.cpus value of the cgroup, with a fallback to the effective
parent value in case the intersection is an empty set.

Allowing this will make it easier to move the cpuset of a nested cgroup
hierarchy where multiple cgroup use the cpuset.cpus, since the current
solution is to manually update the cpuset of each cgroup when doing this,
causing it be quite complex to change. It also makes it possible to
disable cpuset for a populated cgroup (or one of its ancestors), without
having to manually write the effective value into cpuset.cpus.

This also applies in a similar manner on cpuset.mems.

Signed-off-by: Odin Ugedal <odin@uged.al>
---
 kernel/cgroup/cpuset.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index f543c4c6084a..33a55d461ec3 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -609,11 +609,12 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
 	}
 
 	/*
-	 * Cpusets with tasks - existing or newly being attached - can't
-	 * be changed to have empty cpus_allowed or mems_allowed.
+	 * On legacy hierarchy, cpusets with tasks - existing or newly being
+	 * attached - can't be changed to have empty cpus_allowed or
+	 * mems_allowed.
 	 */
 	ret = -ENOSPC;
-	if ((cgroup_is_populated(cur->css.cgroup) || cur->attach_in_progress)) {
+	if (!is_in_v2_mode() && (cgroup_is_populated(cur->css.cgroup) || cur->attach_in_progress)) {
 		if (!cpumask_empty(cur->cpus_allowed) &&
 		    cpumask_empty(trial->cpus_allowed))
 			goto out;
-- 
2.31.0


  parent reply	other threads:[~2021-04-13  9:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  9:02 [PATCH 0/2] Relax cpuset validation for cgroup v2 Odin Ugedal
2021-04-13  9:02 ` [PATCH 1/2] cgroup2: cpuset: Disable subset validation on set Odin Ugedal
2021-04-13  9:02 ` Odin Ugedal [this message]
2021-04-13 11:10 ` [PATCH 0/2] Relax cpuset validation for cgroup v2 Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210413090235.1903026-3-odin@uged.al \
    --to=odin@uged.al \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).