Skip to contentSkip to conversation

cpuset: Enable cpuset controller in default hierarchy

PATCH Superseded Waiman Long 5 participants 24 messages Apr 19, 2018 – May 8, 2018

Subsystems (3)

v7 of 15 Superseded Latest is v15 →

lore
Share & tools
lore

Waiman Long

author maintainer
#0 lore raw

v7 cover cpuset: Enable cpuset controller in default hierarchy

v7:
- Add a root-only cpuset.cpus.isolated control file for CPU isolation.
- Enforce that load_balancing can only be turned off on cpusets with CPUs from the isolated list.
- Update sched domain generation to allow cpusets with CPUs only from the isolated CPU list to be in separate root domains.

v6:
- Hide cpuset control knobs in root cgroup.
- Rename effective_cpus and effective_mems to cpus.effective and mems.effective respectively.
- Remove cpuset.flags and add cpuset.sched_load_balance instead as the behavior of sched_load_balance has changed and so is not a simple flag.
- Update cgroup-v2.txt accordingly.

v5:
- Add patch 2 to provide the cpuset.flags control knob for the sched_load_balance flag which should be the only feature that is essential as a replacement of the "isolcpus" kernel boot parameter.

v4:
- Further minimize the feature set by removing the flags control knob.

v3:
- Further trim the additional features down to just memory_migrate.
- Update Documentation/cgroup-v2.txt.

v6 patch: https://lkml.org/lkml/2018/3/21/530

The purpose of this patchset is to provide a basic set of cpuset features for cgroup v2. This basic set includes the non-root "cpus", "mems", "cpus.effective" and "mems.effective", "sched_load_balance" control file as well as a root-only "cpus.isolated".

The root-only "cpus.isolated" file is added to support use cases similar to the "isolcpus" kernel parameter. CPUs from the isolated list can be put into child cpusets where "sched_load_balance" can be disabled to allow finer control of task-cpu mappings of those isolated CPUs.

On the other hand, enabling the "sched_load_balance" on a cpuset with only CPUs from the isolated list will allow those CPUs to use a separate root domain from that of the root cpuset.

This patchset does not exclude the possibility of adding more features in the future after careful consideration.

Patch 1 enables cpuset in cgroup v2 with cpus, mems and their effective counterparts.

Patch 2 adds sched_load_balance whose behavior changes in v2 to become hierarchical and includes an implicit !cpu_exclusive.

Patch 3 adds a new root-only "cpuset.cpus.isolated" control file for CPU isolation purpose.

Patch 4 adds the limitation that "sched_load_balance" can only be turned off in a cpuset if all the CPUs in the cpuset are already in the root's "cpuset.cpus.isolated".

Patch 5 modifies the sched domain generation code to generate separate root sched domains if all the CPUs in a cpuset comes from "cpuset.cpus.isolated".

In other words, all the CPUs that need to be isolated or in separate root domains have to be put into the "cpuset.cpus.isolated" first. Then child cpusets can be created to partition those isolated CPUs into either separate root domains with "sched_load_balance" on or really isolated CPUs with "sched_load_balance" off. Load balancing cannot be turned off at root.

Waiman Long (5):
cpuset: Enable cpuset controller in default hierarchy
cpuset: Add cpuset.sched_load_balance to v2
cpuset: Add a root-only cpus.isolated v2 control file
cpuset: Restrict load balancing off cpus to subset of cpus.isolated
cpuset: Make generate_sched_domains() recognize isolated_cpus

 Documentation/cgroup-v2.txt | 138 ++++++++++++++++++++-
 kernel/cgroup/cpuset.c      | 287 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 404 insertions(+), 21 deletions(-)
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH v7 1/5 cpuset: Enable cpuset controller in default hierarchy

Given the fact that thread mode had been merged into 4.14, it is now time to enable cpuset to be used in the default hierarchy (cgroup v2) as it is clearly threaded.

The cpuset controller had experienced feature creep since its introduction more than a decade ago. Besides the core cpus and mems control files to limit cpus and memory nodes, there are a bunch of additional features that can be controlled from the userspace. Some of the features are of doubtful usefulness and may not be actively used.

This patch enables cpuset controller in the default hierarchy with a minimal set of features, namely just the cpus and mems and their effective_* counterparts. We can certainly add more features to the default hierarchy in the future if there is a real user need for them later on.

Alternatively, with the unified hiearachy, it may make more sense to move some of those additional cpuset features, if desired, to memory controller or may be to the cpu controller instead of staying with cpuset.

---
 Documentation/cgroup-v2.txt | 90 ++++++++++++++++++++++++++++++++++++++++++---
 kernel/cgroup/cpuset.c      | 48 ++++++++++++++++++++++--
 2 files changed, 130 insertions(+), 8 deletions(-)
Documentation/cgroup-v2.txt +85 -5
index 74cdeae..ed8ec66 100644
@@ -53,11 +53,13 @@ v1 is available under Documentation/cgroup-v1/.
        5-3-2. Writeback
      5-4. PID
        5-4-1. PID Interface Files
-     5-5. Device
-     5-6. RDMA
-       5-6-1. RDMA Interface Files
-     5-7. Misc
-       5-7-1. perf_event
+     5-5. Cpuset
+       5.5-1. Cpuset Interface Files
+     5-6. Device
+     5-7. RDMA
+       5-7-1. RDMA Interface Files
+     5-8. Misc
+       5-8-1. perf_event
      5-N. Non-normative information
        5-N-1. CPU controller root cgroup process behaviour
        5-N-2. IO controller root cgroup process behaviour
@@ -1435,6 +1437,84 @@ through fork() or clone(). These will return -EAGAIN if the creation
 of a new process would cause a cgroup policy to be violated.
 
 
+Cpuset
+------
+
+The "cpuset" controller provides a mechanism for constraining
+the CPU and memory node placement of tasks to only the resources
+specified in the cpuset interface files in a task's current cgroup.
+This is especially valuable on large NUMA systems where placing jobs
+on properly sized subsets of the systems with careful processor and
+memory placement to reduce cross-node memory access and contention
+can improve overall system performance.
+
+The "cpuset" controller is hierarchical.  That means the controller
+cannot use CPUs or memory nodes not allowed in its parent.
+
+
+Cpuset Interface Files
+~~~~~~~~~~~~~~~~~~~~~~
+
+  cpuset.cpus
+	A read-write multiple values file which exists on non-root
+	cgroups.
+
+	It lists the CPUs allowed to be used by tasks within this
+	cgroup.  The CPU numbers are comma-separated numbers or
+	ranges.  For example:
+
+	  # cat cpuset.cpus
+	  0-4,6,8-10
+
+	An empty value indicates that the cgroup is using the same
+	setting as the nearest cgroup ancestor with a non-empty
+	"cpuset.cpus" or all the available CPUs if none is found.
+
+	The value of "cpuset.cpus" stays constant until the next update
+	and won't be affected by any CPU hotplug events.
+
+  cpuset.cpus.effective
+	A read-only multiple values file which exists on non-root
+	cgroups.
+
+	It lists the onlined CPUs that are actually allowed to be
+	used by tasks within the current cgroup.  If "cpuset.cpus"
+	is empty, it shows all the CPUs from the parent cgroup that
+	will be available to be used by this cgroup.  Otherwise, it is
+	a subset of "cpuset.cpus".  Its value will be affected by CPU
+	hotplug events.
+
+  cpuset.mems
+	A read-write multiple values file which exists on non-root
+	cgroups.
+
+	It lists the memory nodes allowed to be used by tasks within
+	this cgroup.  The memory node numbers are comma-separated
+	numbers or ranges.  For example:
+
+	  # cat cpuset.mems
+	  0-1,3
+
+	An empty value indicates that the cgroup is using the same
+	setting as the nearest cgroup ancestor with a non-empty
+	"cpuset.mems" or all the available memory nodes if none
+	is found.
+
+	The value of "cpuset.mems" stays constant until the next update
+	and won't be affected by any memory nodes hotplug events.
+
+  cpuset.mems.effective
+	A read-only multiple values file which exists on non-root
+	cgroups.
+
+	It lists the onlined memory nodes that are actually allowed to
+	be used by tasks within the current cgroup.  If "cpuset.mems"
+	is empty, it shows all the memory nodes from the parent cgroup
+	that will be available to be used by this cgroup.  Otherwise,
+	it is a subset of "cpuset.mems".  Its value will be affected
+	by memory nodes hotplug events.
+
+
 Device controller
 -----------------
 
kernel/cgroup/cpuset.c +45 -3

71 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author maintainer
#2 lore raw

PATCH v7 2/5 cpuset: Add cpuset.sched_load_balance to v2

In reply to Waiman Long

The sched_load_balance flag is needed to enable CPU isolation similar to what can be done with the "isolcpus" kernel boot parameter.

The sched_load_balance flag implies an implicit !cpu_exclusive as it doesn't make sense to have an isolated CPU being load-balanced in another cpuset.

For v2, this flag is hierarchical and is inherited by child cpusets. It is not allowed to have this flag turn off in a parent cpuset, but on in a child cpuset.

This flag is set by the parent and is not delegatable.

---
 Documentation/cgroup-v2.txt | 22 ++++++++++++++++++
 kernel/cgroup/cpuset.c      | 56 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 71 insertions(+), 7 deletions(-)
Documentation/cgroup-v2.txt +22 -0
index ed8ec66..c970bd7 100644
@@ -1514,6 +1514,28 @@ Cpuset Interface Files
 	it is a subset of "cpuset.mems".  Its value will be affected
 	by memory nodes hotplug events.
 
+  cpuset.sched_load_balance
+	A read-write single value file which exists on non-root cgroups.
+	The default is "1" (on), and the other possible value is "0"
+	(off).
+
+	When it is on, tasks within this cpuset will be load-balanced
+	by the kernel scheduler.  Tasks will be moved from CPUs with
+	high load to other CPUs within the same cpuset with less load
+	periodically.
+
+	When it is off, there will be no load balancing among CPUs on
+	this cgroup.  Tasks will stay in the CPUs they are running on
+	and will not be moved to other CPUs.
+
+	This flag is hierarchical and is inherited by child cpusets. It
+	can be turned off only when the CPUs in this cpuset aren't
+	listed in the cpuset.cpus of other sibling cgroups, and all
+	the child cpusets, if present, have this flag turned off.
+
+	Once it is off, it cannot be turned back on as long as the
+	parent cgroup still has this flag in the off state.
+
 
 Device controller
 -----------------
kernel/cgroup/cpuset.c +49 -7

90 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH v7 2/5] cpuset: Add cpuset.sched_load_balance to v2

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1518

Quoted 2 lines · Waiman Long
Documentation/cgroup-v2.txt +2 -0
+  cpuset.sched_load_balance
+	A read-write single value file which exists on non-root cgroups.

Uhhm.. it should very much exist in the root group too. Otherwise you cannot disable it there, which is required to allow smaller groups to load-balance between themselves.

Quoted 9 lines
Documentation/cgroup-v2.txt +9 -0
+	The default is "1" (on), and the other possible value is "0"
+	(off).
+
+	When it is on, tasks within this cpuset will be load-balanced
+	by the kernel scheduler.  Tasks will be moved from CPUs with
+	high load to other CPUs within the same cpuset with less load
+	periodically.
+
+	When it is off, there will be no load balancing among CPUs on

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1537

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	this cgroup.  Tasks will stay in the CPUs they are running on
+	and will not be moved to other CPUs.
+
+	This flag is hierarchical and is inherited by child cpusets. It
+	can be turned off only when the CPUs in this cpuset aren't
+	listed in the cpuset.cpus of other sibling cgroups, and all
+	the child cpusets, if present, have this flag turned off.
+
+	Once it is off, it cannot be turned back on as long as the
+	parent cgroup still has this flag in the off state.

That too is wrong and broken. You explicitly want to turn it on for children.

So the idea is that you can have:

		R
	      /   \
            A       B

With:

	R cpus=0-3, load_balance=0
	A cpus=0-1, load_balance=1
	B cpus=2-3, load_balance=1

Which will allow all tasks in A,B (and its children) to load-balance across 0-1 or 2-3 resp.

If you don't allow the root group to disable load_balance, it will always be the largest group and load-balancing will always happen system wide.

author maintainer
#4 lore raw

Re: [PATCH v7 2/5] cpuset: Add cpuset.sched_load_balance to v2

Quoted 41 lines · Peter Zijlstra

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1518

Quoted 2 lines · Waiman Long
Documentation/cgroup-v2.txt +2 -0
+  cpuset.sched_load_balance
+	A read-write single value file which exists on non-root cgroups.

Uhhm.. it should very much exist in the root group too. Otherwise you cannot disable it there, which is required to allow smaller groups to load-balance between themselves.

Quoted 9 lines
Documentation/cgroup-v2.txt +9 -0
+	The default is "1" (on), and the other possible value is "0"
+	(off).
+
+	When it is on, tasks within this cpuset will be load-balanced
+	by the kernel scheduler.  Tasks will be moved from CPUs with
+	high load to other CPUs within the same cpuset with less load
+	periodically.
+
+	When it is off, there will be no load balancing among CPUs on

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1537

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	this cgroup.  Tasks will stay in the CPUs they are running on
+	and will not be moved to other CPUs.
+
+	This flag is hierarchical and is inherited by child cpusets. It
+	can be turned off only when the CPUs in this cpuset aren't
+	listed in the cpuset.cpus of other sibling cgroups, and all
+	the child cpusets, if present, have this flag turned off.
+
+	Once it is off, it cannot be turned back on as long as the
+	parent cgroup still has this flag in the off state.

That too is wrong and broken. You explicitly want to turn it on for children.

So the idea is that you can have:

		R
	      /   \
            A       B

With:

	R cpus=0-3, load_balance=0
	A cpus=0-1, load_balance=1
	B cpus=2-3, load_balance=1
Quoted 6 lines

Which will allow all tasks in A,B (and its children) to load-balance across 0-1 or 2-3 resp.

If you don't allow the root group to disable load_balance, it will always be the largest group and load-balancing will always happen system wide.

If you look at the remaining patches in the series, I was proposing a different way to support isolcpus and separate sched domains with turning off load balancing in the root cgroup.

For me, it doesn't feel right to have load balancing disabled in the root cgroup as we probably cannot move all the tasks away from the root cgroup anyway. I am going to update the current patchset to incorporate suggestion from Tejun. It will probably be ready sometime next week.

Cheers,
Longman

#5 lore raw

Re: [PATCH v7 2/5] cpuset: Add cpuset.sched_load_balance to v2

Quoted 49 lines · Waiman Long
Quoted 41 lines · Peter Zijlstra

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1518

Quoted 2 lines · Waiman Long
Documentation/cgroup-v2.txt +2 -0
+  cpuset.sched_load_balance
+	A read-write single value file which exists on non-root cgroups.

Uhhm.. it should very much exist in the root group too. Otherwise you cannot disable it there, which is required to allow smaller groups to load-balance between themselves.

Quoted 9 lines
Documentation/cgroup-v2.txt +9 -0
+	The default is "1" (on), and the other possible value is "0"
+	(off).
+
+	When it is on, tasks within this cpuset will be load-balanced
+	by the kernel scheduler.  Tasks will be moved from CPUs with
+	high load to other CPUs within the same cpuset with less load
+	periodically.
+
+	When it is off, there will be no load balancing among CPUs on

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1537

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	this cgroup.  Tasks will stay in the CPUs they are running on
+	and will not be moved to other CPUs.
+
+	This flag is hierarchical and is inherited by child cpusets. It
+	can be turned off only when the CPUs in this cpuset aren't
+	listed in the cpuset.cpus of other sibling cgroups, and all
+	the child cpusets, if present, have this flag turned off.
+
+	Once it is off, it cannot be turned back on as long as the
+	parent cgroup still has this flag in the off state.

That too is wrong and broken. You explicitly want to turn it on for children.

So the idea is that you can have:

		R
	      /   \
            A       B

With:

	R cpus=0-3, load_balance=0
	A cpus=0-1, load_balance=1
	B cpus=2-3, load_balance=1
Quoted 6 lines

Which will allow all tasks in A,B (and its children) to load-balance across 0-1 or 2-3 resp.

If you don't allow the root group to disable load_balance, it will always be the largest group and load-balancing will always happen system wide.

Quoted 9 lines

If you look at the remaining patches in the series, I was proposing a different way to support isolcpus and separate sched domains with turning off load balancing in the root cgroup.

For me, it doesn't feel right to have load balancing disabled in the root cgroup as we probably cannot move all the tasks away from the root cgroup anyway. I am going to update the current patchset to incorporate suggestion from Tejun. It will probably be ready sometime next week.

I've read half of the next patch that adds the isolation thing. And while that kludges around the whole root cgorup is magic thing, it doesn't help if you move the above scenario on level down:

	R
     /    \
   A        B
          /   \
        C       D

R: cpus=0-7, load_balance=0
A: cpus=0-1, load_balance=1
B: cpus=2-7, load_balance=0
C: cpus=2-3, load_balance=1
D: cpus=4-7, load_balance=1

Also, I feel we should strive to have a minimal amount of tasks that cannot be moved out of the root group; the current set is far too large.

author maintainer
#6 lore raw

Re: [PATCH v7 2/5] cpuset: Add cpuset.sched_load_balance to v2

Quoted 77 lines · Peter Zijlstra
Quoted 48 lines · Waiman Long
Quoted 41 lines · Peter Zijlstra

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1518

Quoted 2 lines · Waiman Long
Documentation/cgroup-v2.txt +2 -0
+  cpuset.sched_load_balance
+	A read-write single value file which exists on non-root cgroups.

Uhhm.. it should very much exist in the root group too. Otherwise you cannot disable it there, which is required to allow smaller groups to load-balance between themselves.

Quoted 9 lines
Documentation/cgroup-v2.txt +9 -0
+	The default is "1" (on), and the other possible value is "0"
+	(off).
+
+	When it is on, tasks within this cpuset will be load-balanced
+	by the kernel scheduler.  Tasks will be moved from CPUs with
+	high load to other CPUs within the same cpuset with less load
+	periodically.
+
+	When it is off, there will be no load balancing among CPUs on

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1537

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	this cgroup.  Tasks will stay in the CPUs they are running on
+	and will not be moved to other CPUs.
+
+	This flag is hierarchical and is inherited by child cpusets. It
+	can be turned off only when the CPUs in this cpuset aren't
+	listed in the cpuset.cpus of other sibling cgroups, and all
+	the child cpusets, if present, have this flag turned off.
+
+	Once it is off, it cannot be turned back on as long as the
+	parent cgroup still has this flag in the off state.

That too is wrong and broken. You explicitly want to turn it on for children.

So the idea is that you can have:

		R
	      /   \
            A       B

With:

	R cpus=0-3, load_balance=0
	A cpus=0-1, load_balance=1
	B cpus=2-3, load_balance=1
Quoted 6 lines

Which will allow all tasks in A,B (and its children) to load-balance across 0-1 or 2-3 resp.

If you don't allow the root group to disable load_balance, it will always be the largest group and load-balancing will always happen system wide.

Quoted 9 lines

If you look at the remaining patches in the series, I was proposing a different way to support isolcpus and separate sched domains with turning off load balancing in the root cgroup.

For me, it doesn't feel right to have load balancing disabled in the root cgroup as we probably cannot move all the tasks away from the root cgroup anyway. I am going to update the current patchset to incorporate suggestion from Tejun. It will probably be ready sometime next week.

I've read half of the next patch that adds the isolation thing. And while that kludges around the whole root cgorup is magic thing, it doesn't help if you move the above scenario on level down:

	R
     /    \
   A        B
          /   \
        C       D

R: cpus=0-7, load_balance=0
A: cpus=0-1, load_balance=1
B: cpus=2-7, load_balance=0
C: cpus=2-3, load_balance=1
D: cpus=4-7, load_balance=1

Quoted 2 lines

Also, I feel we should strive to have a minimal amount of tasks that cannot be moved out of the root group; the current set is far too large.

What exactly is the use case you have in mind with loading balancing disabled in B, but enabled in C and D? We would like to support some sensible use cases, but not every possible combinations.

Cheers,
Longman

#7 lore raw

Re: [PATCH v7 2/5] cpuset: Add cpuset.sched_load_balance to v2

Quoted 19 lines · Waiman Long
Quoted 19 lines

I've read half of the next patch that adds the isolation thing. And while that kludges around the whole root cgorup is magic thing, it doesn't help if you move the above scenario on level down:

	R
     /    \
   A        B
          /   \
        C       D

R: cpus=0-7, load_balance=0
A: cpus=0-1, load_balance=1
B: cpus=2-7, load_balance=0
C: cpus=2-3, load_balance=1
D: cpus=4-7, load_balance=1

Quoted 6 lines
Quoted 2 lines

Also, I feel we should strive to have a minimal amount of tasks that cannot be moved out of the root group; the current set is far too large.

What exactly is the use case you have in mind with loading balancing disabled in B, but enabled in C and D? We would like to support some sensible use cases, but not every possible combinations.

Suppose A is your system group, and C and D are individual RT workloads or something.

Or suppose B has siblings and each group at that level is a delegate to a particular user/container. And the user/container in B happens to need 2 partitioned VMs or whatever.

The idea is the same in all the examples, you want to allow sub-partitions.

#8 lore raw

Re: [PATCH v7 2/5] cpuset: Add cpuset.sched_load_balance to v2

Quoted 24 lines · Peter Zijlstra
Quoted 22 lines · Waiman Long
Quoted 21 lines

I've read half of the next patch that adds the isolation thing. And while that kludges around the whole root cgorup is magic thing, it doesn't help if you move the above scenario on level down:

	R
     /    \
   A        B
          /   \
        C       D

R: cpus=0-7, load_balance=0
A: cpus=0-1, load_balance=1
B: cpus=2-7, load_balance=0
C: cpus=2-3, load_balance=1
D: cpus=4-7, load_balance=1

Also, I feel we should strive to have a minimal amount of tasks that cannot be moved out of the root group; the current set is far too large.

Quoted 6 lines
Quoted 3 lines

What exactly is the use case you have in mind with loading balancing disabled in B, but enabled in C and D? We would like to support some sensible use cases, but not every possible combinations.

Suppose A is your system group, and C and D are individual RT workloads or something.

Yeah, it does have a distinct "640K ought to be enough for anybody" flavor to it.

-Mike

author maintainer
#9 lore raw

PATCH v7 3/5 cpuset: Add a root-only cpus.isolated v2 control file

In reply to Waiman Long

In order to better support CPU isolation as well as multiple root domains for deadline scheduling, the ability to carve out a set of CPUs specifically for isolation or for another root domain will be useful.

A new root-only "cpuset.cpus.isolated" control file is now added for holding the list of CPUs that will not be participating in load balancing within the root cpuset. The root's effective cpu list will not contain any CPUs that are in "cpuset.cpus.isolated" file. These isolated CPUs, however, can still be put into child cpusets and load balanced within them if necessary.

For CPU isolation, putting the CPUs into this new control file and not having them in any of the child cpusets should be enough. Those isolated CPUs can also be put into a child cpuset with load balancing disabled for finer-grained control.

For creating additional root domains for scheduling, a child cpuset should only select an exclusive set of CPUs within the isolated set.

The "cpuset.cpus.isolated" control file should be set up before any child cpusets are created. If child cpusets are present, changes to this control file will not be allowed if any CPUs that will change state are in any of the child cpusets.

---
 Documentation/cgroup-v2.txt |  25 ++++++++++
 kernel/cgroup/cpuset.c      | 119 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 143 insertions(+), 1 deletion(-)
Documentation/cgroup-v2.txt +25 -0
index c970bd7..8d89dc2 100644
@@ -1484,6 +1484,31 @@ Cpuset Interface Files
 	a subset of "cpuset.cpus".  Its value will be affected by CPU
 	hotplug events.
 
+  cpuset.cpus.isolated
+	A read-write multiple values file which exists on root cgroup
+	only.
+
+	It lists the CPUs that have been withdrawn from the root cgroup
+	for load balancing.  These CPUs can still be allocated to child
+	cpusets with load balancing enabled, if necessary.
+
+	If a child cpuset contains only an exclusive set of CPUs that are
+	a subset of the isolated CPUs and with load balancing enabled,
+	these CPUs will be load balanced on a separate root domain from
+	the one in the root cgroup.
+
+	Just putting the CPUs into "cpuset.cpus.isolated" will be
+	enough to disable load balancing on those CPUs as long as they
+	do not appear in a child cpuset with load balancing enabled.
+	Fine-grained control of cpu isolation can also be done by
+	putting these isolated CPUs into child cpusets with load
+	balancing disabled.
+
+	The "cpuset.cpus.isolated" should be set up before child
+	cpusets are created.  Once child cpusets are present, changes
+	to "cpuset.cpus.isolated" will not be allowed if the CPUs that
+	change their states are in any of the child cpusets.
+
   cpuset.mems
 	A read-write multiple values file which exists on non-root
 	cgroups.
kernel/cgroup/cpuset.c +118 -1

173 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#10 lore raw

Re: [PATCH v7 3/5] cpuset: Add a root-only cpus.isolated v2 control file

On 19/04/18 09:47, Waiman Long wrote:

[...]

Quoted 6 lines
Documentation/cgroup-v2.txt +6 -0
+  cpuset.cpus.isolated
+	A read-write multiple values file which exists on root cgroup
+	only.
+
+	It lists the CPUs that have been withdrawn from the root cgroup
+	for load balancing.  These CPUs can still be allocated to child

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1502

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	cpusets with load balancing enabled, if necessary.
+
+	If a child cpuset contains only an exclusive set of CPUs that are
+	a subset of the isolated CPUs and with load balancing enabled,
+	these CPUs will be load balanced on a separate root domain from
+	the one in the root cgroup.
+
+	Just putting the CPUs into "cpuset.cpus.isolated" will be
+	enough to disable load balancing on those CPUs as long as they
+	do not appear in a child cpuset with load balancing enabled.

Tasks that were on those CPUs when they got isolated will stay there (unless forcibly moved somewhere else). They will also "automatically" belong to default root domain (or potentially to a new root domain created for a group using those CPUs). Both things are maybe unavoidable (as discussed in previous versions some tasks cannot be migrated at all), but such "side effects" should probably be documented. What do you think?

#11 lore raw

Re: [PATCH v7 3/5] cpuset: Add a root-only cpus.isolated v2 control file

In reply to Waiman Long
Quoted 23 lines · Waiman Long
Documentation/cgroup-v2.txt +15 -0
index c970bd7..8d89dc2 100644
@@ -1484,6 +1484,31 @@ Cpuset Interface Files
 	a subset of "cpuset.cpus".  Its value will be affected by CPU
 	hotplug events.
 
+  cpuset.cpus.isolated
+	A read-write multiple values file which exists on root cgroup
+	only.
+
+	It lists the CPUs that have been withdrawn from the root cgroup
+	for load balancing.  These CPUs can still be allocated to child
+	cpusets with load balancing enabled, if necessary.
+
+	If a child cpuset contains only an exclusive set of CPUs that are
+	a subset of the isolated CPUs and with load balancing enabled,
+	these CPUs will be load balanced on a separate root domain from
+	the one in the root cgroup.
+
+	Just putting the CPUs into "cpuset.cpus.isolated" will be
+	enough to disable load balancing on those CPUs as long as they

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1511

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	do not appear in a child cpuset with load balancing enabled.
+	Fine-grained control of cpu isolation can also be done by
+	putting these isolated CPUs into child cpusets with load
+	balancing disabled.
+
+	The "cpuset.cpus.isolated" should be set up before child
+	cpusets are created.  Once child cpusets are present, changes
+	to "cpuset.cpus.isolated" will not be allowed if the CPUs that
+	change their states are in any of the child cpusets.
+

So I see why you did this, but it is _really_ ugly and breaks the container invariant.

Ideally we'd make the root group less special, not more special.

author maintainer
#12 lore raw

Re: [PATCH v7 3/5] cpuset: Add a root-only cpus.isolated v2 control file

Quoted 37 lines · Peter Zijlstra
Quoted 23 lines · Waiman Long
Documentation/cgroup-v2.txt +15 -0
index c970bd7..8d89dc2 100644
@@ -1484,6 +1484,31 @@ Cpuset Interface Files
 	a subset of "cpuset.cpus".  Its value will be affected by CPU
 	hotplug events.
 
+  cpuset.cpus.isolated
+	A read-write multiple values file which exists on root cgroup
+	only.
+
+	It lists the CPUs that have been withdrawn from the root cgroup
+	for load balancing.  These CPUs can still be allocated to child
+	cpusets with load balancing enabled, if necessary.
+
+	If a child cpuset contains only an exclusive set of CPUs that are
+	a subset of the isolated CPUs and with load balancing enabled,
+	these CPUs will be load balanced on a separate root domain from
+	the one in the root cgroup.
+
+	Just putting the CPUs into "cpuset.cpus.isolated" will be
+	enough to disable load balancing on those CPUs as long as they

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1511

Quoted 10 lines
Documentation/cgroup-v2.txt +10 -0
+	do not appear in a child cpuset with load balancing enabled.
+	Fine-grained control of cpu isolation can also be done by
+	putting these isolated CPUs into child cpusets with load
+	balancing disabled.
+
+	The "cpuset.cpus.isolated" should be set up before child
+	cpusets are created.  Once child cpusets are present, changes
+	to "cpuset.cpus.isolated" will not be allowed if the CPUs that
+	change their states are in any of the child cpusets.
+

So I see why you did this, but it is _really_ ugly and breaks the container invariant.

Quoted 1 line

Ideally we'd make the root group less special, not more special.

Yes, I am planning to make the root cgroup less special by putting a new isolation flag into all the non-root cgroup.

The container invariant thing, however, is a bit hard to do. Do we really need a container root to behave exactly like the real root? I guess we can make that happen if we really want to, but it will certainly make the code more complex. So it is a trade-off about what is worth to do and what is not.

Cheers,
Longman

author maintainer
#13 lore raw

PATCH v7 4/5 cpuset: Restrict load balancing off cpus to subset of cpus.isolated

In reply to Waiman Long

With the addition of "cpuset.cpus.isolated", it makes sense to add the restriction that load balancing can only be turned off if the CPUs in the isolated cpuset are subset of "cpuset.cpus.isolated".

---
 Documentation/cgroup-v2.txt |  7 ++++---
 kernel/cgroup/cpuset.c      | 29 ++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 6 deletions(-)
Documentation/cgroup-v2.txt +4 -3
index 8d89dc2..c4227ee 100644
@@ -1554,9 +1554,10 @@ Cpuset Interface Files
 	and will not be moved to other CPUs.
 
 	This flag is hierarchical and is inherited by child cpusets. It
-	can be turned off only when the CPUs in this cpuset aren't
-	listed in the cpuset.cpus of other sibling cgroups, and all
-	the child cpusets, if present, have this flag turned off.
+	can be explicitly turned off only when it is a direct child of
+	the root cgroup and the CPUs in this cpuset are subset of the
+	root's "cpuset.cpus.isolated".	Moreover, the CPUs cannot be
+	listed in the "cpuset.cpus" of other sibling cgroups.
 
 	Once it is off, it cannot be turned back on as long as the
 	parent cgroup still has this flag in the off state.
kernel/cgroup/cpuset.c +26 -3
index c746b18..d05c4c8 100644
@@ -511,6 +511,16 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
 
 	par = parent_cs(cur);
 
+	/*
+	 * On default hierarchy with sched_load_balance flag off, the cpu
+	 * list must be a subset of the parent's isolated CPU list, if
+	 * defined (root).
+	 */
+	if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys) &&
+	    !is_sched_load_balance(trial) && par->isolation_count &&
+	    !cpumask_subset(trial->cpus_allowed, par->isolated_cpus))
+		goto out;
+
 	/* On legacy hierarchy, we must be a subset of our parent cpuset. */
 	ret = -EACCES;
 	if (!is_in_v2_mode() && !is_cpuset_subset(trial, par))
@@ -1431,10 +1441,16 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
 	else
 		clear_bit(bit, &trialcs->flags);
 
+	balance_flag_changed = (is_sched_load_balance(cs) !=
+				is_sched_load_balance(trialcs));
+
 	/*
 	 * On default hierarchy, turning off sched_load_balance flag implies
 	 * an implicit cpu_exclusive. Turning on sched_load_balance will
 	 * clear the cpu_exclusive flag.
+	 *
+	 * sched_load_balance can only be turned off if all the CPUs are
+	 * in the parent's isolated CPU list.
 	 */
 	if ((bit == CS_SCHED_LOAD_BALANCE) &&
 	    cgroup_subsys_on_dfl(cpuset_cgrp_subsys)) {
@@ -1442,15 +1458,22 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
 			clear_bit(CS_CPU_EXCLUSIVE, &trialcs->flags);
 		else
 			set_bit(CS_CPU_EXCLUSIVE, &trialcs->flags);
+
+		if (balance_flag_changed && !turning_on) {
+			struct cpuset *parent = parent_cs(cs);
+
+			err = -EBUSY;
+			if (!parent->isolation_count ||
+			    !cpumask_subset(trialcs->cpus_allowed,
+					    parent->cpus_allowed))
+				goto out;
+		}
 	}
 
 	err = validate_change(cs, trialcs);
 	if (err < 0)
 		goto out;
 
-	balance_flag_changed = (is_sched_load_balance(cs) !=
-				is_sched_load_balance(trialcs));
-
 	spread_flag_changed = ((is_spread_slab(cs) != is_spread_slab(trialcs))
 			|| (is_spread_page(cs) != is_spread_page(trialcs)));
 
Signature · 1 line
1.8.3.1
maintainer
#14 lore raw

Re: [PATCH v7 4/5] cpuset: Restrict load balancing off cpus to subset of cpus.isolated

Hello, Waiman.

Sorry about the delay.

Quoted 15 lines · Waiman Long

With the addition of "cpuset.cpus.isolated", it makes sense to add the restriction that load balancing can only be turned off if the CPUs in the isolated cpuset are subset of "cpuset.cpus.isolated".

---
 Documentation/cgroup-v2.txt |  7 ++++---
 kernel/cgroup/cpuset.c      | 29 ++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 6 deletions(-)
Documentation/cgroup-v2.txt +0 -0
index 8d89dc2..c4227ee 100644

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1560

Quoted 10 lines
Documentation/cgroup-v2.txt +4 -3
@@ -1554,9 +1554,10 @@ Cpuset Interface Files
 	and will not be moved to other CPUs.
 
 	This flag is hierarchical and is inherited by child cpusets. It
-	can be turned off only when the CPUs in this cpuset aren't
-	listed in the cpuset.cpus of other sibling cgroups, and all
-	the child cpusets, if present, have this flag turned off.
+	can be explicitly turned off only when it is a direct child of
+	the root cgroup and the CPUs in this cpuset are subset of the
+	root's "cpuset.cpus.isolated".	Moreover, the CPUs cannot be
+	listed in the "cpuset.cpus" of other sibling cgroups.

It is a little bit convoluted that the isolation requires coordination among root's isolated file and the first-level children's cpus file and the flag. Maybe I'm missing something but can't we do something like the following?

* Add isolated flag file, which can only be modified on empty (in terms of cpus) first level children.

* Once isolated flag is set, CPUs can only be added to the cpus file iff they aren't being used by anyone else and automatically become isolated.

The first level cpus file is owned by the root cgroup anyway, so there's no danger regarding delegation or whatever and the interface would be a lot simpler.

Thanks.

Signature · 1 line
tejun
author maintainer
#15 lore raw

Re: [PATCH v7 4/5] cpuset: Restrict load balancing off cpus to subset of cpus.isolated

Quoted 38 lines · Tejun Heo

Hello, Waiman.

Sorry about the delay.

Quoted 15 lines · Waiman Long

With the addition of "cpuset.cpus.isolated", it makes sense to add the restriction that load balancing can only be turned off if the CPUs in the isolated cpuset are subset of "cpuset.cpus.isolated".

---
 Documentation/cgroup-v2.txt |  7 ++++---
 kernel/cgroup/cpuset.c      | 29 ++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 6 deletions(-)
Documentation/cgroup-v2.txt +0 -0
index 8d89dc2..c4227ee 100644

Documentation/cgroup-v2.txt Cpuset Interface Files · line 1560

Quoted 10 lines
Documentation/cgroup-v2.txt +4 -3
@@ -1554,9 +1554,10 @@ Cpuset Interface Files
 	and will not be moved to other CPUs.
 
 	This flag is hierarchical and is inherited by child cpusets. It
-	can be turned off only when the CPUs in this cpuset aren't
-	listed in the cpuset.cpus of other sibling cgroups, and all
-	the child cpusets, if present, have this flag turned off.
+	can be explicitly turned off only when it is a direct child of
+	the root cgroup and the CPUs in this cpuset are subset of the
+	root's "cpuset.cpus.isolated".	Moreover, the CPUs cannot be
+	listed in the "cpuset.cpus" of other sibling cgroups.

It is a little bit convoluted that the isolation requires coordination among root's isolated file and the first-level children's cpus file and the flag. Maybe I'm missing something but can't we do something like the following?

* Add isolated flag file, which can only be modified on empty (in terms of cpus) first level children.

Quoted 7 lines

* Once isolated flag is set, CPUs can only be added to the cpus file iff they aren't being used by anyone else and automatically become isolated.

The first level cpus file is owned by the root cgroup anyway, so there's no danger regarding delegation or whatever and the interface would be a lot simpler.

I think that will work too. We currently don't have a flag to make a file visible on first-level children only, but it shouldn't be hard to make one.

Putting CPUs into an isolated child cpuset means removing it from the root's effective CPUs. So I would probably like to expose the read-only cpus.effective in the root cgroup so that we can check changes in the effective cpu list.

I will renew the patchset will your suggestion.

Thanks,
Longman

maintainer
#16 lore raw

Re: [PATCH v7 4/5] cpuset: Restrict load balancing off cpus to subset of cpus.isolated

Hello,

Quoted 3 lines · Waiman Long

I think that will work too. We currently don't have a flag to make a file visible on first-level children only, but it shouldn't be hard to make one.

I think it'd be fine to make the flag file exist on all !root cgroups but only writable on the first level children.

Quoted 4 lines

Putting CPUs into an isolated child cpuset means removing it from the root's effective CPUs. So I would probably like to expose the read-only cpus.effective in the root cgroup so that we can check changes in the effective cpu list.

Ah, yeah, that makes sense.

Quoted 1 line

I will renew the patchset will your suggestion.

Thank you very much.

Signature · 1 line
tejun
author maintainer
#17 lore raw

Re: [PATCH v7 4/5] cpuset: Restrict load balancing off cpus to subset of cpus.isolated

Quoted 8 lines · Tejun Heo

Hello,

Quoted 3 lines · Waiman Long

I think that will work too. We currently don't have a flag to make a file visible on first-level children only, but it shouldn't be hard to make one.

I think it'd be fine to make the flag file exist on all !root cgroups but only writable on the first level children.

Right. This flag will be inherited by child cgroups like the sched_load_balance.

Cheers,
Longman

author maintainer
#18 lore raw

PATCH v7 5/5 cpuset: Make generate_sched_domains() recognize isolated_cpus

In reply to Waiman Long

The generate_sched_domains() function and the hotplug code are modified to make them use the newly introduced isolated_cpus mask for schedule domains generation.

---
 kernel/cgroup/cpuset.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +33 -2
index d05c4c8..a67c77a 100644
@@ -683,13 +683,14 @@ static int generate_sched_domains(cpumask_var_t **domains,
 	int ndoms = 0;		/* number of sched domains in result */
 	int nslot;		/* next empty doms[] struct cpumask slot */
 	struct cgroup_subsys_state *pos_css;
+	bool root_load_balance = is_sched_load_balance(&top_cpuset);
 
 	doms = NULL;
 	dattr = NULL;
 	csa = NULL;
 
 	/* Special case for the 99% of systems with one, full, sched domain */
-	if (is_sched_load_balance(&top_cpuset)) {
+	if (root_load_balance && !top_cpuset.isolation_count) {
 		ndoms = 1;
 		doms = alloc_sched_domains(ndoms);
 		if (!doms)
@@ -712,6 +713,8 @@ static int generate_sched_domains(cpumask_var_t **domains,
 	csn = 0;
 
 	rcu_read_lock();
+	if (root_load_balance)
+		csa[csn++] = &top_cpuset;
 	cpuset_for_each_descendant_pre(cp, pos_css, &top_cpuset) {
 		if (cp == &top_cpuset)
 			continue;
@@ -722,6 +725,9 @@ static int generate_sched_domains(cpumask_var_t **domains,
 		 * parent's cpus, so just skip them, and then we call
 		 * update_domain_attr_tree() to calc relax_domain_level of
 		 * the corresponding sched domain.
+		 *
+		 * If root is load-balancing, we can skip @cp if it
+		 * is a subset of the root's effective_cpus.
 		 */
 		if (!cpumask_empty(cp->cpus_allowed) &&
 		    !(is_sched_load_balance(cp) &&
@@ -729,6 +735,10 @@ static int generate_sched_domains(cpumask_var_t **domains,
 					 housekeeping_cpumask(HK_FLAG_DOMAIN))))
 			continue;
 
+		if (root_load_balance &&
+		    cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus))
+			continue;
+
 		if (is_sched_load_balance(cp))
 			csa[csn++] = cp;
 
@@ -820,6 +830,12 @@ static int generate_sched_domains(cpumask_var_t **domains,
 	}
 	BUG_ON(nslot != ndoms);
 
+#ifdef CONFIG_DEBUG_KERNEL
+	for (i = 0; i < ndoms; i++)
+		pr_info("rebuild_sched_domains dom %d: %*pbl\n", i,
+			cpumask_pr_args(doms[i]));
+#endif
+
 done:
 	kfree(csa);
 
@@ -860,7 +876,12 @@ static void rebuild_sched_domains_locked(void)
 	 * passing doms with offlined cpu to partition_sched_domains().
 	 * Anyways, hotplug work item will rebuild sched domains.
 	 */
-	if (!cpumask_equal(top_cpuset.effective_cpus, cpu_active_mask))
+	if (!top_cpuset.isolation_count &&
+	    !cpumask_equal(top_cpuset.effective_cpus, cpu_active_mask))
+		goto out;
+
+	if (top_cpuset.isolation_count &&
+	   !cpumask_subset(top_cpuset.effective_cpus, cpu_active_mask))
 		goto out;
 
 	/* Generate domain masks and attrs */
@@ -1102,6 +1123,7 @@ static int update_isolated_cpumask(const char *buf)
 
 	top_cpuset.isolation_count = cpumask_weight(top_cpuset.isolated_cpus);
 	spin_unlock_irq(&callback_lock);
+	rebuild_sched_domains_locked();
 
 out_ok:
 	retval = 0;
@@ -2530,6 +2552,11 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
 	cpumask_copy(&new_cpus, cpu_active_mask);
 	new_mems = node_states[N_MEMORY];
 
+	/*
+	 * If isolated_cpus is populated, it is likely that the check below
+	 * will produce a false positive on cpus_updated when the cpu list
+	 * isn't changed. It is extra work, but it is better to be safe.
+	 */
 	cpus_updated = !cpumask_equal(top_cpuset.effective_cpus, &new_cpus);
 	mems_updated = !nodes_equal(top_cpuset.effective_mems, new_mems);
 
@@ -2538,6 +2565,10 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
 		spin_lock_irq(&callback_lock);
 		if (!on_dfl)
 			cpumask_copy(top_cpuset.cpus_allowed, &new_cpus);
+
+		if (top_cpuset.isolation_count)
+			cpumask_andnot(&new_cpus, &new_cpus,
+					top_cpuset.isolated_cpus);
 		cpumask_copy(top_cpuset.effective_cpus, &new_cpus);
 		spin_unlock_irq(&callback_lock);
 		/* we don't mess with cpumasks of tasks in top_cpuset */
Signature · 1 line
1.8.3.1
#19 lore raw
In reply to Waiman Long
Quoted 6 lines · Waiman Long

v7:
- Add a root-only cpuset.cpus.isolated control file for CPU isolation.
- Enforce that load_balancing can only be turned off on cpusets with CPUs from the isolated list.
- Update sched domain generation to allow cpusets with CPUs only from the isolated CPU list to be in separate root domains.

I haven't done much, but was able to do a q/d manual build, populate and teardown of system/critical sets on my desktop box, and it looked ok. Thanks for getting this aboard the v2 boat.

-Mike

author maintainer
#20 lore raw
Quoted 7 lines · Mike Galbraith
Quoted 6 lines · Waiman Long

v7:
- Add a root-only cpuset.cpus.isolated control file for CPU isolation.
- Enforce that load_balancing can only be turned off on cpusets with CPUs from the isolated list.
- Update sched domain generation to allow cpusets with CPUs only from the isolated CPU list to be in separate root domains.

Quoted 5 lines

I haven't done much, but was able to do a q/d manual build, populate and teardown of system/critical sets on my desktop box, and it looked ok. Thanks for getting this aboard the v2 boat.

-Mike

Thank for the testing.

Cheers,
Longman

#21 lore raw
In reply to Waiman Long

Hi Waiman,

Quoted 6 lines · Waiman Long

v7:
- Add a root-only cpuset.cpus.isolated control file for CPU isolation.
- Enforce that load_balancing can only be turned off on cpusets with CPUs from the isolated list.
- Update sched domain generation to allow cpusets with CPUs only from the isolated CPU list to be in separate root domains.

Just got this while

# echo 2-3 > /sys/fs/cgroup/cpuset.cpus.isolated
[ 6679.177826] =============================
[ 6679.178385] WARNING: suspicious RCU usage
[ 6679.178910] 4.16.0-rc6+ #151 Not tainted
[ 6679.179459] -----------------------------
[ 6679.180082] /home/juri/work/kernel/linux/kernel/cgroup/cgroup.c:3826 cgroup_mutex or RCU read lock required!
[ 6679.181402]
[ 6679.181402] other info that might help us debug this:
[ 6679.181402]
[ 6679.182407]
[ 6679.182407] rcu_scheduler_active = 2, debug_locks = 1
[ 6679.183278] 3 locks held by bash/2205:
[ 6679.183785]  #0:  (sb_writers#10){.+.+}, at: [<000000004e577fb9>] vfs_write+0x18a/0x1b0
[ 6679.184871]  #1:  (&of->mutex){+.+.}, at: [<000000005944c83f>] kernfs_fop_write+0xe2/0x1a0
[ 6679.185987]  #2:  (cpuset_mutex){+.+.}, at: [<00000000879bfba0>] cpuset_write_resmask+0x72/0x1560
[ 6679.187112]
[ 6679.187112] stack backtrace:
[ 6679.187612] CPU: 3 PID: 2205 Comm: bash Not tainted 4.16.0-rc6+ #151
[ 6679.188318] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 04/01/2014
[ 6679.189291] Call Trace:
[ 6679.189581]  dump_stack+0x85/0xc5
[ 6679.189963]  css_next_child+0x90/0xd0
[ 6679.190385]  cpuset_write_resmask+0x46f/0x1560
[ 6679.190885]  ? lock_acquire+0x9f/0x210
[ 6679.191315]  cgroup_file_write+0x94/0x230
[ 6679.191768]  kernfs_fop_write+0x113/0x1a0
[ 6679.192223]  __vfs_write+0x36/0x180
[ 6679.192617]  ? rcu_read_lock_sched_held+0x6b/0x80
[ 6679.193139]  ? rcu_sync_lockdep_assert+0x2e/0x60
[ 6679.193654]  ? __sb_start_write+0x154/0x1f0
[ 6679.194118]  ? __sb_start_write+0x16a/0x1f0
[ 6679.194607]  vfs_write+0xc1/0x1b0
[ 6679.194984]  SyS_write+0x55/0xc0
[ 6679.195365]  ? trace_hardirqs_off_thunk+0x1a/0x1c
[ 6679.195839]  do_syscall_64+0x79/0x220
[ 6679.196212]  entry_SYSCALL_64_after_hwframe+0x42/0xb7
[ 6679.196729] RIP: 0033:0x7f03183ff780
[ 6679.197138] RSP: 002b:00007ffeae336ca8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 6679.197866] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f03183ff780
[ 6679.198550] RDX: 0000000000000004 RSI: 0000000000eaf408 RDI: 0000000000000001
[ 6679.199235] RBP: 0000000000eaf408 R08: 000000000000000a R09: 00007f0318cff700
[ 6679.199928] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f03186b57a0
[ 6679.200615] R13: 0000000000000004 R14: 0000000000000001 R15: 0000000000000000
[ 6679.201369] rebuild_sched_domains dom 0: 0-1
[ 6679.202196] span: 0-1 (max cpu_capacity = 1024)

Guess we should grab either lock from the writing path.

Best,

- Juri

#22 lore raw
Quoted 10 lines · Juri Lelli

Hi Waiman,

Quoted 6 lines · Waiman Long

v7:
- Add a root-only cpuset.cpus.isolated control file for CPU isolation.
- Enforce that load_balancing can only be turned off on cpusets with CPUs from the isolated list.
- Update sched domain generation to allow cpusets with CPUs only from the isolated CPU list to be in separate root domains.

Guess I'll be adding comments as soon as I stumble on something unclear (to me :), hope that's OK (shout if I should do it differently).

The below looked unexpected to me:

root@debian-kvm:/sys/fs/cgroup# cat g1/cpuset.cpus
2-3
root@debian-kvm:/sys/fs/cgroup# cat g1/cpuset.mems
root@debian-kvm:~# echo $$ > /sys/fs/cgroup/g1/cgroup.threads
root@debian-kvm:/sys/fs/cgroup# cat g1/cgroup.threads
2312

So I can add tasks to groups with no mems? Or is it this only true in my case with a single mem node? Or maybe it's inherited from root group (slightly confusing IMHO if that's the case).

author maintainer
#23 lore raw
Quoted 19 lines · Juri Lelli
Quoted 9 lines · Juri Lelli

Hi Waiman,

Quoted 6 lines · Waiman Long

v7:
- Add a root-only cpuset.cpus.isolated control file for CPU isolation.
- Enforce that load_balancing can only be turned off on cpusets with CPUs from the isolated list.
- Update sched domain generation to allow cpusets with CPUs only from the isolated CPU list to be in separate root domains.

Guess I'll be adding comments as soon as I stumble on something unclear (to me :), hope that's OK (shout if I should do it differently).

The below looked unexpected to me:

root@debian-kvm:/sys/fs/cgroup# cat g1/cpuset.cpus
2-3
root@debian-kvm:/sys/fs/cgroup# cat g1/cpuset.mems
Quoted 7 lines
root@debian-kvm:~# echo $$ > /sys/fs/cgroup/g1/cgroup.threads
root@debian-kvm:/sys/fs/cgroup# cat g1/cgroup.threads
2312

So I can add tasks to groups with no mems? Or is it this only true in my case with a single mem node? Or maybe it's inherited from root group (slightly confusing IMHO if that's the case).

No mems mean looking up the parents until we find one with non-empty mems. The mems.effective will show you the actual memory nodes used.

-Longman