* [PATCH -next 1/3] cpuset: remove redundant special case for null input in node mask update
2025-09-22 13:02 [PATCH -next 0/3] cpuset: code cleanup and redundancy removal Chen Ridong
@ 2025-09-22 13:02 ` Chen Ridong
2025-09-22 21:36 ` Waiman Long
2025-09-22 13:02 ` [PATCH -next 2/3] cpuset: remove impossible warning in update_parent_effective_cpumask Chen Ridong
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Chen Ridong @ 2025-09-22 13:02 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
From: Chen Ridong <chenridong@huawei.com>
The nodelist_parse function already handles empty nodemask input
appropriately, making it unnecessary to handle this case separately
during the node mask update process.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
kernel/cgroup/cpuset.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 535174ed7126..20dface3c3e0 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2847,22 +2847,16 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
/*
* An empty mems_allowed is ok iff there are no tasks in the cpuset.
- * Since nodelist_parse() fails on an empty mask, we special case
- * that parsing. The validate_change() call ensures that cpusets
- * with tasks have memory.
+ * The validate_change() call ensures that cpusets with tasks have memory.
*/
- if (!*buf) {
- nodes_clear(trialcs->mems_allowed);
- } else {
- retval = nodelist_parse(buf, trialcs->mems_allowed);
- if (retval < 0)
- goto done;
+ retval = nodelist_parse(buf, trialcs->mems_allowed);
+ if (retval < 0)
+ goto done;
- if (!nodes_subset(trialcs->mems_allowed,
- top_cpuset.mems_allowed)) {
- retval = -EINVAL;
- goto done;
- }
+ if (!nodes_subset(trialcs->mems_allowed,
+ top_cpuset.mems_allowed)) {
+ retval = -EINVAL;
+ goto done;
}
if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed)) {
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH -next 1/3] cpuset: remove redundant special case for null input in node mask update
2025-09-22 13:02 ` [PATCH -next 1/3] cpuset: remove redundant special case for null input in node mask update Chen Ridong
@ 2025-09-22 21:36 ` Waiman Long
0 siblings, 0 replies; 8+ messages in thread
From: Waiman Long @ 2025-09-22 21:36 UTC (permalink / raw)
To: Chen Ridong, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 9/22/25 9:02 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> The nodelist_parse function already handles empty nodemask input
> appropriately, making it unnecessary to handle this case separately
> during the node mask update process.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 22 ++++++++--------------
> 1 file changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 535174ed7126..20dface3c3e0 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2847,22 +2847,16 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
>
> /*
> * An empty mems_allowed is ok iff there are no tasks in the cpuset.
> - * Since nodelist_parse() fails on an empty mask, we special case
> - * that parsing. The validate_change() call ensures that cpusets
> - * with tasks have memory.
> + * The validate_change() call ensures that cpusets with tasks have memory.
> */
> - if (!*buf) {
> - nodes_clear(trialcs->mems_allowed);
> - } else {
> - retval = nodelist_parse(buf, trialcs->mems_allowed);
> - if (retval < 0)
> - goto done;
> + retval = nodelist_parse(buf, trialcs->mems_allowed);
> + if (retval < 0)
> + goto done;
>
> - if (!nodes_subset(trialcs->mems_allowed,
> - top_cpuset.mems_allowed)) {
> - retval = -EINVAL;
> - goto done;
> - }
> + if (!nodes_subset(trialcs->mems_allowed,
> + top_cpuset.mems_allowed)) {
> + retval = -EINVAL;
> + goto done;
> }
>
> if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed)) {
Right, the *buf check is no longer need with the current version fof
nodelist_parse().
Reveiwed-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH -next 2/3] cpuset: remove impossible warning in update_parent_effective_cpumask
2025-09-22 13:02 [PATCH -next 0/3] cpuset: code cleanup and redundancy removal Chen Ridong
2025-09-22 13:02 ` [PATCH -next 1/3] cpuset: remove redundant special case for null input in node mask update Chen Ridong
@ 2025-09-22 13:02 ` Chen Ridong
2025-09-22 21:37 ` Waiman Long
2025-09-22 13:02 ` [PATCH -next 3/3] cpuset: remove is_prs_invalid helper Chen Ridong
2025-09-22 23:10 ` [PATCH 0/3] cpuset: code cleanup and redundancy removal Tejun Heo
3 siblings, 1 reply; 8+ messages in thread
From: Chen Ridong @ 2025-09-22 13:02 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
From: Chen Ridong <chenridong@huawei.com>
If the parent is not a valid partition, an error will be returned before
any partition update command is processed. This means the
WARN_ON_ONCE(!is_partition_valid(parent)) can never be triggered, so
it is safe to remove.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
kernel/cgroup/cpuset.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 20dface3c3e0..196645b38b24 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1923,7 +1923,6 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
* A partition error happens when parent has tasks and all
* its effective CPUs will have to be distributed out.
*/
- WARN_ON_ONCE(!is_partition_valid(parent));
if (nocpu) {
part_error = PERR_NOCPUS;
if (is_partition_valid(cs))
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH -next 2/3] cpuset: remove impossible warning in update_parent_effective_cpumask
2025-09-22 13:02 ` [PATCH -next 2/3] cpuset: remove impossible warning in update_parent_effective_cpumask Chen Ridong
@ 2025-09-22 21:37 ` Waiman Long
0 siblings, 0 replies; 8+ messages in thread
From: Waiman Long @ 2025-09-22 21:37 UTC (permalink / raw)
To: Chen Ridong, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 9/22/25 9:02 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> If the parent is not a valid partition, an error will be returned before
> any partition update command is processed. This means the
> WARN_ON_ONCE(!is_partition_valid(parent)) can never be triggered, so
> it is safe to remove.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 20dface3c3e0..196645b38b24 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1923,7 +1923,6 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
> * A partition error happens when parent has tasks and all
> * its effective CPUs will have to be distributed out.
> */
> - WARN_ON_ONCE(!is_partition_valid(parent));
> if (nocpu) {
> part_error = PERR_NOCPUS;
> if (is_partition_valid(cs))
Acked-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH -next 3/3] cpuset: remove is_prs_invalid helper
2025-09-22 13:02 [PATCH -next 0/3] cpuset: code cleanup and redundancy removal Chen Ridong
2025-09-22 13:02 ` [PATCH -next 1/3] cpuset: remove redundant special case for null input in node mask update Chen Ridong
2025-09-22 13:02 ` [PATCH -next 2/3] cpuset: remove impossible warning in update_parent_effective_cpumask Chen Ridong
@ 2025-09-22 13:02 ` Chen Ridong
2025-09-22 21:37 ` Waiman Long
2025-09-22 23:10 ` [PATCH 0/3] cpuset: code cleanup and redundancy removal Tejun Heo
3 siblings, 1 reply; 8+ messages in thread
From: Chen Ridong @ 2025-09-22 13:02 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
From: Chen Ridong <chenridong@huawei.com>
The is_prs_invalid helper function is redundant as it serves a similar
purpose to is_partition_invalid. It can be fully replaced by the existing
is_partition_invalid function, so this patch removes the is_prs_invalid
helper.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
kernel/cgroup/cpuset.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 196645b38b24..52468d2c178a 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -132,11 +132,6 @@ static bool force_sd_rebuild;
#define PRS_INVALID_ROOT -1
#define PRS_INVALID_ISOLATED -2
-static inline bool is_prs_invalid(int prs_state)
-{
- return prs_state < 0;
-}
-
/*
* Temporary cpumasks for working with partitions that are passed among
* functions to avoid memory allocation in inner functions.
@@ -1767,7 +1762,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
old_prs = new_prs = cs->partition_root_state;
if (cmd == partcmd_invalidate) {
- if (is_prs_invalid(old_prs))
+ if (is_partition_invalid(cs))
return 0;
/*
@@ -1874,7 +1869,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
* For invalid partition:
* delmask = newmask & parent->effective_xcpus
*/
- if (is_prs_invalid(old_prs)) {
+ if (is_partition_invalid(cs)) {
adding = false;
deleting = cpumask_and(tmp->delmask,
newmask, parent->effective_xcpus);
@@ -2964,7 +2959,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
/*
* Treat a previously invalid partition root as if it is a "member".
*/
- if (new_prs && is_prs_invalid(old_prs))
+ if (new_prs && is_partition_invalid(cs))
old_prs = PRS_MEMBER;
if (alloc_tmpmasks(&tmpmask))
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH -next 3/3] cpuset: remove is_prs_invalid helper
2025-09-22 13:02 ` [PATCH -next 3/3] cpuset: remove is_prs_invalid helper Chen Ridong
@ 2025-09-22 21:37 ` Waiman Long
0 siblings, 0 replies; 8+ messages in thread
From: Waiman Long @ 2025-09-22 21:37 UTC (permalink / raw)
To: Chen Ridong, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 9/22/25 9:02 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> The is_prs_invalid helper function is redundant as it serves a similar
> purpose to is_partition_invalid. It can be fully replaced by the existing
> is_partition_invalid function, so this patch removes the is_prs_invalid
> helper.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 196645b38b24..52468d2c178a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -132,11 +132,6 @@ static bool force_sd_rebuild;
> #define PRS_INVALID_ROOT -1
> #define PRS_INVALID_ISOLATED -2
>
> -static inline bool is_prs_invalid(int prs_state)
> -{
> - return prs_state < 0;
> -}
> -
> /*
> * Temporary cpumasks for working with partitions that are passed among
> * functions to avoid memory allocation in inner functions.
> @@ -1767,7 +1762,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
> old_prs = new_prs = cs->partition_root_state;
>
> if (cmd == partcmd_invalidate) {
> - if (is_prs_invalid(old_prs))
> + if (is_partition_invalid(cs))
> return 0;
>
> /*
> @@ -1874,7 +1869,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
> * For invalid partition:
> * delmask = newmask & parent->effective_xcpus
> */
> - if (is_prs_invalid(old_prs)) {
> + if (is_partition_invalid(cs)) {
> adding = false;
> deleting = cpumask_and(tmp->delmask,
> newmask, parent->effective_xcpus);
> @@ -2964,7 +2959,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
> /*
> * Treat a previously invalid partition root as if it is a "member".
> */
> - if (new_prs && is_prs_invalid(old_prs))
> + if (new_prs && is_partition_invalid(cs))
> old_prs = PRS_MEMBER;
>
> if (alloc_tmpmasks(&tmpmask))
Acked-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/3] cpuset: code cleanup and redundancy removal
2025-09-22 13:02 [PATCH -next 0/3] cpuset: code cleanup and redundancy removal Chen Ridong
` (2 preceding siblings ...)
2025-09-22 13:02 ` [PATCH -next 3/3] cpuset: remove is_prs_invalid helper Chen Ridong
@ 2025-09-22 23:10 ` Tejun Heo
3 siblings, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2025-09-22 23:10 UTC (permalink / raw)
To: Chen Ridong, longman, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4
> Chen Ridong (3):
> cpuset: remove redundant special case for null input in node mask
> update
> cpuset: remove impossible warning in update_parent_effective_cpumask
> cpuset: remove is_prs_invalid helper
Applied 1-3 to cgroup/for-6.18.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 8+ messages in thread