Skip to contentSkip to conversation

docs: cgroup-v2: Correct cpuset CPU descriptions

PATCH Superseded Guopeng Zhang 2 participants 6 messages Sep 22 1 message not in the archive

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover docs: cgroup-v2: Correct cpuset CPU descriptions

From: Guopeng Zhang <[email protected]>

The cpuset interface documentation says cpuset.cpus.isolated is empty unless an isolated partition exists, omitting CPUs isolated at boot with isolcpus=domain. Its cpuset.cpus.effective description also assumes CPUs come from the immediate parent and are normally a subset of cpuset.cpus, which is not always true for valid non-root partition roots.

Update both descriptions to match the existing behavior.

Changes since v1:
- Reword the cpuset.cpus.isolated description as suggested, while specifying the domain flag of isolcpus.
- Add examples of the cpuset.cpus.effective relationship for member or invalid partition roots and for valid partition roots.
- Add the Suggested-by tags and the Reviewed-by tag.

Guopeng Zhang (2):
docs: cgroup-v2: Describe boot-isolated CPUs in cpuset.cpus.isolated
docs: cgroup-v2: Describe effective CPUs of partition roots

 Documentation/admin-guide/cgroup-v2.rst | 59 ++++++++++++++++++++-----
 1 file changed, 48 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 docs: cgroup-v2: Describe boot-isolated CPUs in cpuset.cpus.isolated

From: Guopeng Zhang <[email protected]>

cpuset.cpus.isolated is documented as empty when no isolated partition exists. This is not true when CPUs are isolated at boot with isolcpus=domain. cpuset_init() adds those CPUs to the isolated mask, and isolcpus=<cpu-list> uses domain isolation by default. They remain listed after a partition using them is released.

Document the boot-isolated CPUs as well.

---
 Documentation/admin-guide/cgroup-v2.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +3 -2
index 2ec582985b5b..18a01ce4c334 100644
@@ -2626,8 +2626,9 @@ Cpuset Interface Files
 	A read-only and root cgroup only multiple values file.
 
 	This file shows the set of all isolated CPUs used in existing
-	isolated partitions. It will be empty if no isolated partition
-	is created.
+	isolated partitions or isolated at boot time via the "domain"
+	flag of "isolcpus". The latter remain listed even after any
+	partition using them is released.
 
   cpuset.cpus.partition
 	A read-write single value file which exists on non-root
Signature · 1 line
2.43.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Re: [PATCH v2 1/2] docs: cgroup-v2: Describe boot-isolated CPUs in cpuset.cpus.isolated

Quoted 45 lines · 在 2026/9/22 11:30, [email protected] 写道:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] cgroup: false claim in docs about boot-isolated CPUs after partition release --

commit 90dfc3bfef47bea738ec73e5d266a04ea1942e6d
Author: Guopeng Zhang <[email protected]>

docs: cgroup-v2: Describe boot-isolated CPUs in cpuset.cpus.isolated

This commit updates the documentation for cpuset.cpus.isolated to mention that boot-isolated CPUs are also listed. It claims these CPUs remain listed even after a partition using them is released.

Documentation/admin-guide/cgroup-v2.rst Cpuset Interface Files · line 2656

Quoted 13 lines
Documentation/admin-guide/cgroup-v2.rst +3 -2
index ebc683070521c..3e94fc88e7db9 100644
@@ -2651,8 +2651,9 @@ Cpuset Interface Files
 	A read-only and root cgroup only multiple values file.
 
 	This file shows the set of all isolated CPUs used in existing
-	isolated partitions. It will be empty if no isolated partition
-	is created.
+	isolated partitions or isolated at boot time via the "domain"
+	flag of "isolcpus". The latter remain listed even after any
+	partition using them is released.

[Severity: Medium]
Is this description accurate regarding what happens when a partition is released?

Looking at isolated_cpus_update() in kernel/cgroup/cpuset.c, when an isolated partition using these CPUs is released and changes state, the code executes this branch:

kernel/cgroup/cpuset.c:isolated_cpus_update() {
    ...
	} else {
		if (!cpumask_intersects(xcpus, isolated_cpus))
			return;
		cpumask_andnot(isolated_cpus, isolated_cpus, xcpus);
	}
    ...
}
Quoted 4 lines

Does this permanently clear the boot-isolated CPUs from the isolated_cpus mask, meaning they will no longer be listed when reading cpuset.cpus.isolated?

This is the old code. I already addressed this in the v1 discussion:

https://lore.kernel.org/all/[email protected]/

Thanks,
Guopeng

#4 lore raw

PATCH v2 2/2 docs: cgroup-v2: Describe effective CPUs of partition roots

In reply to Guopeng Zhang

From: Guopeng Zhang <[email protected]>

The cpuset.cpus.effective description says that the effective CPUs are granted by the parent and are normally a subset of cpuset.cpus. This does not always hold for a valid non-root partition root. Its effective CPUs are the active CPUs in cpuset.cpus.exclusive.effective after CPUs assigned to valid child partition roots are removed.

If cpuset.cpus.exclusive differs from cpuset.cpus, the effective CPUs may therefore be outside cpuset.cpus. Remote partitions also do not necessarily get their CPUs from their immediate parent.

---
 Documentation/admin-guide/cgroup-v2.rst | 56 ++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 10 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +46 -10
index 18a01ce4c334..d21bbae3312a 100644
@@ -2505,16 +2505,52 @@ Cpuset Interface Files
 	A read-only multiple values file which exists on all
 	cpuset-enabled cgroups.
 
-	It lists the onlined CPUs that are actually granted to this
-	cgroup by its parent.  These CPUs are allowed to be used by
-	tasks within the current cgroup.
-
-	If "cpuset.cpus" is empty, the "cpuset.cpus.effective" file shows
-	all the CPUs from the parent cgroup that can be available to
-	be used by this cgroup.  Otherwise, it should be a subset of
-	"cpuset.cpus" unless none of the CPUs listed in "cpuset.cpus"
-	can be granted.  In this case, it will be treated just like an
-	empty "cpuset.cpus".
+	It lists the active CPUs available to tasks in this cgroup.
+
+	For a cgroup that is not a valid partition root, an empty
+	"cpuset.cpus" makes "cpuset.cpus.effective" show all CPUs
+	available from the parent cgroup. Otherwise, it is a subset
+	of "cpuset.cpus" unless none of the requested CPUs can be
+	granted. In that case, it is treated like an empty
+	"cpuset.cpus".
+
+	For example::
+
+	  P (cpuset.cpus.effective=0-3)
+	  |
+	  +-- C0 (member):       cpuset.cpus=1-2
+	  |                      cpuset.cpus.effective=1-2
+	  +-- C1 (invalid root): cpuset.cpus=4-5
+	  |                      cpuset.cpus.effective=0-3
+	  \-- C2 (member):       cpuset.cpus=<empty>
+	                         cpuset.cpus.effective=0-3
+
+	C0 gets CPUs 1-2 because they are available from P.
+	None of C1's requested CPUs 4-5 are available from P, so C1 uses P's
+	effective CPUs 0-3 instead.
+	C2 has an empty "cpuset.cpus" and therefore also uses P's effective
+	CPUs 0-3.
+
+	For a valid non-root partition root, "cpuset.cpus.effective" contains
+	the active CPUs from "cpuset.cpus.exclusive.effective" except
+	those granted to valid child partition roots. If
+	"cpuset.cpus.exclusive" is set to a value different from
+	"cpuset.cpus", the effective CPUs need not be a subset of
+	"cpuset.cpus".
+
+	For example, if CPUs 2-5 are active, available, and not assigned
+	to a valid child partition root::
+
+	  top (root)
+	  |
+	  \-- P (valid partition root)
+	      cpuset.cpus=0-3
+	      cpuset.cpus.exclusive=2-5
+	      cpuset.cpus.exclusive.effective=2-5
+	      cpuset.cpus.effective=2-5
+
+	P has 2-5 in "cpuset.cpus.effective" even though its
+	"cpuset.cpus" is 0-3.
 
 	Its value will be affected by CPU hotplug events.
 
Signature · 1 line
2.43.0
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] docs: cgroup-v2: Describe effective CPUs of partition roots

Quoted 46 lines · Guopeng Zhang

From: Guopeng Zhang <[email protected]>

The cpuset.cpus.effective description says that the effective CPUs are granted by the parent and are normally a subset of cpuset.cpus. This does not always hold for a valid non-root partition root. Its effective CPUs are the active CPUs in cpuset.cpus.exclusive.effective after CPUs assigned to valid child partition roots are removed.

If cpuset.cpus.exclusive differs from cpuset.cpus, the effective CPUs may therefore be outside cpuset.cpus. Remote partitions also do not necessarily get their CPUs from their immediate parent.

---
  Documentation/admin-guide/cgroup-v2.rst | 56 ++++++++++++++++++++-----
  1 file changed, 46 insertions(+), 10 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +10 -10
index 18a01ce4c334..d21bbae3312a 100644
@@ -2505,16 +2505,52 @@ Cpuset Interface Files
  	A read-only multiple values file which exists on all
  	cpuset-enabled cgroups.
 
-	It lists the onlined CPUs that are actually granted to this
-	cgroup by its parent.  These CPUs are allowed to be used by
-	tasks within the current cgroup.
-
-	If "cpuset.cpus" is empty, the "cpuset.cpus.effective" file shows
-	all the CPUs from the parent cgroup that can be available to
-	be used by this cgroup.  Otherwise, it should be a subset of
-	"cpuset.cpus" unless none of the CPUs listed in "cpuset.cpus"
-	can be granted.  In this case, it will be treated just like an
-	empty "cpuset.cpus".
+	It lists the active CPUs available to tasks in this cgroup.
+
+	For a cgroup that is not a valid partition root, an empty
+	"cpuset.cpus" makes "cpuset.cpus.effective" show all CPUs
+	available from the parent cgroup. Otherwise, it is a subset
+	of "cpuset.cpus" unless none of the requested CPUs can be
+	granted. In that case, it is treated like an empty
+	"cpuset.cpus".
+
+	For example::

Documentation/admin-guide/cgroup-v2.rst Cpuset Interface Files · line 2527

Quoted 10 lines
Documentation/admin-guide/cgroup-v2.rst +10 -0
+
+	  P (cpuset.cpus.effective=0-3)
+	  |
+	  +-- C0 (member):       cpuset.cpus=1-2
+	  |                      cpuset.cpus.effective=1-2
+	  +-- C1 (invalid root): cpuset.cpus=4-5
+	  |                      cpuset.cpus.effective=0-3
+	  \-- C2 (member):       cpuset.cpus=<empty>
+	                         cpuset.cpus.effective=0-3
+

That is clear. Thanks.

Quoted 19 lines
Documentation/admin-guide/cgroup-v2.rst +19 -0
+	C0 gets CPUs 1-2 because they are available from P.
+	None of C1's requested CPUs 4-5 are available from P, so C1 uses P's
+	effective CPUs 0-3 instead.
+	C2 has an empty "cpuset.cpus" and therefore also uses P's effective
+	CPUs 0-3.
+
+	For a valid non-root partition root, "cpuset.cpus.effective" contains
+	the active CPUs from "cpuset.cpus.exclusive.effective" except
+	those granted to valid child partition roots. If
+	"cpuset.cpus.exclusive" is set to a value different from
+	"cpuset.cpus", the effective CPUs need not be a subset of
+	"cpuset.cpus".
+
+	For example, if CPUs 2-5 are active, available, and not assigned
+	to a valid child partition root::
+
+	  top (root)
+	  |
+	  \-- P (valid partition root)

Documentation/admin-guide/cgroup-v2.rst Cpuset Interface Files · line 2556

Quoted 10 lines
Documentation/admin-guide/cgroup-v2.rst +7 -0
+	      cpuset.cpus=0-3
+	      cpuset.cpus.exclusive=2-5
+	      cpuset.cpus.exclusive.effective=2-5
+	      cpuset.cpus.effective=2-5
+
+	P has 2-5 in "cpuset.cpus.effective" even though its
+	"cpuset.cpus" is 0-3.
 
  	Its value will be affected by CPU hotplug events.
 

I would suggest offering an example where "cpuset.cpus.effective" differs from "cpuset.cpus.exclusive.effective", meaning that "cpuset.cpus.exclusive.effective" contains offline CPUs. This would make it much clearer that "cpuset.cpus.effective" does not contain offline CPUs.

With that, feel free to add:

Thanks.

Signature · 2 lines
Best regards
Ridong
#6 lore raw

Re: [PATCH v2 2/2] docs: cgroup-v2: Describe effective CPUs of partition roots

Quoted 92 lines · Ridong Chen
Quoted 45 lines · Guopeng Zhang

From: Guopeng Zhang <[email protected]>

The cpuset.cpus.effective description says that the effective CPUs are granted by the parent and are normally a subset of cpuset.cpus. This does not always hold for a valid non-root partition root. Its effective CPUs are the active CPUs in cpuset.cpus.exclusive.effective after CPUs assigned to valid child partition roots are removed.

If cpuset.cpus.exclusive differs from cpuset.cpus, the effective CPUs may therefore be outside cpuset.cpus. Remote partitions also do not necessarily get their CPUs from their immediate parent.

---
  Documentation/admin-guide/cgroup-v2.rst | 56 ++++++++++++++++++++-----

  1 file changed, 46 insertions(+), 10 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +0 -0
index 18a01ce4c334..d21bbae3312a 100644
@@ -2505,16 +2505,52 @@ Cpuset Interface Files

      A read-only multiple values file which exists on all cpuset-enabled cgroups.
  -    It lists the onlined CPUs that are actually granted to this -    cgroup by its parent.  These CPUs are allowed to be used by -    tasks within the current cgroup.

Documentation/admin-guide/cgroup-v2.rst +10 -7
-
-    If "cpuset.cpus" is empty, the "cpuset.cpus.effective" file shows
-    all the CPUs from the parent cgroup that can be available to
-    be used by this cgroup.  Otherwise, it should be a subset of
-    "cpuset.cpus" unless none of the CPUs listed in "cpuset.cpus"
-    can be granted.  In this case, it will be treated just like an
-    empty "cpuset.cpus".
+    It lists the active CPUs available to tasks in this cgroup.
+
+    For a cgroup that is not a valid partition root, an empty
+    "cpuset.cpus" makes "cpuset.cpus.effective" show all CPUs
+    available from the parent cgroup. Otherwise, it is a subset
+    of "cpuset.cpus" unless none of the requested CPUs can be
+    granted. In that case, it is treated like an empty
+    "cpuset.cpus".
+
+    For example::

Documentation/admin-guide/cgroup-v2.rst Cpuset Interface Files · line 2527

Quoted 10 lines
Documentation/admin-guide/cgroup-v2.rst +10 -0
+
+      P (cpuset.cpus.effective=0-3)
+      |
+      +-- C0 (member):       cpuset.cpus=1-2
+      |                      cpuset.cpus.effective=1-2
+      +-- C1 (invalid root): cpuset.cpus=4-5
+      |                      cpuset.cpus.effective=0-3
+      \-- C2 (member):       cpuset.cpus=<empty>
+                             cpuset.cpus.effective=0-3
+

That is clear. Thanks.

Quoted 26 lines

+    C0 gets CPUs 1-2 because they are available from P.
+    None of C1's requested CPUs 4-5 are available from P, so C1 uses P's +    effective CPUs 0-3 instead.
+    C2 has an empty "cpuset.cpus" and therefore also uses P's effective +    CPUs 0-3.

Documentation/admin-guide/cgroup-v2.rst +21 -0
+
+    For a valid non-root partition root, "cpuset.cpus.effective" contains
+    the active CPUs from "cpuset.cpus.exclusive.effective" except
+    those granted to valid child partition roots. If
+    "cpuset.cpus.exclusive" is set to a value different from
+    "cpuset.cpus", the effective CPUs need not be a subset of
+    "cpuset.cpus".
+
+    For example, if CPUs 2-5 are active, available, and not assigned
+    to a valid child partition root::
+
+      top (root)
+      |
+      \-- P (valid partition root)
+          cpuset.cpus=0-3
+          cpuset.cpus.exclusive=2-5
+          cpuset.cpus.exclusive.effective=2-5
+          cpuset.cpus.effective=2-5
+
+    P has 2-5 in "cpuset.cpus.effective" even though its
+    "cpuset.cpus" is 0-3.
Quoted 2 lines

        Its value will be affected by CPU hotplug events.

I would suggest offering an example where "cpuset.cpus.effective" differs from "cpuset.cpus.exclusive.effective", meaning that "cpuset.cpus.exclusive.effective" contains offline CPUs. This would make it much clearer that "cpuset.cpus.effective" does not contain offline CPUs.

Quoted 4 lines

With that, feel free to add:

Thanks for the suggestion. I'll update the example in v3 to cover the offline CPU case and add your Reviewed-by.

Thanks,
Guopeng