Skip to contentSkip to conversation

cpuset: Enable cpuset controller in default hierarchy

PATCH Superseded Waiman Long 3 participants 45 messages Jun 24, 2018 – Aug 18, 2018

Subsystems (3)

v11 of 15 Superseded Latest is v15 →

lore
Share & tools
lore

Waiman Long

author maintainer
#0 lore raw

v11 cover cpuset: Enable cpuset controller in default hierarchy

v11:
- Change the "domain_root" name to "partition" as suggested by Peter and update the documentation and code accordingly.
- Remove the dying cgroup check in update_reserved_cpus() as the check may not be needed after all.
- Document the effect of losing CPU affinity after offling all the cpus in a partition.
- There is no other major code changes in this version.

v10:
- Remove the cpuset.sched.load_balance patch for now as it may not be that useful.
- Break the large patch 2 into smaller patches to make them a bit easier to review.
- Test and fix issues related to changing "cpuset.cpus" and cpu online/offline in a domain root.
- Rename isolated_cpus to reserved_cpus as this cpumask holds CPUs reserved for child sched domains.
- Rework the scheduling domain debug printing code in the last patch.
- Document update to the newly moved Documentation/admin-guide/cgroup-v2.rst.

v9:
- Rename cpuset.sched.domain to cpuset.sched.domain_root to better identify its purpose as the root of a new scheduling domain or partition.
- Clarify in the document about the purpose of domain_root and load_balance. Using domain_root is th only way to create new partition.
- Fix a lockdep warning in update_isolated_cpumask() function.
- Add a new patch to eliminate call to generate_sched_domains() for v2 when a change in cpu list does not touch a domain_root.

v8:
- Remove cpuset.cpus.isolated and add a new cpuset.sched.domain flag and rework the code accordingly.

v8 patch : https://lkml.org/lkml/2018/5/17/939
v9 patch : https://lkml.org/lkml/2018/5/29/507
v10 patch: https://lkml.org/lkml/2018/6/18/3

The purpose of this patchset is to provide a basic set of cpuset control files for cgroup v2. This basic set includes the non-root "cpus", "mems" and "sched.partition". The "cpus.effective" and "mems.effective" will appear in all cpuset-enabled cgroups.

The new control file that is unique to v2 is "sched.partition". It is a boolean flag file that designates if a cgroup is the root of a new scheduling domain or partition with its own set of unique list of CPUs from scheduling perspective disjointed from other partitions. The root cgroup is always a partition root. Multiple levels of partitions are supported with some limitations. So a container partition root can behave like a real root.

When a partition root cgroup is removed, its list of exclusive CPUs will be returned to the parent's cpus.effective automatically.

A container root can be a partition root with sub-partitions created underneath it. One difference from the real root is that the "cpuset.sched.partition" flag isn't present in the real root, but is present in a container root. This is also true for other cpuset control files as well as those from the other controllers. This is a general issue that is not going to be addressed here in this patchset.

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 a new "sched.partition" control file for setting up multiple scheduling domains or partitions. A partition root implies cpu_exclusive.

Patch 3 handles the proper deletion of a partition root cgroup by turning off the partition flag automatically before deletion.

Patch 4 allows "cpuset.cpus" of a partition root cgroup to be changed subject to certain constraints.

Patch 5 makes the hotplug code deal with partition root properly.

Patch 6 updates the scheduling domain genaration code to work with the new domain root feature.

Patch 7 exposes cpus.effective and mems.effective to the root cgroup as enabling child scheduling domains will take CPUs away from the root cgroup. So it will be nice to monitor what CPUs are left there.

Patch 8 eliminates the need to rebuild sched domains for v2 if cpu list changes occur to non-domain root cpusets only.

Patch 9 enables the printing the debug information about scheduling domain generation. This patch is optional and is mainly for testing purpose only, it may not need to be merged.

Waiman Long (9):
cpuset: Enable cpuset controller in default hierarchy
cpuset: Add new v2 cpuset.sched.partition flag
cpuset: Simulate auto-off of sched.partition at cgroup removal
cpuset: Allow changes to cpus in a partition root
cpuset: Make sure that partition flag work properly with CPU hotplug
cpuset: Make generate_sched_domains() recognize reserved_cpus
cpuset: Expose cpus.effective and mems.effective on cgroup v2 root
cpuset: Don't rebuild sched domains if cpu changes in non-partition
root
cpuset: Allow reporting of sched domain generation info

 Documentation/admin-guide/cgroup-v2.rst | 161 ++++++++++++-
 kernel/cgroup/cpuset.c                  | 397 ++++++++++++++++++++++++++++++--
 2 files changed, 537 insertions(+), 21 deletions(-)
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH v11 1/9 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/admin-guide/cgroup-v2.rst | 109 ++++++++++++++++++++++++++++++--
 kernel/cgroup/cpuset.c                  |  48 +++++++++++++-
 2 files changed, 149 insertions(+), 8 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +104 -5
index 8a2c52d..fbc30b6 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
@@ -1486,6 +1488,103 @@ 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
+	cpuset-enabled cgroups.
+
+	It lists the requested CPUs to be used by tasks within this
+	cgroup.  The actual list of CPUs to be granted, however, is
+	subjected to constraints imposed by its parent and can differ
+	from the requested CPUs.
+
+	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
+	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".
+
+	Its value will be affected by CPU hotplug events.
+
+  cpuset.mems
+	A read-write multiple values file which exists on non-root
+	cpuset-enabled cgroups.
+
+	It lists the requested memory nodes to be used by tasks within
+	this cgroup.  The actual list of memory nodes granted, however,
+	is subjected to constraints imposed by its parent and can differ
+	from the requested memory nodes.
+
+	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
+	cpuset-enabled cgroups.
+
+	It lists the onlined memory nodes that are actually granted to
+	this cgroup by its parent. These memory nodes are 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 should be a subset of "cpuset.mems" unless none of
+	the memory nodes listed in "cpuset.mems" can be granted.  In this
+	case, it will be treated just like an empty "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 v11 2/9 cpuset: Add new v2 cpuset.sched.partition flag

In reply to Waiman Long

A new cpuset.sched.partition boolean flag is added to cpuset v2. This new flag, if set, indicates that the cgroup is the root of a new scheduling domain or partition that includes itself and all its descendants except those that are scheduling domain roots themselves and their descendants.

With this new flag, one can directly create as many partitions as necessary without ever using the v1 trick of turning off load balancing in specific cpusets to create partitions as a side effect.

This new flag is owned by the parent and will cause the CPUs in the cpuset to be removed from the effective CPUs of its parent.

This is implemented internally by adding a new reserved_cpus mask that holds the CPUs belonging to child scheduling domain cpusets so that:

reserved_cpus | effective_cpus = cpus_allowed reserved_cpus & effective_cpus = 0

This new flag can only be turned on in a cpuset if its parent is a partition root itself. The state of this flag cannot be changed if the cpuset has children.

---
 Documentation/admin-guide/cgroup-v2.rst |  33 +++++
 kernel/cgroup/cpuset.c                  | 209 +++++++++++++++++++++++++++++++-
 2 files changed, 239 insertions(+), 3 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +33 -0
index fbc30b6..24a7133 100644
@@ -1584,6 +1584,39 @@ Cpuset Interface Files
 
 	Its value will be affected by memory nodes hotplug events.
 
+  cpuset.sched.partition
+	A read-write single value file which exists on non-root
+	cpuset-enabled cgroups.  It is a binary value flag that accepts
+	either "0" (off) or "1" (on).  This flag is set and owned by the
+        parent cgroup.
+
+	If set, it indicates that the current cgroup is the root of a
+	new partition or scheduling domain that comprises itself and
+	all its descendants except those that are separate partition
+        roots themselves and their descendants.  The root cgroup is
+	always a partition root.
+
+	There are constraints on where this flag can be set.  It can
+	only be set in a cgroup if all the following conditions are true.
+
+	1) The "cpuset.cpus" is not empty and the list of CPUs are
+	   exclusive, i.e. they are not shared by any of its siblings.
+	2) The "cpuset.cpus" is also a proper subset of the parent's
+	   "cpuset.cpus.effective".
+	3) The parent cgroup is a partition root.
+	4) There is no child cgroups with cpuset enabled.  This is for
+	   eliminating corner cases that have to be handled if such a
+	   condition is allowed.
+
+	Setting this flag will take the CPUs away from the effective
+	CPUs of the parent cgroup.  That is why this flag has to be set
+        and owned by the parent.  Once it is set, this flag cannot be
+	cleared if there are any child cgroups with cpuset enabled.
+
+	A parent partition root cgroup cannot distribute all its CPUs to
+        its child partition root cgroups.  There must be at least one cpu
+        left in the parent partition root cgroup.
+
 
 Device controller
 -----------------
kernel/cgroup/cpuset.c +206 -3

309 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author maintainer
#3 lore raw

PATCH v11 3/9 cpuset: Simulate auto-off of sched.partition at cgroup removal

In reply to Waiman Long

Making a cgroup a partition root will reserve cpu resource at its parent. So when a partition root cgroup is destroyed, we need to free the reserved cpus at its parent. This is now done by doing an auto-off of the sched.partition flag in the offlining phase when a partition root cgroup is being removed.

---
 kernel/cgroup/cpuset.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +18 -2
index 5989bff..e902f54 100644
@@ -2278,7 +2278,12 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
 /*
  * If the cpuset being removed has its flag 'sched_load_balance'
  * enabled, then simulate turning sched_load_balance off, which
- * will call rebuild_sched_domains_locked().
+ * will call rebuild_sched_domains_locked(). That is not needed
+ * in the default hierarchy where only changes in partition
+ * will cause repartitioning.
+ *
+ * If the cpuset has the 'sched.partition' flag enabled, simulate
+ * turning 'sched.partition" off.
  */
 
 static void cpuset_css_offline(struct cgroup_subsys_state *css)
@@ -2287,7 +2292,18 @@ static void cpuset_css_offline(struct cgroup_subsys_state *css)
 
 	mutex_lock(&cpuset_mutex);
 
-	if (is_sched_load_balance(cs))
+	/*
+	 * A WARN_ON_ONCE() check after calling update_flag() to make
+	 * sure that the operation succceeds without failure.
+	 */
+	if (is_partition_root(cs)) {
+		int ret = update_flag(CS_PARTITION_ROOT, cs, 0);
+
+		WARN_ON_ONCE(ret);
+	}
+
+	if (!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) &&
+	    is_sched_load_balance(cs))
 		update_flag(CS_SCHED_LOAD_BALANCE, cs, 0);
 
 	cpuset_dec();
Signature · 1 line
1.8.3.1
author maintainer
#4 lore raw

PATCH v11 4/9 cpuset: Allow changes to cpus in a partition root

In reply to Waiman Long

The previous patch introduces a new partition flag, but won't allow changes made to "cpuset.cpus" once the flag is on. That may be too restrictive in some use cases. So this restiction is now relaxed to allow changes made to the "cpuset.cpus" file with some constraints:

1) The new set of cpus must still be exclusive.
2) Newly added cpus must be a subset of the parent effective_cpus.
3) None of the deleted cpus can be one of those allocated to a child partition roots, if present.

---
 Documentation/admin-guide/cgroup-v2.rst |  9 ++++
 kernel/cgroup/cpuset.c                  | 80 ++++++++++++++++++++++++++-------
 2 files changed, 72 insertions(+), 17 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +9 -0
index 24a7133..5f3170f 100644
@@ -1617,6 +1617,15 @@ Cpuset Interface Files
         its child partition root cgroups.  There must be at least one cpu
         left in the parent partition root cgroup.
 
+	In a partition root, changes to "cpuset.cpus" is allowed as long
+	as the first condition above as well as the following two
+	additional conditions are true.
+
+	1) Any added CPUs must be a proper subset of the parent's
+	   "cpuset.cpus.effective".
+	2) No CPU that has been distributed to child partition roots is
+	   is deleted.
+
 
 Device controller
 -----------------
kernel/cgroup/cpuset.c +63 -17

173 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author maintainer
#5 lore raw

PATCH v11 5/9 cpuset: Make sure that partition flag work properly with CPU hotplug

In reply to Waiman Long

When there is a cpu hotplug event (CPU online or offline), the partitions may need to be reconfigured and regenerated. So code is added to the hotplug functions to make them work with new reserved_cpus mask to compute the right effective_cpus for each of the affected cpusets.

---
 Documentation/admin-guide/cgroup-v2.rst | 10 ++++++++++
 kernel/cgroup/cpuset.c                  | 26 ++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +10 -0
index 5f3170f..f4efa40 100644
@@ -1626,6 +1626,16 @@ Cpuset Interface Files
 	2) No CPU that has been distributed to child partition roots is
 	   is deleted.
 
+	When all the CPUs allocated to a partition are offlined, the
+	partition will be temporaily gone and all the tasks in it will
+	be migrated to another one that belongs to the parent of the
+	partition root.  This is a destructive operation and all the
+	existing CPU affinity that is narrower than the cpuset itself
+	will be lost.
+
+	When any of those offlined CPUs is onlined again, a new partition
+	will be re-created and the tasks will be migrated back.
+
 
 Device controller
 -----------------
kernel/cgroup/cpuset.c +24 -2
index 3a646a9..e118dd8 100644
@@ -900,7 +900,8 @@ static void update_tasks_cpumask(struct cpuset *cs)
  * @parent: the parent cpuset
  *
  * If the parent has reserved CPUs, include them in the list of allowable
- * CPUs in computing the new effective_cpus mask.
+ * CPUs in computing the new effective_cpus mask. The cpu_active_mask is
+ * used to mask off cpus that are to be offlined.
  */
 static void compute_effective_cpumask(struct cpumask *new_cpus,
 				      struct cpuset *cs, struct cpuset *parent)
@@ -909,6 +910,7 @@ static void compute_effective_cpumask(struct cpumask *new_cpus,
 		cpumask_or(new_cpus, parent->effective_cpus,
 			   parent->reserved_cpus);
 		cpumask_and(new_cpus, new_cpus, cs->cpus_allowed);
+		cpumask_and(new_cpus, new_cpus, cpu_active_mask);
 	} else {
 		cpumask_and(new_cpus, cs->cpus_allowed, parent->effective_cpus);
 	}
@@ -2562,9 +2564,17 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs)
 		goto retry;
 	}
 
-	cpumask_and(&new_cpus, cs->cpus_allowed, parent_cs(cs)->effective_cpus);
+	compute_effective_cpumask(&new_cpus, cs, parent_cs(cs));
 	nodes_and(new_mems, cs->mems_allowed, parent_cs(cs)->effective_mems);
 
+	if (cs->nr_reserved) {
+		/*
+		 * Some of the CPUs may have been distributed to child
+		 * partition roots. So we need skip those when computing the
+		 * real effective cpus.
+		 */
+		cpumask_andnot(&new_cpus, &new_cpus, cs->reserved_cpus);
+	}
 	cpus_updated = !cpumask_equal(&new_cpus, cs->effective_cpus);
 	mems_updated = !nodes_equal(new_mems, cs->effective_mems);
 
@@ -2614,6 +2624,11 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
 	cpumask_copy(&new_cpus, cpu_active_mask);
 	new_mems = node_states[N_MEMORY];
 
+	/*
+	 * If reserved_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);
 
@@ -2622,6 +2637,13 @@ 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);
+		/*
+		 * Make sure that the reserved cpus aren't in the
+		 * effective cpus.
+		 */
+		if (top_cpuset.nr_reserved)
+			cpumask_andnot(&new_cpus, &new_cpus,
+					top_cpuset.reserved_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
author maintainer
#6 lore raw

PATCH v11 6/9 cpuset: Make generate_sched_domains() recognize reserved_cpus

In reply to Waiman Long

The generate_sched_domains() function is modified to make it work correctly with the newly introduced reserved_cpus mask for schedule domains generation.

---
 kernel/cgroup/cpuset.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/cgroup/cpuset.c +20 -4
index e118dd8..e545848 100644
@@ -672,13 +672,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.nr_reserved) {
 		ndoms = 1;
 		doms = alloc_sched_domains(ndoms);
 		if (!doms)
@@ -701,6 +702,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;
@@ -711,6 +714,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) &&
@@ -718,11 +724,16 @@ 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;
 
-		/* skip @cp's subtree */
-		pos_css = css_rightmost_descendant(pos_css);
+		/* skip @cp's subtree if not a partition root */
+		if (!is_partition_root(cp))
+			pos_css = css_rightmost_descendant(pos_css);
 	}
 	rcu_read_unlock();
 
@@ -850,7 +861,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.nr_reserved &&
+	    !cpumask_equal(top_cpuset.effective_cpus, cpu_active_mask))
+		goto out;
+
+	if (top_cpuset.nr_reserved &&
+	   !cpumask_subset(top_cpuset.effective_cpus, cpu_active_mask))
 		goto out;
 
 	/* Generate domain masks and attrs */
Signature · 1 line
1.8.3.1
author maintainer
#7 lore raw

PATCH v11 7/9 cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Waiman Long

Because of the fact that setting the "cpuset.sched.partition" in a direct child of root can remove CPUs from the root's effective CPU list, it makes sense to know what CPUs are left in the root cgroup for scheduling purpose. So the "cpuset.cpus.effective" control file is now exposed in the v2 cgroup root.

For consistency, the "cpuset.mems.effective" control file is exposed as well.

---
 Documentation/admin-guide/cgroup-v2.rst | 4 ++--
 kernel/cgroup/cpuset.c                  | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +2 -2
index f4efa40..f7cde15 100644
@@ -1529,7 +1529,7 @@ Cpuset Interface Files
 	and won't be affected by any CPU hotplug events.
 
   cpuset.cpus.effective
-	A read-only multiple values file which exists on non-root
+	A read-only multiple values file which exists on all
 	cpuset-enabled cgroups.
 
 	It lists the onlined CPUs that are actually granted to this
@@ -1569,7 +1569,7 @@ Cpuset Interface Files
 	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
+	A read-only multiple values file which exists on all
 	cpuset-enabled cgroups.
 
 	It lists the onlined memory nodes that are actually granted to
kernel/cgroup/cpuset.c +0 -2
index e545848..9097e9d 100644
@@ -2216,14 +2216,12 @@ static s64 cpuset_read_s64(struct cgroup_subsys_state *css, struct cftype *cft)
 		.name = "cpus.effective",
 		.seq_show = cpuset_common_seq_show,
 		.private = FILE_EFFECTIVE_CPULIST,
-		.flags = CFTYPE_NOT_ON_ROOT,
 	},
 
 	{
 		.name = "mems.effective",
 		.seq_show = cpuset_common_seq_show,
 		.private = FILE_EFFECTIVE_MEMLIST,
-		.flags = CFTYPE_NOT_ON_ROOT,
 	},
 
 	{
Signature · 1 line
1.8.3.1
author maintainer
#41 lore raw

PATCH v11 8/9 cpuset: Don't rebuild sched domains if cpu changes in non-partition root

In reply to Waiman Long

With the cpuset v1, any changes to the list of allowable CPUs in a cpuset may cause changes in the sched domain configuration depending on the load balancing states and the cpu lists of its parent and its children.

With cpuset v2 (on default hierarchy), there are more restrictions on how the load balancing state of a cpuset can change. As a result, only changes made in a partition root will cause possible changes to the corresponding sched domain. CPU changes to any of the non-partition root cpusets will not cause changes in the sched domain configuration. As a result, we don't need to call rebuild_sched_domains_locked() for changes in a non-partition root cpuset saving precious cpu cycles.

---
 kernel/cgroup/cpuset.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
kernel/cgroup/cpuset.c +7 -3
index 9097e9d..07a5575 100644
@@ -986,11 +986,15 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
 		update_tasks_cpumask(cp);
 
 		/*
-		 * If the effective cpumask of any non-empty cpuset is changed,
-		 * we need to rebuild sched domains.
+		 * On legacy hierarchy, if the effective cpumask of any non-
+		 * empty cpuset is changed, we need to rebuild sched domains.
+		 * On default hierarchy, the cpuset needs to be a partition
+		 * root as well.
 		 */
 		if (!cpumask_empty(cp->cpus_allowed) &&
-		    is_sched_load_balance(cp))
+		    is_sched_load_balance(cp) &&
+		   (!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) ||
+		    is_partition_root(cp)))
 			need_rebuild_sched_domains = true;
 
 		rcu_read_lock();
Signature · 1 line
1.8.3.1
author maintainer
#42 lore raw

PATCH v11 9/9 cpuset: Allow reporting of sched domain generation info

In reply to Waiman Long

This patch enables us to report sched domain generation information.

If DYNAMIC_DEBUG is enabled, issuing the following command

echo "file cpuset.c +p" > /sys/kernel/debug/dynamic_debug/control

and setting loglevel to 8 will allow the kernel to show what scheduling domain changes are being made.

---
 kernel/cgroup/cpuset.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
kernel/cgroup/cpuset.c +18 -0
index 07a5575..62b7e61 100644
@@ -836,6 +836,23 @@ static int generate_sched_domains(cpumask_var_t **domains,
 	return ndoms;
 }
 
+#ifdef CONFIG_DEBUG_KERNEL
+static inline void debug_print_domains(cpumask_var_t *doms, int ndoms)
+{
+	int i;
+	char buf[200];
+	char *ptr, *end = buf + sizeof(buf) - 1;
+
+	for (i = 0, ptr = buf, *end = '\0'; i < ndoms; i++)
+		ptr += snprintf(ptr, end - ptr, "dom%d=%*pbl ", i,
+				cpumask_pr_args(doms[i]));
+
+	pr_debug("Generated %d domains: %s\n", ndoms, buf);
+}
+#else
+static inline void debug_print_domains(cpumask_var_t *doms, int ndoms) { }
+#endif
+
 /*
  * Rebuild scheduler domains.
  *
@@ -871,6 +888,7 @@ static void rebuild_sched_domains_locked(void)
 
 	/* Generate domain masks and attrs */
 	ndoms = generate_sched_domains(&doms, &attr);
+	debug_print_domains(doms, ndoms);
 
 	/* Have scheduler rebuild the domains */
 	partition_sched_domains(ndoms, doms, attr);
Signature · 1 line
1.8.3.1
maintainer
#8 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Waiman Long

Hello, Waiman.

Quoted 5 lines · Waiman Long

Because of the fact that setting the "cpuset.sched.partition" in a direct child of root can remove CPUs from the root's effective CPU list, it makes sense to know what CPUs are left in the root cgroup for scheduling purpose. So the "cpuset.cpus.effective" control file is now exposed in the v2 cgroup root.

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

It's a bit different because the way partition behaves is different from other resource konbs in that it locks away those cpus so that they can't be taken back.

What do people think about restricting partition to the first level children for now at least? That way we aren't locked into the special semantics and we can figure out how to this down the hierarchy later. Given that we ignore the regular cpuset settings when the set goes empty (which also is a special condition which only exists for cpuset) and inherits the parent's, I think the consistent thing to do is doing the same for partition - if it can't be satisfied, ignore it, but maybe there is a better way.

Thanks.

Signature · 1 line
tejun
author maintainer
#9 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 8 lines · Tejun Heo

Hello, Waiman.

Quoted 5 lines · Waiman Long

Because of the fact that setting the "cpuset.sched.partition" in a direct child of root can remove CPUs from the root's effective CPU list, it makes sense to know what CPUs are left in the root cgroup for scheduling purpose. So the "cpuset.cpus.effective" control file is now exposed in the v2 cgroup root.

Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Quoted 4 lines

It's a bit different because the way partition behaves is different from other resource konbs in that it locks away those cpus so that they can't be taken back.

Quoted 8 lines

What do people think about restricting partition to the first level children for now at least? That way we aren't locked into the special semantics and we can figure out how to this down the hierarchy later. Given that we ignore the regular cpuset settings when the set goes empty (which also is a special condition which only exists for cpuset) and inherits the parent's, I think the consistent thing to do is doing the same for partition - if it can't be satisfied, ignore it, but maybe there is a better way.

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

Cheers,
Longman

maintainer
#10 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello, Waiman.

Quoted 9 lines · Waiman Long
Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Yeah, that should work.

Quoted 4 lines

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

As currently implemented, partioning locks away the cpus which should be a system level decision, not container level, so it makes sense to me that it is only available to system root.

Thanks.

Signature · 1 line
tejun
author maintainer
#11 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 7 lines · Tejun Heo

Hello, Waiman.

Quoted 4 lines · Waiman Long
Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Quoted 6 lines
Quoted 4 lines

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Yeah, that should work.

Thinking about it a bit more, that approach will make creating a partition a multi-step process:

1) Reserve the CPUs in reserved_cpus.
2) enable sched.partition
3) Write the CPUs list into cpus.

There are also more exception cases that need to be handled. The current approach, on the other hands, is much simpler and easier to understand and use.

Quoted 7 lines
Quoted 4 lines

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

As currently implemented, partioning locks away the cpus which should be a system level decision, not container level, so it makes sense to me that it is only available to system root.

So my preference is to allow partition only on the first level children of the root for the time being. I think it should cover most of the use cases. I will update the patchset to reflect that.

Cheers,
Longman

author maintainer
#12 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 32 lines · Waiman Long
Quoted 7 lines · Tejun Heo

Hello, Waiman.

Quoted 4 lines · Waiman Long
Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Quoted 6 lines
Quoted 4 lines

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Yeah, that should work.

Thinking about it a bit more, that approach will make creating a partition a multi-step process:

1) Reserve the CPUs in reserved_cpus.
2) enable sched.partition
3) Write the CPUs list into cpus.

There are also more exception cases that need to be handled. The current approach, on the other hands, is much simpler and easier to understand and use.

Quoted 7 lines
Quoted 4 lines

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

As currently implemented, partioning locks away the cpus which should be a system level decision, not container level, so it makes sense to me that it is only available to system root.

Quoted 7 lines

So my preference is to allow partition only on the first level children of the root for the time being. I think it should cover most of the use cases. I will update the patchset to reflect that.

Cheers,
Longman

Below is the incremental patch that allow partitioning only on the first level children of the root. Please let me know your thourght on that.

Thanks,
Longman

-------------[ Cut here ]-------------------------

From 5a41209da94385efff87d79f6523265c710cbea5 Mon Sep 17 00:00:00 2001
From: Waiman Long <[email protected]>
Date: Tue, 10 Jul 2018 10:23:16 -0400
Subject: [PATCH v11 10/10] cpuset: Restrict sched.partition to first level
children of root only

Enabling partition on a v2 cpuset has the side effect of affecting the effective CPUs of its parent which is currently unique to partitioning. As we are not sure about the repercussion of enabling that globally, we are now restricting the enabling of sched.partition to the first level children of the root cgroup in the default hierarchy.

This is done by removing the "cpuset.sched.partition" control file on cgroups that are not the first level children of the root. A new show_cfile function pointer is added to the cftype structure. If it is defined, it will be called to return a boolean value to determine if the corresponding control file should show up in the cgroup. It provides a more flexible mechanism to determine the visibility of the control file than a simple CFTYPE_* flag can do.

---
 Documentation/admin-guide/cgroup-v2.rst | 10 +++++-----
 include/linux/cgroup-defs.h             |  9 +++++++++
 kernel/cgroup/cgroup.c                  |  4 ++++
 kernel/cgroup/cpuset.c                  | 10 ++++++++++
 4 files changed, 28 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/Documentation/admin-guide/cgroup-v2.rst
index f7cde15..cf7cd88 100644

Documentation/admin-guide/cgroup-v2.rst +5 -5
@@ -1585,10 +1585,10 @@ Cpuset Interface Files
     Its value will be affected by memory nodes hotplug events.
 
   cpuset.sched.partition
-    A read-write single value file which exists on non-root
-    cpuset-enabled cgroups.  It is a binary value flag that accepts
-    either "0" (off) or "1" (on).  This flag is set and owned by the
-        parent cgroup.
+    A read-write single value file which exists on the first level
+    children of the root cgroup.  It is a binary value flag that
+    accepts either "0" (off) or "1" (on).  This flag is set and
+    owned by the parent cgroup.
 
     If set, it indicates that the current cgroup is the root of a
     new partition or scheduling domain that comprises itself and
@@ -1603,7 +1603,7 @@ Cpuset Interface Files
        exclusive, i.e. they are not shared by any of its siblings.
     2) The "cpuset.cpus" is also a proper subset of the parent's
        "cpuset.cpus.effective".
-    3) The parent cgroup is a partition root.
+    3) The parent cgroup is the root cgroup.
     4) There is no child cgroups with cpuset enabled.  This is for
        eliminating corner cases that have to be handled if such a
        condition is allowed.
include/linux/cgroup-defs.h +9 -0
index c0e68f9..be79487 100644
@@ -565,6 +565,15 @@ struct cftype {
     ssize_t (*write)(struct kernfs_open_file *of,
              char *buf, size_t nbytes, loff_t off);
 
+    /*
+     * show_cfile(), if defined, will return a boolean value to
+     * determine if the control file should show up in the cgroup.
+     * It provides more flexibility in deciding where the control
+     * file should appear than simple criteria like on-root or
+     * not-on-root.
+     */
+    bool (*show_cfile)(struct cgroup_subsys_state *css);
+
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
     struct lock_class_key    lockdep_key;
 #endif
kernel/cgroup/cgroup.c +0 -0
index 077370b..0afdab8 100644
@@ -3612,6 +3612,10 @@ static int cgroup_addrm_files(struct

cgroup_subsys_state *css,

         if ((cft->flags & CFTYPE_ONLY_ON_ROOT) && cgroup_parent(cgrp))
             continue;

+ /* Should the control file show up in the cgroup */
+ if (cft->show_cfile && !cft->show_cfile(css))
+ continue;
+

         if (is_add) {
             ret = cgroup_add_file(css, cgrp, cft);
             if (ret) {
kernel/cgroup/cpuset.c +0 -0
index 62b7e61..2f85c1e 100644
@@ -2106,6 +2106,15 @@ static s64 cpuset_read_s64(struct

cgroup_subsys_state *css, struct cftype *cft)
}

/*
+ * The sched.partition control file should only show up in the first
+ * level children of the root cgroup.
+ */
+static bool cpuset_show_partition(struct cgroup_subsys_state *css) +{
+ return parent_cs(css_cs(css)) == &top_cpuset;
+}
+
+/*
* for the common functions, 'private' gives the type of file */

@@ -2250,6 +2259,7 @@ static s64 cpuset_read_s64(struct cgroup_subsys_state *css, struct cftype *cft)

         .name = "sched.partition",
         .read_u64 = cpuset_read_u64,
         .write_u64 = cpuset_write_u64,

+ .show_cfile = cpuset_show_partition,
.private = FILE_PARTITION_ROOT,
.flags = CFTYPE_NOT_ON_ROOT,
},

Signature · 1 line
1.8.3.1
author maintainer
#13 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 170 lines · Waiman Long
Quoted 32 lines · Waiman Long
Quoted 7 lines · Tejun Heo

Hello, Waiman.

Quoted 4 lines · Waiman Long
Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Quoted 6 lines
Quoted 4 lines

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Yeah, that should work.

Thinking about it a bit more, that approach will make creating a partition a multi-step process:

1) Reserve the CPUs in reserved_cpus.
2) enable sched.partition
3) Write the CPUs list into cpus.

There are also more exception cases that need to be handled. The current approach, on the other hands, is much simpler and easier to understand and use.

Quoted 7 lines
Quoted 4 lines

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

As currently implemented, partioning locks away the cpus which should be a system level decision, not container level, so it makes sense to me that it is only available to system root.

Quoted 7 lines

So my preference is to allow partition only on the first level children of the root for the time being. I think it should cover most of the use cases. I will update the patchset to reflect that.

Cheers,
Longman

Below is the incremental patch that allow partitioning only on the first level children of the root. Please let me know your thourght on that.

Thanks,
Longman

-------------[ Cut here ]-------------------------

From 5a41209da94385efff87d79f6523265c710cbea5 Mon Sep 17 00:00:00 2001
From: Waiman Long <[email protected]>
Date: Tue, 10 Jul 2018 10:23:16 -0400
Subject: [PATCH v11 10/10] cpuset: Restrict sched.partition to first level
children of root only

Enabling partition on a v2 cpuset has the side effect of affecting the effective CPUs of its parent which is currently unique to partitioning. As we are not sure about the repercussion of enabling that globally, we are now restricting the enabling of sched.partition to the first level children of the root cgroup in the default hierarchy.

This is done by removing the "cpuset.sched.partition" control file on cgroups that are not the first level children of the root. A new show_cfile function pointer is added to the cftype structure. If it is defined, it will be called to return a boolean value to determine if the corresponding control file should show up in the cgroup. It provides a more flexible mechanism to determine the visibility of the control file than a simple CFTYPE_* flag can do.

---
 Documentation/admin-guide/cgroup-v2.rst | 10 +++++-----
 include/linux/cgroup-defs.h             |  9 +++++++++
 kernel/cgroup/cgroup.c                  |  4 ++++
 kernel/cgroup/cpuset.c                  | 10 ++++++++++
 4 files changed, 28 insertions(+), 5 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +5 -5
index f7cde15..cf7cd88 100644
@@ -1585,10 +1585,10 @@ Cpuset Interface Files
     Its value will be affected by memory nodes hotplug events.
 
   cpuset.sched.partition
-    A read-write single value file which exists on non-root
-    cpuset-enabled cgroups.  It is a binary value flag that accepts
-    either "0" (off) or "1" (on).  This flag is set and owned by the
-        parent cgroup.
+    A read-write single value file which exists on the first level
+    children of the root cgroup.  It is a binary value flag that
+    accepts either "0" (off) or "1" (on).  This flag is set and
+    owned by the parent cgroup.
 
     If set, it indicates that the current cgroup is the root of a
     new partition or scheduling domain that comprises itself and
@@ -1603,7 +1603,7 @@ Cpuset Interface Files
        exclusive, i.e. they are not shared by any of its siblings.
     2) The "cpuset.cpus" is also a proper subset of the parent's
        "cpuset.cpus.effective".
-    3) The parent cgroup is a partition root.
+    3) The parent cgroup is the root cgroup.
     4) There is no child cgroups with cpuset enabled.  This is for
        eliminating corner cases that have to be handled if such a
        condition is allowed.
include/linux/cgroup-defs.h +9 -0
index c0e68f9..be79487 100644
@@ -565,6 +565,15 @@ struct cftype {
     ssize_t (*write)(struct kernfs_open_file *of,
              char *buf, size_t nbytes, loff_t off);
 
+    /*
+     * show_cfile(), if defined, will return a boolean value to
+     * determine if the control file should show up in the cgroup.
+     * It provides more flexibility in deciding where the control
+     * file should appear than simple criteria like on-root or
+     * not-on-root.
+     */
+    bool (*show_cfile)(struct cgroup_subsys_state *css);
+
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
     struct lock_class_key    lockdep_key;
 #endif
kernel/cgroup/cgroup.c +4 -0
index 077370b..0afdab8 100644
@@ -3612,6 +3612,10 @@ static int cgroup_addrm_files(struct
 cgroup_subsys_state *css,
         if ((cft->flags & CFTYPE_ONLY_ON_ROOT) && cgroup_parent(cgrp))
             continue;
 
+        /* Should the control file show up in the cgroup */
+        if (cft->show_cfile && !cft->show_cfile(css))
+            continue;
+
         if (is_add) {
             ret = cgroup_add_file(css, cgrp, cft);
             if (ret) {
kernel/cgroup/cpuset.c +10 -0
index 62b7e61..2f85c1e 100644
@@ -2106,6 +2106,15 @@ static s64 cpuset_read_s64(struct
 cgroup_subsys_state *css, struct cftype *cft)
 }
 
 /*
+ * The sched.partition control file should only show up in the first
+ * level children of the root cgroup.
+ */
+static bool cpuset_show_partition(struct cgroup_subsys_state *css)
+{
+    return parent_cs(css_cs(css)) == &top_cpuset;
+}
+
+/*
  * for the common functions, 'private' gives the type of file
  */
@@ -2250,6 +2259,7 @@ static s64 cpuset_read_s64(struct
 cgroup_subsys_state *css, struct cftype *cft)
         .name = "sched.partition",
         .read_u64 = cpuset_read_u64,
         .write_u64 = cpuset_write_u64,
+        .show_cfile = cpuset_show_partition,
         .private = FILE_PARTITION_ROOT,
         .flags = CFTYPE_NOT_ON_ROOT,
Quoted 1 line
     },

Tejun,

What do you think about this patch?

Are there any other issues you have with this patchset?

Thanks,
Longman

maintainer
#14 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 3 lines · Waiman Long

What do you think about this patch?

Are there any other issues you have with this patchset?

Looks good to me. If others are okay with it, I think we're all good.

Thanks.

Signature · 1 line
tejun
author maintainer
#15 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 8 lines · Tejun Heo
Quoted 3 lines · Waiman Long

What do you think about this patch?

Are there any other issues you have with this patchset?

Looks good to me. If others are okay with it, I think we're all good.

Thanks.

Peter,

Do you have any major issues with this cpuset patchset as it stands today?

Thanks,
Longman

#16 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 15 lines · Tejun Heo

Hello, Waiman.

Quoted 9 lines · Waiman Long
Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Yeah, that should work.

Quoted 8 lines
Quoted 4 lines

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

As currently implemented, partioning locks away the cpus which should be a system level decision, not container level, so it makes sense to me that it is only available to system root.

I'm terribly confused, what?!

Why would a container not be allowed to create partitions for its various RT workloads?

#43 lore raw

Re: [PATCH v11 9/9] cpuset: Allow reporting of sched domain generation info

In reply to Waiman Long
Quoted 28 lines · Waiman Long

This patch enables us to report sched domain generation information.

If DYNAMIC_DEBUG is enabled, issuing the following command

echo "file cpuset.c +p" > /sys/kernel/debug/dynamic_debug/control

and setting loglevel to 8 will allow the kernel to show what scheduling domain changes are being made.

---
 kernel/cgroup/cpuset.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
kernel/cgroup/cpuset.c +6 -0
index 07a5575..62b7e61 100644
@@ -836,6 +836,23 @@ static int generate_sched_domains(cpumask_var_t **domains,
 	return ndoms;
 }
 
+#ifdef CONFIG_DEBUG_KERNEL
+static inline void debug_print_domains(cpumask_var_t *doms, int ndoms)
+{
+	int i;
+	char buf[200];
+	char *ptr, *end = buf + sizeof(buf) - 1;

kernel/cgroup/cpuset.c static int generate_sched_domains(cpumask_var_t **domains, · line 854

Quoted 10 lines
kernel/cgroup/cpuset.c +10 -0
+
+	for (i = 0, ptr = buf, *end = '\0'; i < ndoms; i++)
+		ptr += snprintf(ptr, end - ptr, "dom%d=%*pbl ", i,
+				cpumask_pr_args(doms[i]));
+
+	pr_debug("Generated %d domains: %s\n", ndoms, buf);
+}
+#else
+static inline void debug_print_domains(cpumask_var_t *doms, int ndoms) { }
+#endif

I still hate this patch.. it prints information already available in sched_debug and has that rediculous on-stack buffer.

author maintainer
#44 lore raw

Re: [PATCH v11 9/9] cpuset: Allow reporting of sched domain generation info

Quoted 33 lines · Peter Zijlstra
Quoted 32 lines · Waiman Long

This patch enables us to report sched domain generation information.

If DYNAMIC_DEBUG is enabled, issuing the following command

echo "file cpuset.c +p" > /sys/kernel/debug/dynamic_debug/control

and setting loglevel to 8 will allow the kernel to show what scheduling domain changes are being made.

---
 kernel/cgroup/cpuset.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
kernel/cgroup/cpuset.c +10 -0
index 07a5575..62b7e61 100644
@@ -836,6 +836,23 @@ static int generate_sched_domains(cpumask_var_t **domains,
 	return ndoms;
 }
 
+#ifdef CONFIG_DEBUG_KERNEL
+static inline void debug_print_domains(cpumask_var_t *doms, int ndoms)
+{
+	int i;
+	char buf[200];
+	char *ptr, *end = buf + sizeof(buf) - 1;
+
+	for (i = 0, ptr = buf, *end = '\0'; i < ndoms; i++)
+		ptr += snprintf(ptr, end - ptr, "dom%d=%*pbl ", i,
+				cpumask_pr_args(doms[i]));
Quoted 8 lines

kernel/cgroup/cpuset.c static int generate_sched_domains(cpumask_var_t **domains, · line 854

Quoted 6 lines
kernel/cgroup/cpuset.c +6 -0
+
+	pr_debug("Generated %d domains: %s\n", ndoms, buf);
+}
+#else
+static inline void debug_print_domains(cpumask_var_t *doms, int ndoms) { }
+#endif

I still hate this patch.. it prints information already available in sched_debug and has that rediculous on-stack buffer.

This patch is just for my own testing purpose. We can certainly drop that.

Tejun, please drop this one.

Thanks,
Longman

author maintainer
#17 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 17 lines · Tejun Heo

Hello, Waiman.

Quoted 8 lines · Waiman Long
Quoted 4 lines

So, effective changing when enabling partition on a child feels wrong to me. It's supposed to contain what's actually allowed to the cgroup from its parent and that shouldn't change regardless of how those resources are used. It's still given to the cgroup from its parent.

Another way to work around this issue is to expose the reserved_cpus in the parent for holding CPUs that can taken by a chid partition. That will require adding one more cpuset file for those cgroups that are partition roots.

Yeah, that should work.

Quoted 4 lines

I don't mind restricting that to the first level children for now. That does restrict where we can put the container root if we want a separate partition for a container. Let's hear if others have any objection about that.

Quoted 7 lines
Quoted 3 lines

As currently implemented, partioning locks away the cpus which should be a system level decision, not container level, so it makes sense to me that it is only available to system root.

I'm terribly confused, what?!

Why would a container not be allowed to create partitions for its various RT workloads?

As far as I understand, Tejun has some concern about the way that partitioning works is inconsistent with how other resources are being managed by cgroup v2 controllers. I adds an incremental patch to temporarily disable the creation of partition below the first level children to buy us time so that we can reach a compromise later on what to do. We can always add features, but taking away features after they are made available will be hard.

I am fine either way. It is up to you and Tejun to figure out what should be made available to the users.

Cheers,
Longman

maintainer
#18 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello,

Quoted 11 lines · Waiman Long
Quoted 2 lines

Why would a container not be allowed to create partitions for its various RT workloads?

As far as I understand, Tejun has some concern about the way that partitioning works is inconsistent with how other resources are being managed by cgroup v2 controllers. I adds an incremental patch to temporarily disable the creation of partition below the first level children to buy us time so that we can reach a compromise later on what to do. We can always add features, but taking away features after they are made available will be hard.

Quoted 2 lines

I am fine either way. It is up to you and Tejun to figure out what should be made available to the users.

So, the main thing is that putting a cpu into a partition locks away the cpu from its ancestors. That's a system level operation which isn't delegatable. If we want to allow partitioning in subtrees, the parent still be able to take away partitioned cpus too even if that means ignoring descendants' configurations, which btw is exactly what cpuset does for non-partition configs.

I don't think this would be technically too challenging to implement, but unless there are immediate use cases for it, we can start simpler & restricted.

Thanks.

Signature · 1 line
tejun
author maintainer
#19 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 22 lines · Tejun Heo

Hello,

Quoted 10 lines · Waiman Long
Quoted 2 lines

Why would a container not be allowed to create partitions for its various RT workloads?

As far as I understand, Tejun has some concern about the way that partitioning works is inconsistent with how other resources are being managed by cgroup v2 controllers. I adds an incremental patch to temporarily disable the creation of partition below the first level children to buy us time so that we can reach a compromise later on what to do. We can always add features, but taking away features after they are made available will be hard.

Quoted 2 lines

I am fine either way. It is up to you and Tejun to figure out what should be made available to the users.

So, the main thing is that putting a cpu into a partition locks away the cpu from its ancestors. That's a system level operation which isn't delegatable. If we want to allow partitioning in subtrees, the parent still be able to take away partitioned cpus too even if that means ignoring descendants' configurations, which btw is exactly what cpuset does for non-partition configs.

Quoted 6 lines

I don't think this would be technically too challenging to implement, but unless there are immediate use cases for it, we can start simpler & restricted.

Thanks.

BTW, the way the partition is currently implemented right now is that a child cannot be a partition root unless its parent is a partition root itself. That is to avoid turning on partition to affect ancestors further up the hierarchy than just the parent. So in the case of a container, it cannot allocate sub-partitions underneath it unless it is a partition itself. Will that solve your concern?

Thanks,
Longman

maintainer
#20 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello,

Quoted 6 lines · Waiman Long

BTW, the way the partition is currently implemented right now is that a child cannot be a partition root unless its parent is a partition root itself. That is to avoid turning on partition to affect ancestors further up the hierarchy than just the parent. So in the case of a container, it cannot allocate sub-partitions underneath it unless it is a partition itself. Will that solve your concern?

Hmm... so a given ancestor must be able to both

1. control which cpus are moved into a partition in all of its subtree.

2. take away any given cpu from ist subtree.

Right now, I don't think it's achieving either, right?

Thanks.

Signature · 1 line
tejun
author maintainer
#21 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 9 lines · Tejun Heo

Hello,

Quoted 6 lines · Waiman Long

BTW, the way the partition is currently implemented right now is that a child cannot be a partition root unless its parent is a partition root itself. That is to avoid turning on partition to affect ancestors further up the hierarchy than just the parent. So in the case of a container, it cannot allocate sub-partitions underneath it unless it is a partition itself. Will that solve your concern?

Quoted 4 lines

Hmm... so a given ancestor must be able to both

1. control which cpus are moved into a partition in all of its subtree.

Not at the moment. I do have another idea of adding a "cpus.subpart" file, for example, to indicate what CPUs a child sub-partition can use in its partition. This control file only serves as an intention to grant, it won't affect anything else. Before the partition flag can be turned on, the kernel will have to check if the cpu list of the child is also a subset of its parent's cpus.subpart as a precondition. Does that serve the purpose of letting a parent has a say of what CPUs can be included in a child partition?

This change will require adding a new cpumask into the cpuset structure, the code to handle the mask as well as an additional check in the partition enable code. That will have minimal impact to the current code.

Quoted 3 lines

2. take away any given cpu from ist subtree.

Right now, I don't think it's achieving either, right?

The only way to take away the CPUs from a sub-partition is to turn off the partition flag in the child provided that it has no sub-partitions underneath it.

Do you want a way at the parent level to take CPUs away from child partitions? The "cpus.subpart" file can probably be used also for this purpose, but we have to decide what taking CPUs away from child partition means. Does that mean automatically turn off the partition flag in the children if there is no CPU left in the partition? There are some implementation details that need to be fleshed out. I would prefer not doing this as this will complicate the code without too much benefit that I can see.

Cheers,
Longman

maintainer
#22 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello, Waiman.

On Thu, Jul 19, 2018 at 01:22:36PM -0400, Waiman Long wrote:
...

Quoted 5 lines

Do you want a way at the parent level to take CPUs away from child partitions? The "cpus.subpart" file can probably be used also for this purpose, but we have to decide what taking CPUs away from child partition means. Does that mean automatically turn off the partition flag in the children if there is no CPU left in the partition? There are

Yeah, I think so. That's what we do when cpuset.cpus or mems go empty
- ignoring the config.

Quoted 3 lines

some implementation details that need to be fleshed out. I would prefer not doing this as this will complicate the code without too much benefit that I can see.

So, given how long this has been dragging along and it isn't yet super clear to me why this needs to be fully hierarchical, I'd actually prefer just restricting it to the first level children.

Thanks.

Signature · 1 line
tejun
author maintainer
#23 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 12 lines · Tejun Heo

Hello, Waiman.

On Thu, Jul 19, 2018 at 01:22:36PM -0400, Waiman Long wrote:
...

Quoted 5 lines

Do you want a way at the parent level to take CPUs away from child partitions? The "cpus.subpart" file can probably be used also for this purpose, but we have to decide what taking CPUs away from child partition means. Does that mean automatically turn off the partition flag in the children if there is no CPU left in the partition? There are

Yeah, I think so. That's what we do when cpuset.cpus or mems go empty
- ignoring the config.

Quoted 9 lines
Quoted 3 lines

some implementation details that need to be fleshed out. I would prefer not doing this as this will complicate the code without too much benefit that I can see.

So, given how long this has been dragging along and it isn't yet super clear to me why this needs to be fully hierarchical, I'd actually prefer just restricting it to the first level children.

Thanks.

Yes, I would prefer to check in the v11 cpuset patch as it is today, including the incremental patch to limit partition to first level child minus the debug patch. I do need to make cpuset v2 enabled ASAP.

This will give me more times to work on extending partition to be hierarchical if the need arises as well as other cpuset v2 features. We usually can't get all the things right in one single step.

Peter, are you OK with that? I can promise you that I will work to make this happen at a later date if you really want it.

Cheers,
Longman

#40 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 12 lines · Tejun Heo
Quoted 11 lines · Waiman Long
Quoted 2 lines

Why would a container not be allowed to create partitions for its various RT workloads?

As far as I understand, Tejun has some concern about the way that partitioning works is inconsistent with how other resources are being managed by cgroup v2 controllers. I adds an incremental patch to temporarily disable the creation of partition below the first level children to buy us time so that we can reach a compromise later on what to do. We can always add features, but taking away features after they are made available will be hard.

Quoted 6 lines
Quoted 2 lines

I am fine either way. It is up to you and Tejun to figure out what should be made available to the users.

So, the main thing is that putting a cpu into a partition locks away the cpu from its ancestors. That's a system level operation which isn't delegatable.

If I understood things right, the partition file is actually owned by the parent. So only the parent can flip that flag. In case of a container, the filesystem namespace capturing the cgroup would cause that file to be effectively r/o.

So effectively the partition flag if part of the parent control. The parent takes the CPUs away to give them to the child cgroup. The child itself cannot take or give here.

This is perhaps a little unorthodox, but it delegates just fine. Because if a container finds .partition == 1, it knows it too can create (sub) partitions.

Quoted 4 lines

If we want to allow partitioning in subtrees, the
parent still be able to take away partitioned cpus too even if that means ignoring descendants' configurations, which btw is exactly what cpuset does for non-partition configs.

I don't see why it would not be able to take away CPUs. But in case of partitions this really is henous behaviour of the parent.

#25 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 10 lines · Tejun Heo

Hello,

Quoted 6 lines · Waiman Long

BTW, the way the partition is currently implemented right now is that a child cannot be a partition root unless its parent is a partition root itself. That is to avoid turning on partition to affect ancestors further up the hierarchy than just the parent. So in the case of a container, it cannot allocate sub-partitions underneath it unless it is a partition itself. Will that solve your concern?

Quoted 4 lines

Hmm... so a given ancestor must be able to both

1. control which cpus are moved into a partition in all of its subtree.

By virtue of the partition file being owned by the parent, this is already achived, no?

Quoted 1 line

2. take away any given cpu from ist subtree.

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

#24 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Waiman Long
Quoted 6 lines · Waiman Long
Quoted 2 lines

1. control which cpus are moved into a partition in all of its subtree.

Not at the moment. I do have another idea of adding a "cpus.subpart" file, for example, to indicate what CPUs a child sub-partition can use in its partition.

ARGH, why more files; this is turning into a right mess to use.

maintainer
#26 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Peter Zijlstra

Hello,

Quoted 9 lines · Peter Zijlstra
Quoted 8 lines · Tejun Heo
Quoted 6 lines · Waiman Long

BTW, the way the partition is currently implemented right now is that a child cannot be a partition root unless its parent is a partition root itself. That is to avoid turning on partition to affect ancestors further up the hierarchy than just the parent. So in the case of a container, it cannot allocate sub-partitions underneath it unless it is a partition itself. Will that solve your concern?

Quoted 7 lines
Quoted 4 lines

Hmm... so a given ancestor must be able to both

1. control which cpus are moved into a partition in all of its subtree.

By virtue of the partition file being owned by the parent, this is already achived, no?

The currently proposed implementation is somewhere in the middle. It kinda gets there by restricting a partition to be a child of another partition, which may be okay but it does make the whole delegation mechanism less useful.

Quoted 4 lines
Quoted 1 line

2. take away any given cpu from ist subtree.

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

Well, sorry that you hate it. It's a fundamental architectural constraint. If it can't satisfy that, it should't be in cgroup.

Thanks.

Signature · 1 line
tejun
maintainer
#27 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello,

Quoted 7 lines · Tejun Heo
Quoted 4 lines
Quoted 1 line

2. take away any given cpu from ist subtree.

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

Well, sorry that you hate it. It's a fundamental architectural constraint. If it can't satisfy that, it should't be in cgroup.

Just in case it wasn't clear from previous the exchanges, basic architecture designs like this are what makes things like delegation actually useful across all controllers. If we allow a descendant in the hierarchy to restrict waht its ancestors can do, it becomes really painful operationally.

For now, I'd suggest just doing it at the first child level and move on unless there are clear use cases where nested partitions are useful, which I find unlikely given the nature of the operation - partitions don't really have anything to do with one another.

Thanks.

Signature · 1 line
tejun
#28 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 5 lines · Tejun Heo
Quoted 5 lines
Quoted 4 lines

Hmm... so a given ancestor must be able to both

1. control which cpus are moved into a partition in all of its subtree.

Quoted 7 lines
Quoted 2 lines

By virtue of the partition file being owned by the parent, this is already achived, no?

The currently proposed implementation is somewhere in the middle. It kinda gets there by restricting a partition to be a child of another partition, which may be okay but it does make the whole delegation mechanism less useful.

So the implementation does not set ownership of the 'partition' file to that of the parent directory? Because _that_ is what I understood from Waiman (many versions ago). And that _does_ allow delegation to work nicely.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

2. take away any given cpu from ist subtree.

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

Well, sorry that you hate it. It's a fundamental architectural constraint. If it can't satisfy that, it should't be in cgroup.

So is hierarchical behaviour; but you seem willing to forgo that.

Still, the question was, how is this (dispicable or not) behaviour not allowed by the current implementation?

maintainer
#29 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello, Peter.

Quoted 9 lines · Peter Zijlstra
Quoted 4 lines

The currently proposed implementation is somewhere in the middle. It kinda gets there by restricting a partition to be a child of another partition, which may be okay but it does make the whole delegation mechanism less useful.

So the implementation does not set ownership of the 'partition' file to that of the parent directory? Because _that_ is what I understood from Waiman (many versions ago). And that _does_ allow delegation to work nicely.

So, that part isn't the problem. The problem is that if we allow partitioning nested further away from ancestor, the descendant would be able to take away reources from the removed ancestor. Waiman avoids this problem by only allowing partitions to nest but then it's kinda weird cuz it's just a separate tree.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

2. take away any given cpu from ist subtree.

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

Well, sorry that you hate it. It's a fundamental architectural constraint. If it can't satisfy that, it should't be in cgroup.

So is hierarchical behaviour; but you seem willing to forgo that.

Well, we do have root or first-level only things. Things just need to be properly delegatable when they're hierarchical (and things should be hierarchical only when that actually means something). While not desirable, considering the history, accomodating this specific usage that way seems acceptable to me.

Quoted 2 lines

Still, the question was, how is this (dispicable or not) behaviour not allowed by the current implementation?

I'm not quite sure what you're trying to ask. Can you elaborate?

Thanks.

Signature · 1 line
tejun
author maintainer
#39 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 10 lines · Tejun Heo
Quoted 6 lines
Quoted 4 lines

Hmm... so a given ancestor must be able to both

1. control which cpus are moved into a partition in all of its subtree.

By virtue of the partition file being owned by the parent, this is already achived, no?

The currently proposed implementation is somewhere in the middle. It kinda gets there by restricting a partition to be a child of another partition, which may be okay but it does make the whole delegation mechanism less useful.

So the implementation does not set ownership of the 'partition' file to that of the parent directory? Because _that_ is what I understood from Waiman (many versions ago). And that _does_ allow delegation to work nicely.

Quoted 1 line
Quoted 1 line
Quoted 1 line

2. take away any given cpu from ist subtree.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

Well, sorry that you hate it. It's a fundamental architectural constraint. If it can't satisfy that, it should't be in cgroup.

So is hierarchical behaviour; but you seem willing to forgo that.

Still, the question was, how is this (dispicable or not) behaviour not allowed by the current implementation?

The taking CPUs away part is not functioning yet in the current patchset. It is certainly doable. I just need more time to work on that.

The current patchset is fine if partition is restricted to the first level children as CPU online/offline is properly handled by the patchset. It is in the non-root level that taking CPUs away from a partition can be problematic.

Cheers,
Longman

author maintainer
#30 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 11 lines · Tejun Heo

Hello, Peter.

Quoted 8 lines · Peter Zijlstra
Quoted 4 lines

The currently proposed implementation is somewhere in the middle. It kinda gets there by restricting a partition to be a child of another partition, which may be okay but it does make the whole delegation mechanism less useful.

So the implementation does not set ownership of the 'partition' file to that of the parent directory? Because _that_ is what I understood from Waiman (many versions ago). And that _does_ allow delegation to work nicely.

Quoted 5 lines

So, that part isn't the problem. The problem is that if we allow partitioning nested further away from ancestor, the descendant would be able to take away reources from the removed ancestor. Waiman avoids this problem by only allowing partitions to nest but then it's kinda weird cuz it's just a separate tree.

The rationale behind the current design is that a parent is allowed to create a child partition if it fully owns all the cpus it has. That is true only if it is a partition itself. IOW, making a cpuset a partition won't affect any ancestors other than the parent.

Quoted 11 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

2. take away any given cpu from ist subtree.

I really hate this obsession of yours and doubly so for partitions. But why would this currently not be allowed?

Well, sorry that you hate it. It's a fundamental architectural constraint. If it can't satisfy that, it should't be in cgroup.

So is hierarchical behaviour; but you seem willing to forgo that.

Well, we do have root or first-level only things. Things just need to be properly delegatable when they're hierarchical (and things should be hierarchical only when that actually means something). While not desirable, considering the history, accomodating this specific usage that way seems acceptable to me.

I am not against the idea of making it hierarchical eventually. I am just hoping to get thing going by merging the patchset in its current form and then we can make it hierarchical in a followup patch.

Cheers,
Longman

#38 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 8 lines · Tejun Heo

Hello, Peter.

Quoted 5 lines · Peter Zijlstra
Quoted 4 lines

The currently proposed implementation is somewhere in the middle. It kinda gets there by restricting a partition to be a child of another partition, which may be okay but it does make the whole delegation mechanism less useful.

Quoted 8 lines
Quoted 4 lines

So the implementation does not set ownership of the 'partition' file to that of the parent directory? Because _that_ is what I understood from Waiman (many versions ago). And that _does_ allow delegation to work nicely.

So, that part isn't the problem. The problem is that if we allow partitioning nested further away from ancestor, the descendant would be able to take away reources from the removed ancestor.

If the partition file is owned by the parent, the descendant cannot take away anything. It can only read the file, not actually write to it.

To be explicit, if we have:

	/.			(uid = root)
	/A/.			(uid = user1)
	/A/cpuset.partition	(uid = root)

so ./*/cpuset.partition is always owned by .

Quoted 2 lines

Waiman avoids this problem by only allowing partitions to nest but then it's kinda weird cuz it's just a separate tree.

The only real constraint is that the parent must have exclusive 'ownership' of the CPUs. Being a partition mandates that to be so. There is no other way to distinguish exclusive / shared CPUs.

But I don't see how any of this is related to delegation per se. It is a prerequisite for creating nested partitions, which in turn is a prerequisite for delegation of partitions.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

2. take away any given cpu from ist subtree.

Still, the question was, how is this (dispicable or not) behaviour not allowed by the current implementation?

I'm not quite sure what you're trying to ask. Can you elaborate?

We can always offline the CPU, so how exactly can the ancestor not take back it's CPU?

The parent can simply shrink it's cpuset.cpus, no? Then the child gets to recompute its setup and it might find its sub-partition just became smaller or empty -- just like hotplug.

#31 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Waiman Long
Quoted 3 lines · Waiman Long

I am not against the idea of making it hierarchical eventually. I am just hoping to get thing going by merging the patchset in its current form and then we can make it hierarchical in a followup patch.

Where's the rush? Why can't we do this right in one go?

author maintainer
#32 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long

I am not against the idea of making it hierarchical eventually. I am just hoping to get thing going by merging the patchset in its current form and then we can make it hierarchical in a followup patch.

Where's the rush? Why can't we do this right in one go?

For me, the rush comes from RHEL8 as it is a goal to have a fully functioning cgroup v2 in that release.

I also believe that most of the use cases of partition can be satisfied with partitions at the first level children. Getting hierarchical partition right may drag on for half a year, maybe, giving our history with cpu v2 controller. No matter what we do to enable hierarchical partition in the future, the current model of using a partition flag is intuitive enough that it won't be changed at least for the first level children.

Cheers,
Longman

maintainer
#33 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello,

Quoted 10 lines · Waiman Long
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long

I am not against the idea of making it hierarchical eventually. I am just hoping to get thing going by merging the patchset in its current form and then we can make it hierarchical in a followup patch.

Where's the rush? Why can't we do this right in one go?

For me, the rush comes from RHEL8 as it is a goal to have a fully functioning cgroup v2 in that release.

Quoted 7 lines

I also believe that most of the use cases of partition can be satisfied with partitions at the first level children. Getting hierarchical partition right may drag on for half a year, maybe, giving our history with cpu v2 controller. No matter what we do to enable hierarchical partition in the future, the current model of using a partition flag is intuitive enough that it won't be changed at least for the first level children.

I'm fully with Waiman here. There are people wanting to use it and the part most people isn't controversial at all. I don't see what'd be gained by further delaying the whole thing. If the first level partition thing isn't acceptable to everyone, we can even strip down further. We can get .cpus and .mems merged first, which is what most people want anyway.

Thanks.

Signature · 1 line
tejun
author maintainer
#37 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Waiman Long
Quoted 9 lines · Waiman Long
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long

I am not against the idea of making it hierarchical eventually. I am just hoping to get thing going by merging the patchset in its current form and then we can make it hierarchical in a followup patch.

Where's the rush? Why can't we do this right in one go?

For me, the rush comes from RHEL8 as it is a goal to have a fully functioning cgroup v2 in that release.

Quoted 7 lines

I also believe that most of the use cases of partition can be satisfied with partitions at the first level children. Getting hierarchical partition right may drag on for half a year, maybe, giving our history with cpu v2 controller. No matter what we do to enable hierarchical partition in the future, the current model of using a partition flag is intuitive enough that it won't be changed at least for the first level children.

Peter, are you OK that or do you still want to have hierarchical partition done before submission?

Thanks,
Longman

author maintainer
#34 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

In reply to Tejun Heo
Quoted 19 lines · Tejun Heo

Hello,

Quoted 9 lines · Waiman Long
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long

I am not against the idea of making it hierarchical eventually. I am just hoping to get thing going by merging the patchset in its current form and then we can make it hierarchical in a followup patch.

Where's the rush? Why can't we do this right in one go?

For me, the rush comes from RHEL8 as it is a goal to have a fully functioning cgroup v2 in that release.

Quoted 7 lines

I also believe that most of the use cases of partition can be satisfied with partitions at the first level children. Getting hierarchical partition right may drag on for half a year, maybe, giving our history with cpu v2 controller. No matter what we do to enable hierarchical partition in the future, the current model of using a partition flag is intuitive enough that it won't be changed at least for the first level children.

Quoted 6 lines

I'm fully with Waiman here. There are people wanting to use it and the part most people isn't controversial at all. I don't see what'd be gained by further delaying the whole thing. If the first level partition thing isn't acceptable to everyone, we can even strip down further. We can get .cpus and .mems merged first, which is what most people want anyway.

BTW, I am trying to support hierarchical partition. The first thing that I want to support is to allow removing CPUs from partition root freely. It turns out that the following existing code in validate_change() will prevent the removal from happening when it touches any CPUs that are used in child cpusets:

        /* Each of our child cpusets must be a subset of us */
        ret = -EBUSY;
        cpuset_for_each_child(c, css, cur)
                if (!is_cpuset_subset(c, trial))
                        goto out;

So this is not a new restriction after all.

The following restrictions are still imposed on a partition root wrt allowable changes in cpuset.cpus:
1) cpuset.cpus cannot be set to "". There must be at least 1 cpu there.
2) Adding cpus that are not in parent's cpuset.cpus (as well as cpuset.cpus.effective) or that will take all the parent's effective cpus away is not allowed.

So are these limitations acceptable?

The easiest way to remove those restrictions is to forcefully turn off the cpuset.sched.partition flag in the cpuset as well as any sub-partitions when the user try to do that. With that change, there will be no more new restriction on what you can do on cpuset.cpus.

What is your opinion on the best way forward wrt supporting hierarchical partitioning?

Thanks,
Longman

maintainer
#35 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Hello, Waiman.

Quoted 7 lines · Waiman Long

The following restrictions are still imposed on a partition root wrt allowable changes in cpuset.cpus:
1) cpuset.cpus cannot be set to "". There must be at least 1 cpu there.
2) Adding cpus that are not in parent's cpuset.cpus (as well as cpuset.cpus.effective) or that will take all the parent's effective cpus away is not allowed.

Quoted 6 lines

So are these limitations acceptable?

The easiest way to remove those restrictions is to forcefully turn off the cpuset.sched.partition flag in the cpuset as well as any sub-partitions when the user try to do that. With that change, there will be no more new restriction on what you can do on cpuset.cpus.

I think that'd be the right thing to do. That's what we do with cpuset.cpus and cpuset.mems too. If there's nothing available, we ignore the config and show the settings which are currently in effect.

Thanks.

Signature · 1 line
tejun
author maintainer
#36 lore raw

Re: [PATCH v11 7/9] cpuset: Expose cpus.effective and mems.effective on cgroup v2 root

Quoted 16 lines · Tejun Heo

Hello, Waiman.

Quoted 7 lines · Waiman Long

The following restrictions are still imposed on a partition root wrt allowable changes in cpuset.cpus:
1) cpuset.cpus cannot be set to "". There must be at least 1 cpu there.
2) Adding cpus that are not in parent's cpuset.cpus (as well as cpuset.cpus.effective) or that will take all the parent's effective cpus away is not allowed.

Quoted 6 lines

So are these limitations acceptable?

The easiest way to remove those restrictions is to forcefully turn off the cpuset.sched.partition flag in the cpuset as well as any sub-partitions when the user try to do that. With that change, there will be no more new restriction on what you can do on cpuset.cpus.

Quoted 6 lines

I think that'd be the right thing to do. That's what we do with cpuset.cpus and cpuset.mems too. If there's nothing available, we ignore the config and show the settings which are currently in effect.

Thanks.

Thanks! I will send out an updated patch after the 4.19 merge window closes.

-Longman