[PATCH -next RFC -v2 10/11] cpuset: use parse_cpulist for setting cpus.exclusive

Chen Ridong posted 11 patches 3 weeks, 2 days ago
There is a newer version of this series
[PATCH -next RFC -v2 10/11] cpuset: use parse_cpulist for setting cpus.exclusive
Posted by Chen Ridong 3 weeks, 2 days ago
From: Chen Ridong <chenridong@huawei.com>

Previous patches made parse_cpulist handle empty cpu mask input.
Now use this helper for exclusive cpus setting. Also, compute_trialcs_xcpus
can be called with empty cpus and handles it correctly.

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

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index de61520f1e44..785a2740b0ea 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2567,27 +2567,20 @@ static int update_exclusive_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 	bool force = false;
 	int old_prs = cs->partition_root_state;
 
-	if (!*buf) {
-		cpumask_clear(trialcs->exclusive_cpus);
-		cpumask_clear(trialcs->effective_xcpus);
-	} else {
-		retval = cpulist_parse(buf, trialcs->exclusive_cpus);
-		if (retval < 0)
-			return retval;
-	}
+	retval = parse_cpuset_cpulist(buf, trialcs->exclusive_cpus);
+	if (retval < 0)
+		return retval;
 
 	/* Nothing to do if the CPUs didn't change */
 	if (cpumask_equal(cs->exclusive_cpus, trialcs->exclusive_cpus))
 		return 0;
 
-	if (*buf) {
-		/*
-		 * Reject the change if there is exclusive CPUs conflict with
-		 * the siblings.
-		 */
-		if (compute_trialcs_excpus(trialcs, cs))
-			return -EINVAL;
-	}
+	/*
+	 * Reject the change if there is exclusive CPUs conflict with
+	 * the siblings.
+	 */
+	if (compute_trialcs_excpus(trialcs, cs))
+		return -EINVAL;
 
 	/*
 	 * Check all the descendants in update_cpumasks_hier() if
-- 
2.34.1
Re: [PATCH -next RFC -v2 10/11] cpuset: use parse_cpulist for setting cpus.exclusive
Posted by Waiman Long 2 weeks, 3 days ago
On 9/8/25 11:32 PM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> Previous patches made parse_cpulist handle empty cpu mask input.
> Now use this helper for exclusive cpus setting. Also, compute_trialcs_xcpus
> can be called with empty cpus and handles it correctly.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>   kernel/cgroup/cpuset.c | 25 +++++++++----------------
>   1 file changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index de61520f1e44..785a2740b0ea 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2567,27 +2567,20 @@ static int update_exclusive_cpumask(struct cpuset *cs, struct cpuset *trialcs,
>   	bool force = false;
>   	int old_prs = cs->partition_root_state;
>   
> -	if (!*buf) {
> -		cpumask_clear(trialcs->exclusive_cpus);
> -		cpumask_clear(trialcs->effective_xcpus);
> -	} else {
> -		retval = cpulist_parse(buf, trialcs->exclusive_cpus);
> -		if (retval < 0)
> -			return retval;
> -	}
> +	retval = parse_cpuset_cpulist(buf, trialcs->exclusive_cpus);
> +	if (retval < 0)
> +		return retval;
>   
>   	/* Nothing to do if the CPUs didn't change */
>   	if (cpumask_equal(cs->exclusive_cpus, trialcs->exclusive_cpus))
>   		return 0;
>   
> -	if (*buf) {
> -		/*
> -		 * Reject the change if there is exclusive CPUs conflict with
> -		 * the siblings.
> -		 */
> -		if (compute_trialcs_excpus(trialcs, cs))
> -			return -EINVAL;
> -	}
> +	/*
> +	 * Reject the change if there is exclusive CPUs conflict with
> +	 * the siblings.
> +	 */
> +	if (compute_trialcs_excpus(trialcs, cs))
> +		return -EINVAL;
>   
>   	/*
>   	 * Check all the descendants in update_cpumasks_hier() if
Reviewed-by: Waiman Long <longman@redhat.com>