cgroup/cpuset: Add new cpuset partition type & empty effecitve cpus
Subsystems (4)
Waiman Long
maintainerv4 cover cgroup/cpuset: Add new cpuset partition type & empty effecitve cpus
v4:
- Rebased to the for-5.15 branch of cgroup git tree and dropped the first 3 patches of v3 series which have been merged.
- Beside prohibiting violation of cpu exclusivity rule, allow arbitrary changes to cpuset.cpus of a partition root and force the partition root to become invalid in case any of the partition root constraints are violated. The documentation file and self test are modified accordingly.
v3:
- Add two new patches (patches 2 & 3) to fix bugs found during the testing process.
- Add a new patch to enable inotify event notification when partition become invalid.
- Add a test to test event notification when partition become invalid.
v2:
- Drop v1 patch 1.
- Break out some cosmetic changes into a separate patch (patch #1).
- Add a new patch to clarify the transition to invalid partition root is mainly caused by hotplug events.
- Enhance the partition root state test including CPU online/offline behavior and fix issues found by the test.
This patchset makes four enhancements to the cpuset v2 code.
Patch 1: Enable event notification on "cpuset.cpus.partition" whenever the state of a partition changes.
Patch 2: Properly handle partition root tree and make partition invalid in case changes to cpuset.cpus violate any of the partition root constraints.
Patch 3: Add a new partition state "isolated" to create a partition root without load balancing. This is for handling intermitten workloads that have a strict low latency requirement.
Patch 4: Allow partition roots that are not the top cpuset to distribute all its cpus to child partitions as long as there is no task associated with that partition root. This allows more flexibility for middleware to manage multiple partitions.
Patch 5 updates the cgroup-v2.rst file accordingly. Patch 6 adds a new cpuset test to test the new cpuset partition code.
Waiman Long (6):
cgroup/cpuset: Enable event notification when partition state changes cgroup/cpuset: Properly handle partition root tree cgroup/cpuset: Add a new isolated cpus.partition type cgroup/cpuset: Allow non-top parent partition root to distribute out
all CPUs
cgroup/cpuset: Update description of cpuset.cpus.partition in
cgroup-v2.rst
kselftest/cgroup: Add cpuset v2 partition root state test
Documentation/admin-guide/cgroup-v2.rst | 104 +-- kernel/cgroup/cpuset.c | 282 +++++--- tools/testing/selftests/cgroup/Makefile | 5 +- .../selftests/cgroup/test_cpuset_prs.sh | 632 ++++++++++++++++++ tools/testing/selftests/cgroup/wait_inotify.c | 86 +++ 5 files changed, 980 insertions(+), 129 deletions(-) create mode 100755 tools/testing/selftests/cgroup/test_cpuset_prs.sh create mode 100644 tools/testing/selftests/cgroup/wait_inotify.c
Signature · 1 line
2.18.1
Waiman Long
maintainerPATCH v4 1/6 cgroup/cpuset: Enable event notification when partition state changes
A valid cpuset partition can become invalid if all its CPUs are offlined or somehow removed. This can happen through external events without "cpuset.cpus.partition" being touched at all.
Users that rely on the property of a partition being present do not currently have a simple way to get such an event notified other than constant periodic polling which is both inefficient and cumbersome.
To make life easier for those users, event notification is now enabled for "cpuset.cpus.partition" whenever its state changes.
--- kernel/cgroup/cpuset.c | 46 ++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 11 deletions(-)
kernel/cgroup/cpuset.c +35 -11
@@ -160,6 +160,9 @@ struct cpuset {*/ int use_parent_ecpus;int child_ecpus_count; + +/* Handle for cpuset.cpus.partition */ +struct cgroup_file partition_file; };/*
@@ -263,6 +266,16 @@ static inline int is_partition_root(const struct cpuset *cs)return cs->partition_root_state >0 ; } +/* +* Send notification event of whenever partition_root_state changes. +*/ +static inline void notify_partition_change (struct cpuset *cs, +int old_prs,int new_prs) +{ +if (old_prs != new_prs) +cgroup_file_notify (&cs->partition_file); +} +static struct cpuset top_cpuset = { .flags = ((1 <<CS_ONLINE ) | (1 <<CS_CPU_EXCLUSIVE ) | (1 <<CS_MEM_EXCLUSIVE )),
@@ -1148,7 +1161,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,struct cpuset *parent =parent_cs (cpuset);int adding;/* Moving cpus from effective_cpus to subparts_cpus */ int deleting;/* Moving cpus from subparts_cpus to effective_cpus */ -int new_prs; +int old_prs, new_prs;bool part_error = false;/* Partition error? */ percpu_rwsem_assert_held (&cpuset_rwsem);
@@ -1184,7 +1197,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,* A cpumask update cannot make parent's effective_cpus become empty. */ adding = deleting = false; - new_prs = cpuset->partition_root_state; + old_prs = new_prs = cpuset->partition_root_state;if (cmd == partcmd_enable) {cpumask_copy (tmp->addmask, cpuset->cpus_allowed); adding = true;
@@ -1274,7 +1287,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, parent->subparts_cpus); } -if (!adding && !deleting && (new_prs == cpuset->partition_root_state)) +if (!adding && !deleting && (new_prs == old_prs))return 0 ;/*
@@ -1302,9 +1315,11 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, parent->nr_subparts_cpus =cpumask_weight (parent->subparts_cpus); -if (cpuset->partition_root_state != new_prs) +if (old_prs != new_prs) cpuset->partition_root_state = new_prs; +spin_unlock_irq (&callback_lock); +notify_partition_change (cpuset, old_prs, new_prs);return cmd == partcmd_update; }
@@ -1326,7 +1341,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)struct cpuset *cp;struct cgroup_subsys_state *pos_css;bool need_rebuild_sched_domains = false; -int new_prs; +int old_prs, new_prs;rcu_read_lock ();cpuset_for_each_descendant_pre (cp, pos_css, cs) {
@@ -1366,8 +1381,8 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)* update_tasks_cpumask() again for tasks in the parent * cpuset if the parent's subparts_cpus changes. */ - new_prs = cp->partition_root_state; -if ((cp != cs) && new_prs) { + old_prs = new_prs = cp->partition_root_state; +if ((cp != cs) && old_prs) {switch (parent->partition_root_state) {case PRS_DISABLED :/*
@@ -1438,10 +1453,11 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp) } } -if (new_prs != cp->partition_root_state) +if (new_prs != old_prs) cp->partition_root_state = new_prs;spin_unlock_irq (&callback_lock); +notify_partition_change (cp, old_prs, new_prs);WARN_ON (!is_in_v2_mode () && !cpumask_equal (cp->cpus_allowed, cp->effective_cpus));
@@ -2023,6 +2039,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)spin_lock_irq (&callback_lock); cs->partition_root_state = new_prs;spin_unlock_irq (&callback_lock); +notify_partition_change (cs, old_prs, new_prs); }free_cpumasks (NULL , &tmpmask);
@@ -2708,6 +2725,7 @@ static struct cftype dfl_files[] = { .write = sched_partition_write, .private = FILE_PARTITION_ROOT, .flags = CFTYPE_NOT_ON_ROOT, + .file_offset = offsetof(struct cpuset, partition_file), }, {
@@ -3103,11 +3121,17 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)*/ if ((parent->partition_root_state ==PRS_ERROR ) ||cpumask_empty (&new_cpus)) { +int old_prs; +update_parent_subparts_cpumask (cs, partcmd_disable,NULL , tmp); -spin_lock_irq (&callback_lock); - cs->partition_root_state =PRS_ERROR ; -spin_unlock_irq (&callback_lock); + old_prs = cs->partition_root_state; +if (old_prs !=PRS_ERROR ) { +spin_lock_irq (&callback_lock); + cs->partition_root_state =PRS_ERROR ; +spin_unlock_irq (&callback_lock); +notify_partition_change (cs, old_prs,PRS_ERROR ); + } }cpuset_force_rebuild (); }
Signature · 1 line
2.18.1
Re: [PATCH v4 1/6] cgroup/cpuset: Enable event notification when partition state changes
Quoted 8 lines · Waiman Long
A valid cpuset partition can become invalid if all its CPUs are offlined or somehow removed. This can happen through external events without "cpuset.cpus.partition" being touched at all.
Users that rely on the property of a partition being present do not currently have a simple way to get such an event notified other than constant periodic polling which is both inefficient and cumbersome.
Quoted 5 lines
To make life easier for those users, event notification is now enabled for "cpuset.cpus.partition" whenever its state changes.
Suggested-by Tejun Heo <[email protected]>Signed-off-by Waiman Long <[email protected]>
Applied to cgroup/for-5.15.
Thanks.
Signature · 1 line
tejun
Waiman Long
maintainerPATCH v4 2/6 cgroup/cpuset: Properly handle partition root tree
In reply to Waiman LongFor cpuset partition, the special state of PRS_ERROR (invalid partition root) was originally designed to handle hotplug events. In this state, CPUs allocated to the partition root is released back to the parent but the cpuset exclusive flags remain unchanged.
Since partition root sets the CPU_EXCLUSIVE flag, cpuset.cpus changes that break the cpu exclusivity rule will not be allowed. However, other changes to cpuset.cpus on a partition root may still cause it to become invalid. So users must always check the partition root state of "cpuset.cpus.partition" after making changes to cpuset.cpus to make sure that the partition root is still valid.
For a partition root tree with parent and child partition roots, this patch will now prohibit changing parent partition root back to member as changes to "cpuset.cpus.partition" should not cause those child partition roots to become invalid.
If some cpus are taken away from the parent partition root so that its cpuset.cpus.effective becomes empty, it will pull cpus away from the child partition roots and force them to become invalid which may allow the parent partition root to remain valid.
This patch also makes partition root invalid in case changes to "cpuset.cpus" violates any of the partition root constraints.
--- kernel/cgroup/cpuset.c | 141 +++++++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 63 deletions(-)
kernel/cgroup/cpuset.c +78 -63
@@ -1208,6 +1208,14 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,/* * partcmd_update with newmask: * +* Make partition invalid if newmask isn't a subset of +* (cpus_allowed | parent->effective_cpus). +*/ +cpumask_or (tmp->addmask, cpuset->cpus_allowed, + parent->effective_cpus); + part_error = !cpumask_subset (newmask, tmp->addmask); + +/* * delmask = cpus_allowed & ~newmask & parent->subparts_cpus * addmask = newmask & parent->effective_cpus * & ~parent->subparts_cpus
@@ -1220,7 +1228,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, adding =cpumask_andnot (tmp->addmask, tmp->addmask, parent->subparts_cpus);/* -* Return error if the new effective_cpus could become empty. +* Return error if parent's effective_cpus could become empty. */ if (adding &&cpumask_equal (parent->effective_cpus, tmp->addmask)) {
@@ -1242,19 +1250,23 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,* * addmask = cpus_allowed & parent->effective_cpus * +* This gets invoked either due to a hotplug event or +* from update_cpumasks_hier() where we can't return an +* error. This can cause a partition root to become invalid +* in the case of a hotplug. +* * Note that parent's subparts_cpus may have been * pre-shrunk in case there is a change in the cpu list. * So no deletion is needed. */ adding =cpumask_and (tmp->addmask, cpuset->cpus_allowed, parent->effective_cpus); - part_error =cpumask_equal (tmp->addmask, - parent->effective_cpus); + part_error = (is_partition_root (cpuset) && + !parent->nr_subparts_cpus) || +cpumask_equal (tmp->addmask, parent->effective_cpus); }if (cmd == partcmd_update) { -int prev_prs = cpuset->partition_root_state; -/* * Check for possible transition between PRS_ENABLED * and PRS_ERROR.
@@ -1269,13 +1281,9 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, new_prs =PRS_ENABLED ;break ; } -/* -* Set part_error if previously in invalid state. -*/ - part_error = (prev_prs ==PRS_ERROR ); } -if (!part_error && (new_prs ==PRS_ERROR )) +if ((old_prs ==PRS_ERROR ) && (new_prs ==PRS_ERROR ))return 0 ;/* Nothing need to be done */ if (new_prs ==PRS_ERROR ) {
@@ -1407,6 +1415,11 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)case PRS_ENABLED :if (update_parent_subparts_cpumask (cp, partcmd_update,NULL , tmp))update_tasks_cpumask (parent); +/* +* The cpuset partition_root_state may be +* changed to PRS_ERROR. Capture it. +*/ + new_prs = cp->partition_root_state;break ;case PRS_ERROR :
@@ -1424,33 +1437,27 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)spin_lock_irq (&callback_lock); -cpumask_copy (cp->effective_cpus, tmp->new_cpus);if (cp->nr_subparts_cpus && (new_prs !=PRS_ENABLED )) { +/* +* Put all active subparts_cpus back to effective_cpus. +*/ +cpumask_or (tmp->new_cpus, tmp->new_cpus, + cp->subparts_cpus); +cpumask_and (tmp->new_cpus, tmp->new_cpus, + cpu_active_mask); cp->nr_subparts_cpus =0 ;cpumask_clear (cp->subparts_cpus); - }else if (cp->nr_subparts_cpus) { + } + +cpumask_copy (cp->effective_cpus, tmp->new_cpus); +if (cp->nr_subparts_cpus) {/* * Make sure that effective_cpus & subparts_cpus -* are mutually exclusive. -* -* In the unlikely event that effective_cpus -* becomes empty. we clear cp->nr_subparts_cpus and -* let its child partition roots to compete for -* CPUs again. +* of a partition root are mutually exclusive. */ cpumask_andnot (cp->effective_cpus, cp->effective_cpus, cp->subparts_cpus); -if (cpumask_empty (cp->effective_cpus)) { -cpumask_copy (cp->effective_cpus, tmp->new_cpus); -cpumask_clear (cp->subparts_cpus); - cp->nr_subparts_cpus =0 ; - }else if (!cpumask_subset (cp->subparts_cpus, - tmp->new_cpus)) { -cpumask_andnot (cp->subparts_cpus, - cp->subparts_cpus, tmp->new_cpus); - cp->nr_subparts_cpus - =cpumask_weight (cp->subparts_cpus); - } +WARN_ON_ONCE (cpumask_empty (cp->effective_cpus)); }if (new_prs != old_prs)
@@ -1582,8 +1589,8 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,* Make sure that subparts_cpus is a subset of cpus_allowed. */ if (cs->nr_subparts_cpus) { -cpumask_andnot (cs->subparts_cpus, cs->subparts_cpus, - cs->cpus_allowed); +cpumask_and (cs->subparts_cpus, cs->subparts_cpus, + cs->cpus_allowed); cs->nr_subparts_cpus =cpumask_weight (cs->subparts_cpus); }spin_unlock_irq (&callback_lock);
@@ -2005,20 +2012,26 @@ static int update_prstate(struct cpuset *cs, int new_prs) } }else {/* -* Turning off partition root will clear the -* CS_CPU_EXCLUSIVE bit. +* Switch back to member is always allowed if PRS_ERROR. */ if (old_prs ==PRS_ERROR ) { -update_flag (CS_CPU_EXCLUSIVE , cs,0 ); err =0 ; - goto out; + goto reset_flag; } +/* +* A partition root cannot be reverted to member if some +* CPUs have been distributed to child partition roots. +*/ +if (!cpumask_empty (cs->subparts_cpus)) +return -EBUSY ; + err =update_parent_subparts_cpumask (cs, partcmd_disable,NULL , &tmpmask);if (err) goto out; +reset_flag:/* Turning off CS_CPU_EXCLUSIVE will not return error */ update_flag (CS_CPU_EXCLUSIVE , cs,0 ); }
@@ -3100,11 +3113,28 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)/* * In the unlikely event that a partition root has empty -* effective_cpus or its parent becomes erroneous, we have to -* transition it to the erroneous state. +* effective_cpus, we will have to force any child partitions, +* if present, to become invalid by setting nr_subparts_cpus to 0 +* without causing itself to become invalid. +*/ +if (is_partition_root (cs) && cs->nr_subparts_cpus && +cpumask_empty (&new_cpus)) { + cs->nr_subparts_cpus =0 ; +cpumask_clear (cs->subparts_cpus); +compute_effective_cpumask (&new_cpus, cs, parent); + } + +/* +* If empty effective_cpus or zero nr_subparts_cpus or its parent +* becomes erroneous, we have to transition it to the erroneous state. */ if (is_partition_root (cs) && (cpumask_empty (&new_cpus) || - (parent->partition_root_state ==PRS_ERROR ))) { + (parent->partition_root_state ==PRS_ERROR ) || + !parent->nr_subparts_cpus)) { +int old_prs; + +update_parent_subparts_cpumask (cs, partcmd_disable, +NULL , tmp);if (cs->nr_subparts_cpus) {spin_lock_irq (&callback_lock); cs->nr_subparts_cpus =0 ;
@@ -3113,38 +3143,23 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)compute_effective_cpumask (&new_cpus, cs, parent); } -/* -* If the effective_cpus is empty because the child -* partitions take away all the CPUs, we can keep -* the current partition and let the child partitions -* fight for available CPUs. -*/ -if ((parent->partition_root_state ==PRS_ERROR ) || -cpumask_empty (&new_cpus)) { -int old_prs; - -update_parent_subparts_cpumask (cs, partcmd_disable, -NULL , tmp); - old_prs = cs->partition_root_state; -if (old_prs !=PRS_ERROR ) { -spin_lock_irq (&callback_lock); - cs->partition_root_state =PRS_ERROR ; -spin_unlock_irq (&callback_lock); -notify_partition_change (cs, old_prs,PRS_ERROR ); - } + old_prs = cs->partition_root_state; +if (old_prs !=PRS_ERROR ) { +spin_lock_irq (&callback_lock); + cs->partition_root_state =PRS_ERROR ; +spin_unlock_irq (&callback_lock); +notify_partition_change (cs, old_prs,PRS_ERROR ); }cpuset_force_rebuild (); }/* * On the other hand, an erroneous partition root may be transitioned -* back to a regular one or a partition root with no CPU allocated -* from the parent may change to erroneous. +* back to a regular one. */ -if (is_partition_root (parent) && - ((cs->partition_root_state ==PRS_ERROR ) || - !cpumask_intersects (&new_cpus, parent->subparts_cpus)) && -update_parent_subparts_cpumask (cs, partcmd_update,NULL , tmp)) +else if (is_partition_root (parent) && + (cs->partition_root_state ==PRS_ERROR ) && +update_parent_subparts_cpumask (cs, partcmd_update,NULL , tmp))cpuset_force_rebuild (); update_tasks:
Signature · 1 line
2.18.1
Tejun Heo
maintainerRe: [PATCH v4 2/6] cgroup/cpuset: Properly handle partition root tree
Hello,
Quoted 4 lines · Waiman Long
For a partition root tree with parent and child partition roots, this patch will now prohibit changing parent partition root back to member as changes to "cpuset.cpus.partition" should not cause those child partition roots to become invalid.
So, the general rule is that a descendant should never be able to affect or restrict what an ancestor can do in terms of configuration. This is because descendant cgroups can be delegated and a system manager sitting at a higher level in the hierarchy may not have much control over what happens under delegated subtrees.
Given that we're promoting the error state as the first class citizen in the interface anyway, wouldn't it be better to keep this in line too?
Thanks.
Signature · 1 line
tejun
Re: [PATCH v4 2/6] cgroup/cpuset: Properly handle partition root tree
Quoted 7 lines · Tejun Heo
Hello,
Quoted 4 lines · Waiman Long
For a partition root tree with parent and child partition roots, this patch will now prohibit changing parent partition root back to member as changes to "cpuset.cpus.partition" should not cause those child partition roots to become invalid.
Quoted 8 lines
So, the general rule is that a descendant should never be able to affect or restrict what an ancestor can do in terms of configuration. This is because descendant cgroups can be delegated and a system manager sitting at a higher level in the hierarchy may not have much control over what happens under delegated subtrees.
Given that we're promoting the error state as the first class citizen in the interface anyway, wouldn't it be better to keep this in line too?
Disabling partition at the parent level does invalidate all the child partitions under it. So it must be done with care when we disable a partition.
How about we give some indication that a child partition exist when reading cpuset.cpus.partition and recommend double-checking it before disabling a partition? For example, we keep track of the number of cpus delegated to child partitions. Perhaps we can list that information on read.
With that information available, I have no objection to allow disabling a parent partition with child partitions under it.
Cheers,
Longman
Tejun Heo
maintainerRe: [PATCH v4 2/6] cgroup/cpuset: Properly handle partition root tree
Hello,
Quoted 11 lines · Waiman Long
Disabling partition at the parent level does invalidate all the child partitions under it. So it must be done with care when we disable a partition.
How about we give some indication that a child partition exist when reading cpuset.cpus.partition and recommend double-checking it before disabling a partition? For example, we keep track of the number of cpus delegated to child partitions. Perhaps we can list that information on read.
With that information available, I have no objection to allow disabling a parent partition with child partitions under it.
This is a general problem which has always existed regardless of whether the errors are synchronous or not. There are many different reasons that a write to a cpuset interface file could fail and it has never been easy to tell why a given operation was rejected. Making error notifications asynchronous doesn't really change anything fundamental although it does make the situation a bit more opaque.
I'm all for improving visibility. Now that we can consolidate most error states into a unified failure state, this might actually be easier to do. IOW, we now just have to explain why a given cgroup is in an invalid state rather than additionally having to explain why a given write has been rejected, which is pretty awkward to do as those failures are transient and local to the writer.
So, if you wanna tackle this, let's do it right and provide something comprehensive rather than explaining just one failure.
Thanks.
Signature · 1 line
tejun
Re: [PATCH v4 2/6] cgroup/cpuset: Properly handle partition root tree
Quoted 28 lines · Tejun Heo
Hello,
Quoted 11 lines · Waiman Long
Disabling partition at the parent level does invalidate all the child partitions under it. So it must be done with care when we disable a partition.
How about we give some indication that a child partition exist when reading cpuset.cpus.partition and recommend double-checking it before disabling a partition? For example, we keep track of the number of cpus delegated to child partitions. Perhaps we can list that information on read.
With that information available, I have no objection to allow disabling a parent partition with child partitions under it.
This is a general problem which has always existed regardless of whether the errors are synchronous or not. There are many different reasons that a write to a cpuset interface file could fail and it has never been easy to tell why a given operation was rejected. Making error notifications asynchronous doesn't really change anything fundamental although it does make the situation a bit more opaque.
I'm all for improving visibility. Now that we can consolidate most error states into a unified failure state, this might actually be easier to do. IOW, we now just have to explain why a given cgroup is in an invalid state rather than additionally having to explain why a given write has been rejected, which is pretty awkward to do as those failures are transient and local to the writer.
Quoted 2 lines
So, if you wanna tackle this, let's do it right and provide something comprehensive rather than explaining just one failure.
That sounds reasonable. My current idea is to add invalid partition reason string to cpuset. So when users read cpuset.cpus.partition of an invalid partition, it will read something like "root invalid (<reason>)".
What do you think?
Cheers,
Longman
Tejun Heo
maintainerRe: [PATCH v4 2/6] cgroup/cpuset: Properly handle partition root tree
Quoted 5 lines · Waiman Long
That sounds reasonable. My current idea is to add invalid partition reason string to cpuset. So when users read cpuset.cpus.partition of an invalid partition, it will read something like "root invalid (<reason>)".
What do you think?
Sounds good to me.
Thanks.
Signature · 1 line
tejun
Waiman Long
maintainerPATCH v4 3/6 cgroup/cpuset: Add a new isolated cpus.partition type
In reply to Waiman LongCpuset v1 uses the sched_load_balance control file to determine if load balancing should be enabled. Cpuset v2 gets rid of sched_load_balance as its use may require disabling load balancing at cgroup root.
For workloads that require very low latency like DPDK, the latency jitters caused by periodic load balancing may exceed the desired latency limit.
When cpuset v2 is in use, the only way to avoid this latency cost is to use the "isolcpus=" kernel boot option to isolate a set of CPUs. After the kernel boot, however, there is no way to add or remove CPUs from this isolated set. For workloads that are more dynamic in nature, that means users have to provision enough CPUs for the worst case situation resulting in excess idle CPUs.
To address this issue for cpuset v2, a new cpuset.cpus.partition type "isolated" is added which allows the creation of a cpuset partition without load balancing. This will allow system administrators to dynamically adjust the size of isolated partition to the current need of the workload without rebooting the system.
--- kernel/cgroup/cpuset.c | 48 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-)
kernel/cgroup/cpuset.c +43 -5
@@ -172,6 +172,8 @@ struct cpuset {* * 1 - partition root * +* 2 - partition root without load balancing (isolated) +* * -1 - invalid partition root * None of the cpus in cpus_allowed can be put into the parent's * subparts_cpus. In this case, the cpuset is not a real partition
@@ -181,6 +183,7 @@ struct cpuset {*/ #define PRS_DISABLED 0#define PRS_ENABLED 1 +#define PRS_ISOLATED 2#define PRS_ERROR -1/*
@@ -1268,17 +1271,22 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,if (cmd == partcmd_update) {/* -* Check for possible transition between PRS_ENABLED -* and PRS_ERROR. +* Check for possible transition between PRS_ERROR and +* PRS_ENABLED/PRS_ISOLATED. */ switch (cpuset->partition_root_state) {case PRS_ENABLED : +case PRS_ISOLATED :if (part_error) new_prs =PRS_ERROR ;break ;case PRS_ERROR : -if (!part_error) +if (part_error) +break ; +if (is_sched_load_balance (cpuset)) new_prs =PRS_ENABLED ; +else + new_prs =PRS_ISOLATED ;break ; } }
@@ -1413,6 +1421,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)break ;case PRS_ENABLED : +case PRS_ISOLATED :if (update_parent_subparts_cpumask (cp, partcmd_update,NULL , tmp))update_tasks_cpumask (parent);/*
@@ -1437,7 +1446,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)spin_lock_irq (&callback_lock); -if (cp->nr_subparts_cpus && (new_prs !=PRS_ENABLED )) { +if (cp->nr_subparts_cpus && (new_prs <=0 )) {/* * Put all active subparts_cpus back to effective_cpus. */
@@ -1976,6 +1985,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)int err, old_prs = cs->partition_root_state;struct cpuset *parent =parent_cs (cs);struct tmpmasks tmpmask; +bool sched_domain_rebuilt = false;if (old_prs == new_prs)return 0 ;
@@ -2010,6 +2020,22 @@ static int update_prstate(struct cpuset *cs, int new_prs)update_flag (CS_CPU_EXCLUSIVE , cs,0 ); goto out; } + +if (new_prs ==PRS_ISOLATED ) { +/* +* Disable the load balance flag should not return an +* error unless the system is running out of memory. +*/ +update_flag (CS_SCHED_LOAD_BALANCE , cs,0 ); + sched_domain_rebuilt = true; + } + }else if (old_prs && new_prs) { +/* +* A change in load balance state only, no change in cpumasks. +*/ +update_flag (CS_SCHED_LOAD_BALANCE , cs, (new_prs !=PRS_ISOLATED )); + err =0 ; + goto out;/* Sched domain is rebuilt in update_flag() */ }else {/* * Switch back to member is always allowed if PRS_ERROR.
@@ -2034,6 +2060,12 @@ static int update_prstate(struct cpuset *cs, int new_prs) reset_flag:/* Turning off CS_CPU_EXCLUSIVE will not return error */ update_flag (CS_CPU_EXCLUSIVE , cs,0 ); + +if (!is_sched_load_balance (cs)) { +/* Make sure load balance is on */ +update_flag (CS_SCHED_LOAD_BALANCE , cs,1 ); + sched_domain_rebuilt = true; + } }/*
@@ -2046,7 +2078,8 @@ static int update_prstate(struct cpuset *cs, int new_prs)if (parent->child_ecpus_count)update_sibling_cpumasks (parent, cs, &tmpmask); -rebuild_sched_domains_locked (); +if (!sched_domain_rebuilt) +rebuild_sched_domains_locked (); out:if (!err) {spin_lock_irq (&callback_lock);
@@ -2548,6 +2581,9 @@ static int sched_partition_show(struct seq_file *seq, void *v)case PRS_ENABLED :seq_puts (seq,"root\n" );break ; +case PRS_ISOLATED : +seq_puts (seq,"isolated\n" ); +break ;case PRS_DISABLED :seq_puts (seq,"member\n" );break ;
@@ -2574,6 +2610,8 @@ static ssize_t sched_partition_write(struct kernfs_open_file *of, char *buf, val =PRS_ENABLED ; else if (!strcmp(buf, "member")) val =PRS_DISABLED ; + else if (!strcmp(buf, "isolated")) + val =PRS_ISOLATED ; else return -EINVAL;
Signature · 1 line
2.18.1
Waiman Long
maintainerPATCH v4 4/6 cgroup/cpuset: Allow non-top parent partition root to distribute out all CPUs
In reply to Waiman LongCurrently, a parent partition root cannot distribute all its CPUs to child partition roots with no CPUs left. However in some use cases, a management application may want to create a parent partition root as a management unit with no task associated with it and has all its CPUs distributed to various child partition roots dynamically according to their needs. Leaving a cpu in the parent partition root in such a case is now a waste.
To accommodate such use cases, a parent partition root can now have all its CPUs distributed to its child partition roots as long as:
1) it is not the top cpuset; and
2) there is no task directly associated with the parent.
Once an empty parent partition root is formed, no new task can be moved into it.
--- kernel/cgroup/cpuset.c | 91 ++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 30 deletions(-)
kernel/cgroup/cpuset.c +61 -30
@@ -279,6 +279,11 @@ static inline void notify_partition_change(struct cpuset *cs,cgroup_file_notify (&cs->partition_file); } +static inline int cpuset_has_tasks (const struct cpuset *cs) +{ +return cs->css.cgroup->nr_populated_csets; +} +static struct cpuset top_cpuset = { .flags = ((1 <<CS_ONLINE ) | (1 <<CS_CPU_EXCLUSIVE ) | (1 <<CS_MEM_EXCLUSIVE )),
@@ -1186,22 +1191,32 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,if ((cmd != partcmd_update) &&css_has_online_children (&cpuset->css))return -EBUSY ; -/* -* Enabling partition root is not allowed if not all the CPUs -* can be granted from parent's effective_cpus or at least one -* CPU will be left after that. -*/ -if ((cmd == partcmd_enable) && - (!cpumask_subset (cpuset->cpus_allowed, parent->effective_cpus) || -cpumask_equal (cpuset->cpus_allowed, parent->effective_cpus))) -return -EINVAL ; -/* * A cpumask update cannot make parent's effective_cpus become empty. */ adding = deleting = false; old_prs = new_prs = cpuset->partition_root_state;if (cmd == partcmd_enable) { +bool parent_is_top_cpuset = !parent_cs (parent); +bool no_cpu_in_parent =cpumask_equal (cpuset->cpus_allowed, + parent->effective_cpus); +/* +* Enabling partition root is not allowed if not all the CPUs +* can be granted from parent's effective_cpus. If the parent +* is the top cpuset, at least one CPU must be left after that. +*/ +if (!cpumask_subset (cpuset->cpus_allowed, parent->effective_cpus) || + (parent_is_top_cpuset && no_cpu_in_parent)) +return -EINVAL ; + +/* +* A non-top parent can be left with no CPU as long as there +* is no task directly associated with the parent. For such +* a parent, no new task can be moved into it. +*/ +if (no_cpu_in_parent &&cpuset_has_tasks (parent)) +return -EINVAL ; +cpumask_copy (tmp->addmask, cpuset->cpus_allowed); adding = true; }else if (cmd == partcmd_disable) {
@@ -1231,20 +1246,21 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, adding =cpumask_andnot (tmp->addmask, tmp->addmask, parent->subparts_cpus);/* -* Return error if parent's effective_cpus could become empty. +* Make partition invalid if parent's effective_cpus could +* become empty and there are tasks in the parent. */ -if (adding && +if (adding &&cpuset_has_tasks (parent) &&cpumask_equal (parent->effective_cpus, tmp->addmask)) {if (!deleting) -return -EINVAL ; + part_error = true;/* * As some of the CPUs in subparts_cpus might have * been offlined, we need to compute the real delmask * to confirm that. */ -if (!cpumask_and (tmp->addmask, tmp->delmask, - cpu_active_mask)) -return -EINVAL ; +else if (!cpumask_and (tmp->addmask, tmp->delmask, + cpu_active_mask)) + part_error = true;cpumask_copy (tmp->addmask, parent->effective_cpus); } }else {
@@ -1266,7 +1282,8 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd, parent->effective_cpus); part_error = (is_partition_root (cpuset) && !parent->nr_subparts_cpus) || -cpumask_equal (tmp->addmask, parent->effective_cpus); + (cpumask_equal (tmp->addmask, parent->effective_cpus) && +cpuset_has_tasks (parent)); }if (cmd == partcmd_update) {
@@ -1367,9 +1384,15 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)/* * If it becomes empty, inherit the effective mask of the -* parent, which is guaranteed to have some CPUs. +* parent, which is guaranteed to have some CPUs unless +* it is a partition root that has explicitly distributed +* out all its CPUs. */ if (is_in_v2_mode () &&cpumask_empty (tmp->new_cpus)) { +if (is_partition_root (cp) && +cpumask_equal (cp->cpus_allowed, cp->subparts_cpus)) + goto update_parent_subparts; +cpumask_copy (tmp->new_cpus, parent->effective_cpus);if (!cp->use_parent_ecpus) { cp->use_parent_ecpus = true;
@@ -1391,6 +1414,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)continue ; } +update_parent_subparts:/* * update_parent_subparts_cpumask() should have been called * for cs already in update_cpumask(). We should also call
@@ -1466,12 +1490,9 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)*/ cpumask_andnot (cp->effective_cpus, cp->effective_cpus, cp->subparts_cpus); -WARN_ON_ONCE (cpumask_empty (cp->effective_cpus)); } -if (new_prs != old_prs) - cp->partition_root_state = new_prs; - + cp->partition_root_state = new_prs;spin_unlock_irq (&callback_lock);notify_partition_change (cp, old_prs, new_prs);
@@ -2215,6 +2236,13 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))) goto out_unlock; +/* +* On default hierarchy, task cannot be moved to a cpuset with empty +* effective cpus. +*/ +if (is_in_v2_mode () &&cpumask_empty (cs->effective_cpus)) + goto out_unlock; +cgroup_taskset_for_each (task, css, tset) { ret =task_can_attach (task, cs->cpus_allowed);if (ret)
@@ -3082,7 +3110,8 @@ hotplug_update_tasks(struct cpuset *cs, struct cpumask *new_cpus, nodemask_t *new_mems, bool cpus_updated, bool mems_updated) { - if (cpumask_empty(new_cpus)) + /* A partition root is allowed to have empty effective cpus */ + if (cpumask_empty(new_cpus) && !is_partition_root(cs)) cpumask_copy(new_cpus, parent_cs(cs)->effective_cpus); if (nodes_empty(*new_mems)) *new_mems = parent_cs(cs)->effective_mems;
@@ -3151,22 +3180,24 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)/* * In the unlikely event that a partition root has empty -* effective_cpus, we will have to force any child partitions, -* if present, to become invalid by setting nr_subparts_cpus to 0 -* without causing itself to become invalid. +* effective_cpus with tasks, we will have to force any child +* partitions, if present, to become invalid by setting +* nr_subparts_cpus to 0 without causing itself to become invalid. */ if (is_partition_root (cs) && cs->nr_subparts_cpus && -cpumask_empty (&new_cpus)) { +cpumask_empty (&new_cpus) &&cpuset_has_tasks (cs)) { cs->nr_subparts_cpus =0 ;cpumask_clear (cs->subparts_cpus);compute_effective_cpumask (&new_cpus, cs, parent); }/* -* If empty effective_cpus or zero nr_subparts_cpus or its parent -* becomes erroneous, we have to transition it to the erroneous state. +* If empty effective_cpus with tasks or zero nr_subparts_cpus or +* its parent becomes erroneous, we have to transition it to the +* erroneous state. */ -if (is_partition_root (cs) && (cpumask_empty (&new_cpus) || +if (is_partition_root (cs) && + ((cpumask_empty (&new_cpus) &&cpuset_has_tasks (cs)) || (parent->partition_root_state ==PRS_ERROR ) || !parent->nr_subparts_cpus)) {int old_prs;
Signature · 1 line
2.18.1
Tejun Heo
maintainerRe: [PATCH v4 4/6] cgroup/cpuset: Allow non-top parent partition root to distribute out all CPUs
Quoted 8 lines · Waiman Long
Currently, a parent partition root cannot distribute all its CPUs to child partition roots with no CPUs left. However in some use cases, a management application may want to create a parent partition root as a management unit with no task associated with it and has all its CPUs distributed to various child partition roots dynamically according to their needs. Leaving a cpu in the parent partition root in such a case is now a waste.
Quoted 8 lines
To accommodate such use cases, a parent partition root can now have all its CPUs distributed to its child partition roots as long as:
1) it is not the top cpuset; and2) there is no task directly associated with the parent.
Once an empty parent partition root is formed, no new task can be moved into it.
The above are already enforced by cgroup2 core, right? No intermediate cgroup with controllers enabled can have processes. From controllers' POV, only leaves can have processes.
Thanks.
Signature · 1 line
tejun
Re: [PATCH v4 4/6] cgroup/cpuset: Allow non-top parent partition root to distribute out all CPUs
Quoted 14 lines · Tejun Heo
Quoted 13 lines · Waiman Long
Currently, a parent partition root cannot distribute all its CPUs to child partition roots with no CPUs left. However in some use cases, a management application may want to create a parent partition root as a management unit with no task associated with it and has all its CPUs distributed to various child partition roots dynamically according to their needs. Leaving a cpu in the parent partition root in such a case is now a waste.
To accommodate such use cases, a parent partition root can now have all its CPUs distributed to its child partition roots as long as:
1) it is not the top cpuset; and
2) there is no task directly associated with the parent.
Quoted 6 lines
Quoted 2 lines
Once an empty parent partition root is formed, no new task can be moved into it.
The above are already enforced by cgroup2 core, right? No intermediate cgroup with controllers enabled can have processes. From controllers' POV, only leaves can have processes.
I don't think that is true. A task can reside anywhere in the cgroup hierarchy. I have encountered no problem moving tasks around.
Cheers,
Longman
Tejun Heo
maintainerRe: [PATCH v4 4/6] cgroup/cpuset: Allow non-top parent partition root to distribute out all CPUs
Quoted 2 lines · Waiman Long
I don't think that is true. A task can reside anywhere in the cgroup hierarchy. I have encountered no problem moving tasks around.
Oh, that shouldn't be happening with controllers enabled. Can you please share a repro?
Thanks.
Signature · 1 line
tejun
Re: [PATCH v4 4/6] cgroup/cpuset: Allow non-top parent partition root to distribute out all CPUs
Quoted 5 lines · Tejun Heo
Quoted 2 lines · Waiman Long
I don't think that is true. A task can reside anywhere in the cgroup hierarchy. I have encountered no problem moving tasks around.
Oh, that shouldn't be happening with controllers enabled. Can you please share a repro?
I have done further testing. Enabling controllers won't prohibit moving a task into a parent cgroup as long as the child cgroups have no tasks. Once the child cgroup has task, moving another task to the parent is not allowed (-EBUSY). Similarly if a parent cgroup has tasks, you can't put new tasks into the child cgroup. I don't realize that we have such constraints as I usually do my testing with a cgroup hierarchy with no tasks initially. Anyway, a new lesson learned.
I will try to see how to address that in the patch, but the additional check added is still valid in some special case.
Cheers,
Longman
Tejun Heo
maintainerRe: [PATCH v4 4/6] cgroup/cpuset: Allow non-top parent partition root to distribute out all CPUs
Quoted 9 lines · Waiman Long
Quoted 5 lines · Tejun Heo
Quoted 2 lines · Waiman Long
I don't think that is true. A task can reside anywhere in the cgroup hierarchy. I have encountered no problem moving tasks around.
Oh, that shouldn't be happening with controllers enabled. Can you please share a repro?
I have done further testing. Enabling controllers won't prohibit moving a task into a parent cgroup as long as the child cgroups have no tasks. Once
Should be "as long as there's no child cgroups".
root@test /s/f/cgroup# mkdir test
root@test /s/f/cgroup# mkdir -p test/A
root@test /s/f/cgroup# echo +io > test/cgroup.subtree_control root@test /s/f/cgroup# echo $fish_pid > test/cgroup.procs
write: Device or resource busy
Quoted 3 lines
the child cgroup has task, moving another task to the parent is not allowed (
-EBUSY). Similarly if a parent cgroup has tasks, you can't put new tasks into the child cgroup. I don't realize that we have such constraints as I
You can't enable controller from a populated cgroup:
root@test /s/f/cgroup# mkdir test
root@test /s/f/cgroup# echo +io > test/cgroup.subtree_control root@test /s/f/cgroup# echo $fish_pid > test/cgroup.procs
Quoted 2 lines
usually do my testing with a cgroup hierarchy with no tasks initially. Anyway, a new lesson learned.
The invariant is that from each controller's POV, all cgroups with processes in them are leaves. This is all pretty well documented in cgroup-v2.rst.
Thanks.
Signature · 1 line
tejun
Waiman Long
maintainerPATCH v4 5/6 cgroup/cpuset: Update description of cpuset.cpus.partition in cgroup-v2.rst
In reply to Waiman LongUpdate Documentation/admin-guide/cgroup-v2.rst on the newly introduced "isolated" cpuset partition type as well as the ability to create non-top cpuset partition with no cpu allocated to it.
--- Documentation/admin-guide/cgroup-v2.rst | 104 +++++++++++++++--------- 1 file changed, 64 insertions(+), 40 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +64 -40
@@ -2080,8 +2080,9 @@ Cpuset Interface Files It accepts only the following input values when written to. ======== ================================ - "root" a partition root - "member" a non-root member of a partition + "member" Non-root member of a partition + "root" Partition root + "isolated" Partition root without load balancing ======== ================================ When set to be a partition root, the current cgroup is the
@@ -2090,9 +2091,14 @@ Cpuset Interface Files partition roots themselves and their descendants. The root cgroup is always a partition root. - There are constraints on where a partition root can be set. - It can only be set in a cgroup if all the following conditions - are true. + When set to "isolated", the CPUs in that partition root will + be in an isolated state without any load balancing from the + scheduler. Tasks in such a partition must be explicitly bound + to each individual CPU. + + There are constraints on where a partition root can be set + ("root" or "isolated"). 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.
@@ -2103,51 +2109,69 @@ Cpuset Interface Files eliminating corner cases that have to be handled if such a condition is allowed. - Setting it to partition root will take the CPUs away from the - effective CPUs of the parent cgroup. Once it is set, this + Setting it to a partition root will take the CPUs away from + the effective CPUs of the parent cgroup. Once it is set, this file cannot be reverted back to "member" if there are any child cgroups with cpuset enabled. - A parent partition cannot distribute all its CPUs to its - child partitions. There must be at least one cpu left in the - parent partition. - - Once becoming a partition root, changes to "cpuset.cpus" is - generally allowed as long as the first condition above is true, - the change will not take away all the CPUs from the parent - partition and the new "cpuset.cpus" value is a superset of its - children's "cpuset.cpus" values. - - Sometimes, external factors like changes to ancestors' - "cpuset.cpus" or cpu hotplug can cause the state of the partition - root to change. On read, the "cpuset.sched.partition" file - can show the following values. + A parent partition may distribute all its CPUs to its child + partitions as long as it is not the root cgroup and there is no + task directly associated with that parent partition. Otherwise, + there must be at least one cpu left in the parent partition. + A new task cannot be moved to a partition root with no effective + cpu. + + Once becoming a partition root, changes to "cpuset.cpus" + is generally allowed as long as the first condition above + (cpu exclusivity rule) is true. + + Sometimes, changes to "cpuset.cpus" or cpu hotplug may cause + the state of the partition root to become invalid when the + other constraints of partition root are violated. Therefore, + it is recommended that users should always set "cpuset.cpus" + to the proper value first before enabling partition. In case + "cpuset.cpus" has to be modified after partition is enabled, + users should check the state of "cpuset.cpus.partition" after + making change to it to make sure that the partition is still + valid. + + On read, the "cpuset.cpus.partition" file can show the following + values. ============== ============================== "member" Non-root member of a partition "root" Partition root + "isolated" Partition root without load balancing "root invalid" Invalid partition root ============== ============================== - It is a partition root if the first 2 partition root conditions - above are true and at least one CPU from "cpuset.cpus" is - granted by the parent cgroup. - - A partition root can become invalid if none of CPUs requested - in "cpuset.cpus" can be granted by the parent cgroup or the - parent cgroup is no longer a partition root itself. In this - case, it is not a real partition even though the restriction - of the first partition root condition above will still apply. - The cpu affinity of all the tasks in the cgroup will then be - associated with CPUs in the nearest ancestor partition. - - An invalid partition root can be transitioned back to a - real partition root if at least one of the requested CPUs - can now be granted by its parent. In this case, the cpu - affinity of all the tasks in the formerly invalid partition - will be associated to the CPUs of the newly formed partition. - Changing the partition state of an invalid partition root to - "member" is always allowed even if child cpusets are present. + A partition root becomes invalid if all the CPUs requested in + "cpuset.cpus" become unavailable. This can happen if all the + CPUs have been offlined, or the state of an ancestor partition + root become invalid. In this case, it is not a real partition + even though the restriction of the cpu exclusivity rule will + still apply. The cpu affinity of all the tasks in the cgroup + will then be associated with CPUs in the nearest ancestor + partition. + + In the special case of a parent partition competing with a child + partition for the only CPU left, the parent partition wins and + the child partition becomes invalid. + + An invalid partition root can be transitioned back to a real + partition root if at least one of the requested CPUs become + available again. In this case, the cpu affinity of all the tasks + in the formerly invalid partition will be associated to the CPUs + of the newly formed partition. Changing the partition state of + an invalid partition root to "member" is always allowed even if + child cpusets are present. However changing a partition root back + to member will not be allowed if child partitions are present. + + Poll and inotify events are triggered whenever the state + of "cpuset.cpus.partition" changes. That includes changes + caused by write to "cpuset.cpus.partition" and cpu hotplug. + This will allow a user space agent to monitor changes caused + by hotplug events. Device controller
Signature · 1 line
2.18.1
Tejun Heo
maintainerRe: [PATCH v4 5/6] cgroup/cpuset: Update description of cpuset.cpus.partition in cgroup-v2.rst
Hello,
Documentation/admin-guide/cgroup-v2.rst Cpuset Interface Files · line 2174
Quoted 5 lines · Waiman Long
Documentation/admin-guide/cgroup-v2.rst +5
-0+ Poll and inotify events are triggered whenever the state + of "cpuset.cpus.partition" changes. That includes changes + caused by write to "cpuset.cpus.partition" and cpu hotplug. + This will allow a user space agent to monitor changes caused + by hotplug events.
It might be useful to emphasize that this is the primary mechanism to signify errors and thus should always be monitored.
Thanks.
Signature · 1 line
tejun
Re: [PATCH v4 5/6] cgroup/cpuset: Update description of cpuset.cpus.partition in cgroup-v2.rst
Quoted 10 lines · Tejun Heo
Hello,
Documentation/admin-guide/cgroup-v2.rst Cpuset Interface Files · line 2174
Quoted 5 lines · Waiman Long
Documentation/admin-guide/cgroup-v2.rst +5
-0+ Poll and inotify events are triggered whenever the state + of "cpuset.cpus.partition" changes. That includes changes + caused by write to "cpuset.cpus.partition" and cpu hotplug. + This will allow a user space agent to monitor changes caused + by hotplug events.It might be useful to emphasize that this is the primary mechanism to signify errors and thus should always be monitored.
Sure, will do that in the next version.
Cheers,
Longman
Waiman Long
maintainerPATCH v4 6/6 kselftest/cgroup: Add cpuset v2 partition root state test
In reply to Waiman LongAdd a test script test_cpuset_prs.sh with a helper program wait_inotify for exercising the cpuset v2 partition root state code.
--- tools/testing/selftests/cgroup/Makefile | 5 +- .../selftests/cgroup/test_cpuset_prs.sh | 632 ++++++++++++++++++ tools/testing/selftests/cgroup/wait_inotify.c | 87 +++ 3 files changed, 722 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/cgroup/test_cpuset_prs.sh create mode 100644 tools/testing/selftests/cgroup/wait_inotify.c
tools/testing/selftests/cgroup/Makefile +3 -2
@@ -1,10 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -Wall -pthread -all: +all: ${HELPER_PROGS} TEST_FILES := with_stress.sh -TEST_PROGS := test_stress.sh +TEST_PROGS := test_stress.sh test_cpuset_prs.sh +TEST_GEN_FILES := wait_inotify TEST_GEN_PROGS = test_memcontrol TEST_GEN_PROGS += test_kmem TEST_GEN_PROGS += test_core
tools/testing/selftests/cgroup/test_cpuset_prs.sh new file +632 -0
632 lines not on this page · raw message
tools/testing/selftests/cgroup/wait_inotify.c new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.18.1