Re: [PATCH-next v2 1/2] cgroup/cpuset: Run SCHED_DEADLINE shrink test on valid partition root only
From: Guopeng Zhang
Date: Mon Sep 28 2026 - 05:33:51 EST
在 2026/9/28 05:53, Waiman Long 写道:
> Commit f82f80426f7a ("sched/deadline: Ensure that updates to exclusive
> cpusets don't break AC") adds a check in validate_change() to make
> sure that there is enough bandwidth for SCHED_DEADLINE tasks if we
> shrink a v1 exclusive cpuset that has CS_CPU_EXCLUSIVE flag set.
>
> With the introduction of cpuset partition in cgroup v2, we keep setting
> the CS_CPU_EXCLUSIVE flag for a partition root so that the SCHED_DEADLINE
> check will continue to work as intended. However it turns out that the
> current code isn't perfect and there are cases where a cpuset isn't
> a valid partition root, but the exclusive flag is still incorrectly
> set. This can leads to SCHED_DEADLINE check being incorrectly triggered
> when there are deadline tasks in the system. This can result in unexpected
> -EBUSY failure when making changes to cpuset control files. Fix that
> by checking for a valid partition root for v2 and is_cpu_exclusive()
> for v1. It is far easier and less cumbersome than to make sure that
> the exclusive flag is only set for valid partition roots.
>
> Even though commit a86ce68078b2 ("cgroup/cpuset: Extract out
> CS_CPU_EXCLUSIVE & CS_SCHED_LOAD_BALANCE handling") is marked as a
> commit to be fixed, the problem may exist before that.
>
> Fixes: a86ce68078b2 ("cgroup/cpuset: Extract out CS_CPU_EXCLUSIVE & CS_SCHED_LOAD_BALANCE handling")
> Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
> ---
> kernel/cgroup/cpuset.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 753aa65afcd7..104fe10c336d 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -771,8 +771,8 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
> * For v1, effective_cpus == cpus_allowed & user_xcpus() returns
> * cpus_allowed.
> *
> - * For v2, is_cpu_exclusive() & is_sched_load_balance() are true only
> - * for non-isolated partition root. At this point, the target
> + * For v2, is_partition_valid(cur) & is_sched_load_balance() are true
> + * only for non-isolated partition root. At this point, the target
> * effective_cpus isn't computed yet. user_xcpus() is the best
> * approximation.
> *
> @@ -781,7 +781,8 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial)
> * becomes an issue.
> */
> ret = -EBUSY;
> - if (is_cpu_exclusive(cur) && is_sched_load_balance(cur) &&
> + if ((is_partition_valid(cur) || (!cpuset_v2() && is_cpu_exclusive(cur))) &&
> + is_sched_load_balance(cur) &&
> !cpuset_cpumask_can_shrink(cur->effective_cpus, user_xcpus(trial)))
> goto out;
>
Reviewed-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
Thanks,
Guopeng