mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH cgroup/for-next 0/2] cpuset: fix failure to enable isolated partition when containing isolcpus
@ 2025-09-18 12:25 Chen Ridong
  2025-09-18 12:25 ` [PATCH cgroup/for-next 1/2] " Chen Ridong
  2025-09-18 12:25 ` [PATCH cgroup/for-next 2/2] cpuset: Use new excpus for nocpu error check when enabling root partition Chen Ridong
  0 siblings, 2 replies; 6+ messages in thread
From: Chen Ridong @ 2025-09-18 12:25 UTC (permalink / raw)
  To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong

From: Chen Ridong <chenridong@huawei.com>

This series fixes an issue where enabling an isolated partition fails if
the cpuset contains isolcpus. Additionally, the patches include
modifications to address a potential related issue.

Chen Ridong (2):
  cpuset: fix failure to enable isolated partition when containing
    isolcpus
  cpuset: Use new excpus for nocpu error check when enabling root
    partition

 kernel/cgroup/cpuset.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH cgroup/for-next 1/2] cpuset: fix failure to enable isolated partition when containing isolcpus
  2025-09-18 12:25 [PATCH cgroup/for-next 0/2] cpuset: fix failure to enable isolated partition when containing isolcpus Chen Ridong
@ 2025-09-18 12:25 ` Chen Ridong
  2025-09-18 18:02   ` Waiman Long
  2025-09-18 12:25 ` [PATCH cgroup/for-next 2/2] cpuset: Use new excpus for nocpu error check when enabling root partition Chen Ridong
  1 sibling, 1 reply; 6+ messages in thread
From: Chen Ridong @ 2025-09-18 12:25 UTC (permalink / raw)
  To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong

From: Chen Ridong <chenridong@huawei.com>

The 'isolcpus' parameter specified at boot time can be assigned to an
isolated partition. While it is valid put the 'isolcpus' in an isolated
partition, attempting to change a member cpuset to an isolated partition
will fail if the cpuset contains any 'isolcpus'.

For example, the system boots with 'isolcpus=9', and the following
configuration works correctly:

  # cd /sys/fs/cgroup/
  # mkdir test
  # echo 1 > test/cpuset.cpus
  # echo isolated > test/cpuset.cpus.partition
  # cat test/cpuset.cpus.partition
  isolated
  # echo 9 > test/cpuset.cpus
  # cat test/cpuset.cpus.partition
  isolated
  # cat test/cpuset.cpus
  9

However, the following steps to convert a member cpuset to an isolated
partition will fail:

  # cd /sys/fs/cgroup/
  # mkdir test
  # echo 9 > test/cpuset.cpus
  # echo isolated > test/cpuset.cpus.partition
  # cat test/cpuset.cpus.partition
  isolated invalid (partition config conflicts with housekeeping setup)

The issue occurs because the new partition state (new_prs) is used for
validation against housekeeping constraints before it has been properly
updated. To resolve this, move the assignment of new_prs before the
housekeeping validation check when enabling a root partition.

Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 kernel/cgroup/cpuset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 44231cb1d83f..2b7e2f17577e 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1806,6 +1806,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
 		xcpus = tmp->delmask;
 		if (compute_excpus(cs, xcpus))
 			WARN_ON_ONCE(!cpumask_empty(cs->exclusive_cpus));
+		new_prs = (cmd == partcmd_enable) ? PRS_ROOT : PRS_ISOLATED;
 
 		/*
 		 * Enabling partition root is not allowed if its
@@ -1838,7 +1839,6 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
 
 		deleting = true;
 		subparts_delta++;
-		new_prs = (cmd == partcmd_enable) ? PRS_ROOT : PRS_ISOLATED;
 	} else if (cmd == partcmd_disable) {
 		/*
 		 * May need to add cpus back to parent's effective_cpus
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH cgroup/for-next 2/2] cpuset: Use new excpus for nocpu error check when enabling root partition
  2025-09-18 12:25 [PATCH cgroup/for-next 0/2] cpuset: fix failure to enable isolated partition when containing isolcpus Chen Ridong
  2025-09-18 12:25 ` [PATCH cgroup/for-next 1/2] " Chen Ridong
@ 2025-09-18 12:25 ` Chen Ridong
  2025-09-18 18:10   ` Waiman Long
  1 sibling, 1 reply; 6+ messages in thread
From: Chen Ridong @ 2025-09-18 12:25 UTC (permalink / raw)
  To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong

From: Chen Ridong <chenridong@huawei.com>

A previous patch fixed a bug where new_prs should be assigned before
checking housekeeping conflicts. This patch addresses another potential
issue: the nocpu error check currently uses the xcpus which is not updated.
Although no issue has been observed so far, the check should be performed
using the new effective exclusive cpus.

The comment has been removed because the function returns an error if
nocpu checking fails, which is unrelated to the parent.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 kernel/cgroup/cpuset.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 2b7e2f17577e..44d65890326a 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1818,11 +1818,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
 		if (prstate_housekeeping_conflict(new_prs, xcpus))
 			return PERR_HKEEPING;
 
-		/*
-		 * A parent can be left with no CPU as long as there is no
-		 * task directly associated with the parent partition.
-		 */
-		if (nocpu)
+		if (tasks_nocpu_error(parent, cs, xcpus))
 			return PERR_NOCPUS;
 
 		/*
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH cgroup/for-next 1/2] cpuset: fix failure to enable isolated partition when containing isolcpus
  2025-09-18 12:25 ` [PATCH cgroup/for-next 1/2] " Chen Ridong
@ 2025-09-18 18:02   ` Waiman Long
  2025-09-19  0:58     ` Chen Ridong
  0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2025-09-18 18:02 UTC (permalink / raw)
  To: Chen Ridong, tj, hannes, mkoutny
  Cc: cgroups, linux-kernel, lujialin4, chenridong

On 9/18/25 8:25 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> The 'isolcpus' parameter specified at boot time can be assigned to an
> isolated partition. While it is valid put the 'isolcpus' in an isolated
> partition, attempting to change a member cpuset to an isolated partition
> will fail if the cpuset contains any 'isolcpus'.
>
> For example, the system boots with 'isolcpus=9', and the following
> configuration works correctly:
>
>    # cd /sys/fs/cgroup/
>    # mkdir test
>    # echo 1 > test/cpuset.cpus
>    # echo isolated > test/cpuset.cpus.partition
>    # cat test/cpuset.cpus.partition
>    isolated
>    # echo 9 > test/cpuset.cpus
>    # cat test/cpuset.cpus.partition
>    isolated
>    # cat test/cpuset.cpus
>    9
>
> However, the following steps to convert a member cpuset to an isolated
> partition will fail:
>
>    # cd /sys/fs/cgroup/
>    # mkdir test
>    # echo 9 > test/cpuset.cpus
>    # echo isolated > test/cpuset.cpus.partition
>    # cat test/cpuset.cpus.partition
>    isolated invalid (partition config conflicts with housekeeping setup)
>
> The issue occurs because the new partition state (new_prs) is used for
> validation against housekeeping constraints before it has been properly
> updated. To resolve this, move the assignment of new_prs before the
> housekeeping validation check when enabling a root partition.
>
> Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
> Signed-off-by: Chen Ridong <chenridong@huawei.com>

Thanks for finding the bug. However, I think the commit to be fixed 
should be 4a74e418881f ("cgroup/cpuset: Check partition conflict with 
housekeeping setup"), not the one you listed above.

Cheers,
Longman


> ---
>   kernel/cgroup/cpuset.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 44231cb1d83f..2b7e2f17577e 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1806,6 +1806,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
>   		xcpus = tmp->delmask;
>   		if (compute_excpus(cs, xcpus))
>   			WARN_ON_ONCE(!cpumask_empty(cs->exclusive_cpus));
> +		new_prs = (cmd == partcmd_enable) ? PRS_ROOT : PRS_ISOLATED;
>   
>   		/*
>   		 * Enabling partition root is not allowed if its
> @@ -1838,7 +1839,6 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
>   
>   		deleting = true;
>   		subparts_delta++;
> -		new_prs = (cmd == partcmd_enable) ? PRS_ROOT : PRS_ISOLATED;
>   	} else if (cmd == partcmd_disable) {
>   		/*
>   		 * May need to add cpus back to parent's effective_cpus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH cgroup/for-next 2/2] cpuset: Use new excpus for nocpu error check when enabling root partition
  2025-09-18 12:25 ` [PATCH cgroup/for-next 2/2] cpuset: Use new excpus for nocpu error check when enabling root partition Chen Ridong
@ 2025-09-18 18:10   ` Waiman Long
  0 siblings, 0 replies; 6+ messages in thread
From: Waiman Long @ 2025-09-18 18:10 UTC (permalink / raw)
  To: Chen Ridong, tj, hannes, mkoutny
  Cc: cgroups, linux-kernel, lujialin4, chenridong


On 9/18/25 8:25 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> A previous patch fixed a bug where new_prs should be assigned before
> checking housekeeping conflicts. This patch addresses another potential
> issue: the nocpu error check currently uses the xcpus which is not updated.
> Although no issue has been observed so far, the check should be performed
> using the new effective exclusive cpus.
>
> The comment has been removed because the function returns an error if
> nocpu checking fails, which is unrelated to the parent.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>   kernel/cgroup/cpuset.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 2b7e2f17577e..44d65890326a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1818,11 +1818,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
>   		if (prstate_housekeeping_conflict(new_prs, xcpus))
>   			return PERR_HKEEPING;
>   
> -		/*
> -		 * A parent can be left with no CPU as long as there is no
> -		 * task directly associated with the parent partition.
> -		 */
> -		if (nocpu)
> +		if (tasks_nocpu_error(parent, cs, xcpus))
>   			return PERR_NOCPUS;
>   
>   		/*
Reviewed-by:  Waiman Long <longman@redhat.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH cgroup/for-next 1/2] cpuset: fix failure to enable isolated partition when containing isolcpus
  2025-09-18 18:02   ` Waiman Long
@ 2025-09-19  0:58     ` Chen Ridong
  0 siblings, 0 replies; 6+ messages in thread
From: Chen Ridong @ 2025-09-19  0:58 UTC (permalink / raw)
  To: Waiman Long, tj, hannes, mkoutny
  Cc: cgroups, linux-kernel, lujialin4, chenridong



On 2025/9/19 2:02, Waiman Long wrote:
> On 9/18/25 8:25 AM, Chen Ridong wrote:
>> From: Chen Ridong <chenridong@huawei.com>
>>
>> The 'isolcpus' parameter specified at boot time can be assigned to an
>> isolated partition. While it is valid put the 'isolcpus' in an isolated
>> partition, attempting to change a member cpuset to an isolated partition
>> will fail if the cpuset contains any 'isolcpus'.
>>
>> For example, the system boots with 'isolcpus=9', and the following
>> configuration works correctly:
>>
>>    # cd /sys/fs/cgroup/
>>    # mkdir test
>>    # echo 1 > test/cpuset.cpus
>>    # echo isolated > test/cpuset.cpus.partition
>>    # cat test/cpuset.cpus.partition
>>    isolated
>>    # echo 9 > test/cpuset.cpus
>>    # cat test/cpuset.cpus.partition
>>    isolated
>>    # cat test/cpuset.cpus
>>    9
>>
>> However, the following steps to convert a member cpuset to an isolated
>> partition will fail:
>>
>>    # cd /sys/fs/cgroup/
>>    # mkdir test
>>    # echo 9 > test/cpuset.cpus
>>    # echo isolated > test/cpuset.cpus.partition
>>    # cat test/cpuset.cpus.partition
>>    isolated invalid (partition config conflicts with housekeeping setup)
>>
>> The issue occurs because the new partition state (new_prs) is used for
>> validation against housekeeping constraints before it has been properly
>> updated. To resolve this, move the assignment of new_prs before the
>> housekeeping validation check when enabling a root partition.
>>
>> Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> 
> Thanks for finding the bug. However, I think the commit to be fixed should be 4a74e418881f
> ("cgroup/cpuset: Check partition conflict with housekeeping setup"), not the one you listed above.
> 

Thank you for the correction, Longman, you are right. I'll update the commit ID with the correct one

-- 
Best regards,
Ridong


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-19  0:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 12:25 [PATCH cgroup/for-next 0/2] cpuset: fix failure to enable isolated partition when containing isolcpus Chen Ridong
2025-09-18 12:25 ` [PATCH cgroup/for-next 1/2] " Chen Ridong
2025-09-18 18:02   ` Waiman Long
2025-09-19  0:58     ` Chen Ridong
2025-09-18 12:25 ` [PATCH cgroup/for-next 2/2] cpuset: Use new excpus for nocpu error check when enabling root partition Chen Ridong
2025-09-18 18:10   ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®