Re: [RFC PATCH 0/5] cgroup/cpuset: A new "isolcpus" paritition

From: Waiman Long
Date: Mon Jun 05 2023 - 22:48:02 EST


On 6/5/23 16:27, Tejun Heo wrote:
Hello,

On Mon, Jun 05, 2023 at 04:00:39PM -0400, Waiman Long wrote:
...
file seems hacky to me. e.g. How would it interact with namespacing? Are
there reasons why this can't be properly hierarchical other than the amount
of work needed? For example:

cpuset.cpus.exclusive is a per-cgroup file and represents the mask of CPUs
that the cgroup holds exclusively. The mask is always a subset of
cpuset.cpus. The parent loses access to a CPU when the CPU is given to a
child by setting the CPU in the child's cpus.exclusive and the CPU can't
be given to more than one child. IOW, exclusive CPUs are available only to
the leaf cgroups that have them set in their .exclusive file.

When a cgroup is turned into a partition, its cpuset.cpus and
cpuset.cpus.exclusive should be the same. For backward compatibility, if
the cgroup's parent is already a partition, cpuset will automatically
attempt to add all cpus in cpuset.cpus into cpuset.cpus.exclusive.

I could well be missing something important but I'd really like to see
something like the above where the reservation feature blends in with the
rest of cpuset.
It can certainly be made hierarchical as you suggest. It does increase
complexity from both user and kernel point of view.

From the user point of view, there is one more knob to manage hierarchically
which is not used that often.
From user pov, this only affects them when they want to create partitions
down the tree, right?

From the kernel point of view, we may need to have one more cpumask per
cpuset as the current subparts_cpus is used to track automatic reservation.
We need another cpumask to contain extra exclusive CPUs not allocated
through automatic reservation. The fact that you mention this new control
file as a list of exclusively owned CPUs for this cgroup. Creating a
partition is in fact allocating exclusive CPUs to a cgroup. So it kind of
overlaps with the cpuset.cpus.partititon file. Can we fail a write to
Yes, it substitutes and expands on cpuset.cpus.partition behavior.

cpuset.cpus.exclusive if those exclusive CPUs cannot be granted or will this
exclusive list is only valid if a valid partition can be formed. So we need
to properly manage the dependency between these 2 control files.
So, I think cpus.exclusive can become the sole mechanism to arbitrate
exclusive owenership of CPUs and .partition can depend on .exclusive.

Alternatively, I have no problem exposing cpuset.cpus.exclusive as a
read-only file. It is a bit problematic if we need to make it writable.
I don't follow. How would remote partitions work then?

I had a different idea on the semantics of the cpuset.cpus.exclusive at the beginning. My original thinking is that it was the actual exclusive CPUs that are allocated to the cgroup. Now if we treat this as a hint of what exclusive CPUs should be used and it becomes valid only if the cgroup can become a valid partition. I can see it as a value that can be hierarchically set throughout the whole cpuset hierarchy.

So a transition to a valid partition is possible iff

1) cpuset.cpus.exclusive is a subset of cpuset.cpus and is a subset of cpuset.cpus.exclusive of all its ancestors.
2) If its parent is not a partition root, none of the CPUs in cpuset.cpus.exclusive are currently allocated to other partitions. This the same remote partition concept in my v2 patch. If its parent is a partition root, part of its exclusive CPUs will be distributed to this child partition like the current behavior of cpuset partition.

I can rework my patch to adopt this model if it is what you have in mind.

Thanks,
Longman