Re: [PATCH v13 22/36] cgroup/cpuset: Refuse to take a deadline task out of its root domain
From: Mathieu Desnoyers
Date: Wed Dec 02 2026 - 09:54:48 EST
> Could dl_tasks_hold_bw() be checked on entry to dl_tasks_keep_without()
> and dl_tasks_keep_root_domain() instead of only inside
> dl_tasks_keep_cpus()? Because cpuset_mutex prevents any task from
> acquiring deadline bandwidth during the check, testing it only at the leaf
> causes every cpuset mask and partition update to walk all descendant
> cpusets and recompute effective_cpus_below() even when no task in the
> system holds deadline bandwidth.
It could, but the gain is small. dl_tasks_keep_cpus() already calls
dl_tasks_hold_bw() first. So with no deadline bandwidth held, the walk
of the tasks does not run. Only the walk of the cpusets stays. It runs
only when the cpusets change: on a write to a cpuset, or when a CPU
hotplug makes a partition valid again. update_cpumasks_hier() walks the
same cpusets on a write. The v12 review asked the same. v14 will leave
it as it is.
> When cpumask_equal(cp->effective_cpus, new_cpus) is true here, in the
> second loop below, and in dl_tasks_keep_root_domain(), should the loop
> advance pos_css = css_rightmost_descendant(pos_css) before continuing?
> Since valid child partitions are already skipped and non-partition
> descendants derive their effective_cpus only from their parent's
> effective_cpus and their own unchanged cpus_allowed, no descendant in cp's
> subtree can change effective_cpus, yet a plain continue walks every
> descendant in unaffected subtrees and runs effective_cpus_below() on each
> of them.
The same answer as above. The extra cost is a walk of the cpusets, and
only when the cpusets change. v14 will leave it as it is.
> When an update to a valid PRS_ISOLATED partition invalidates it, can
> returning all of cs->effective_xcpus to a non-isolated parent move a
> deadline task out of the default root domain without being caught by
> dl_tasks_keep_given_back()?
Yes. In v14, such a write will fail with EBUSY if a deadline task in
the partition would then change root domain. To know whether the write
makes the partition invalid, the check will repeat the tests of
partition_cpus_change(). A new case, partition_invalidate_refused, will
test it.
> Can shrinking a partition still move a deadline task in the parent's
> hierarchy out of its root domain in cases that dl_tasks_keep_given_back()
> skips?
Yes. In v14, a write to cpuset.cpus or cpuset.cpus.exclusive will fail
with EBUSY if a deadline task would then leave its root domain. The
check will cover these writes:
- A write that only gives CPUs back. It will check the tasks of the
parent (paths 1 and 2).
- A write that takes away all the CPUs of a partition root below. It
will check the tasks of that partition (path 3).
A write that only shrinks a partition root below is not checked. The
tasks of that partition keep the CPUs left to it. New cases will test
the refusals: partition_shrink_moves_refused,
partition_shrink_isolated_moves_refused and
partition_child_invalidate_refused.
Thanks,
Mathieu