mbox series

[v12,00/10] cgroup/cpuset: cpu partition code fixes & enhancements

Message ID 20220901205745.323326-1-longman@redhat.com
Headers show
Series cgroup/cpuset: cpu partition code fixes & enhancements | expand

Message

Waiman Long Sept. 1, 2022, 8:57 p.m. UTC
v12:
 - Change patch 1 to enable update_tasks_cpumask() for top_cpuset except
   for percpu kthreads.
 - Add 2 more patches to make exclusivity rule violations invalidate the
   partition and its siblings instead of failing the change to make it
   consistent with other cpuset changes.
 - Update documentation and test script accordingly.

v11:
 - Fix incorrect spacing in patch 7 and include documentation suggestions
   by Michal.
 - Move partition_is_populated() check to the last one in list of
   conditions to be checked.

v10:
 - Relax constraints for changes made to "cpuset.cpus"
   and "cpuset.cpus.partition" as suggested. Now almost all changes
   are allowed.
 - Add patch 1 to signal that we may need to do additional work in
   the future to relax the constraint that tasks' cpumask may need
   some adjustment if child partitions are present.
 - Add patch 2 for miscellaneous cleanups.

The first patch fixes the problem that tasks in the top_cpuset
will not have its cpus_mask properly set to reflect the reduced
set of cpus available in the top_cpuset when a partition is enabled.

This patchset also includes the following enhancements to the cpuset
v2 partition code.

 1) Allow partitions that have no task to have empty effective cpus.
 2) Relax the constraints on what changes are allowed in cpuset.cpus
    and cpuset.cpus.partition. However, the partition remain invalid
    until the constraints of a valid partition root is satisfied.
 3) Add a new "isolated" partition type for partitions with no load
    balancing which is available in v1 but not yet in v2.
 4) Allow the reading of cpuset.cpus.partition to include a reason
    string as to why the partition remain invalid.

In addition, the cgroup-v2.rst documentation file is updated and a self
test is added to verify the correctness the partition code.

Waiman Long (10):
  cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset
  cgroup/cpuset: Miscellaneous cleanups & add helper functions
  cgroup/cpuset: Allow no-task partition to have empty
    cpuset.cpus.effective
  cgroup/cpuset: Relax constraints to partition & cpus changes
  cgroup/cpuset: Add a new isolated cpus.partition type
  cgroup/cpuset: Show invalid partition reason string
  cgroup/cpuset: Relocate a code block in validate_change()
  cgroup/cpuset: Make partition invalid if cpumask change violates
    exclusivity rule
  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       | 150 ++--
 kernel/cgroup/cpuset.c                        | 817 ++++++++++++------
 tools/testing/selftests/cgroup/.gitignore     |   1 +
 tools/testing/selftests/cgroup/Makefile       |   5 +-
 .../selftests/cgroup/test_cpuset_prs.sh       | 674 +++++++++++++++
 tools/testing/selftests/cgroup/wait_inotify.c |  87 ++
 6 files changed, 1385 insertions(+), 349 deletions(-)
 create mode 100755 tools/testing/selftests/cgroup/test_cpuset_prs.sh
 create mode 100644 tools/testing/selftests/cgroup/wait_inotify.c

Comments

Bagas Sanjaya Sept. 4, 2022, 8:20 a.m. UTC | #1
On Thu, Sep 01, 2022 at 04:57:44PM -0400, Waiman Long wrote:
>  	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
>  	  ========	================================
>  
><snipped>
> +	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 (<reason>)"	Invalid partition root
> +	  "isolated invalid (<reason>)"	Invalid isolated partition root
> +	  ======================	==============================
> +

These tables above produced htmldocs warnings:

Documentation/admin-guide/cgroup-v2.rst:2191: WARNING: Malformed table.
Text in column margin in table line 4.

========      ================================
"member"      Non-root member of a partition
"root"        Partition root
"isolated"    Partition root without load balancing
========      ================================
Documentation/admin-guide/cgroup-v2.rst:2229: WARNING: Malformed table.
Text in column margin in table line 5.

======================        ==============================
"member"                      Non-root member of a partition
"root"                        Partition root
"isolated"                    Partition root without load balancing
"root invalid (<reason>)"     Invalid partition root
"isolated invalid (<reason>)" Invalid isolated partition root
======================        ==============================

I have applied the fixup:

---- >8 ----

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 76b3ea9fd5c560..77b6faecf066cb 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2185,11 +2185,11 @@ Cpuset Interface Files
 
 	It accepts only the following input values when written to.
 
-	  ========	================================
+	  ==========	================================
 	  "member"	Non-root member of a partition
 	  "root"	Partition root
 	  "isolated"	Partition root without load balancing
-	  ========	================================
+	  ==========	================================
 
 	The root cgroup is always a partition root and its state
 	cannot be changed.  All other non-root cgroups start out as
@@ -2222,13 +2222,13 @@ Cpuset Interface Files
 	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 (<reason>)"	Invalid partition root
 	  "isolated invalid (<reason>)"	Invalid isolated partition root
-	  ======================	==============================
+	  =============================	=====================================
 
 	In the case of an invalid partition root, a descriptive string on
 	why the partition is invalid is included within parentheses.

Thanks.
Tejun Heo Sept. 4, 2022, 8:48 p.m. UTC | #2
On Thu, Sep 01, 2022 at 04:57:35PM -0400, Waiman Long wrote:
> v12:
>  - Change patch 1 to enable update_tasks_cpumask() for top_cpuset except
>    for percpu kthreads.
>  - Add 2 more patches to make exclusivity rule violations invalidate the
>    partition and its siblings instead of failing the change to make it
>    consistent with other cpuset changes.
>  - Update documentation and test script accordingly.

Applied to cgroup/for-6.1 with the doc tables fixed.

Thanks a lot for sticking with it. This looks great.
Waiman Long Sept. 6, 2022, 2:57 p.m. UTC | #3
On 9/4/22 04:20, Bagas Sanjaya wrote:
> On Thu, Sep 01, 2022 at 04:57:44PM -0400, Waiman Long wrote:
>>   	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
>>   	  ========	================================
>>   
>> <snipped>
>> +	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 (<reason>)"	Invalid partition root
>> +	  "isolated invalid (<reason>)"	Invalid isolated partition root
>> +	  ======================	==============================
>> +
> These tables above produced htmldocs warnings:
>
> Documentation/admin-guide/cgroup-v2.rst:2191: WARNING: Malformed table.
> Text in column margin in table line 4.
>
> ========      ================================
> "member"      Non-root member of a partition
> "root"        Partition root
> "isolated"    Partition root without load balancing
> ========      ================================
> Documentation/admin-guide/cgroup-v2.rst:2229: WARNING: Malformed table.
> Text in column margin in table line 5.
>
> ======================        ==============================
> "member"                      Non-root member of a partition
> "root"                        Partition root
> "isolated"                    Partition root without load balancing
> "root invalid (<reason>)"     Invalid partition root
> "isolated invalid (<reason>)" Invalid isolated partition root
> ======================        ==============================
>
> I have applied the fixup:
>
> ---- >8 ----
>
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
> index 76b3ea9fd5c560..77b6faecf066cb 100644
> --- a/Documentation/admin-guide/cgroup-v2.rst
> +++ b/Documentation/admin-guide/cgroup-v2.rst
> @@ -2185,11 +2185,11 @@ Cpuset Interface Files
>   
>   	It accepts only the following input values when written to.
>   
> -	  ========	================================
> +	  ==========	================================
>   	  "member"	Non-root member of a partition
>   	  "root"	Partition root
>   	  "isolated"	Partition root without load balancing
> -	  ========	================================
> +	  ==========	================================
>   
>   	The root cgroup is always a partition root and its state
>   	cannot be changed.  All other non-root cgroups start out as
> @@ -2222,13 +2222,13 @@ Cpuset Interface Files
>   	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 (<reason>)"	Invalid partition root
>   	  "isolated invalid (<reason>)"	Invalid isolated partition root
> -	  ======================	==============================
> +	  =============================	=====================================
>   
>   	In the case of an invalid partition root, a descriptive string on
>   	why the partition is invalid is included within parentheses.
>
> Thanks.

Thanks for the fixes. Will apply that.

Cheers,
Longman