# Re: \[PATCH v8 0/6\] cgroup/cpuset: Add new cpuset partition type \& empty effecitve cpus

- From: Michal Koutný \<mkoutny@suse.com\>
- Date: 2021-11-10 18:16:09 
- List: linux-doc
- Page: https://ratatoskr.run/linux-doc/2021/11/1568573
- Thread: https://ratatoskr.run/cgroups/2021/10/1545921/t.md

```text
On Wed, Nov 10, 2021 at 03:21:54PM +0000, "Moessbauer, Felix" [ref] wrote:
> 2. Threads can be started on non-rt CPUs and then bound to a specific rt CPU.
> This binding can be specified before thread creation via pthread_create.
> By that, you can make sure that at no point in time a thread has a
> "forbidden" CPU in its affinities.

It should boil down to some clone$version(2) and sched_setaffinity(2)
calls, so strictly speaking even with pthread_create(3) the thread is
shortly running with the parent's affinity.

> With cgroup2, you cannot guarantee the second aspect, as thread
> creation and moving to a cgroup is not an atomic operation.

As suggested by others, CLONE_INTO_CGROUP (into cpuset cgroup) can
actually "hide" the migration into the clone3() call.

> At creation time, you cannot set the final affinity mask (as you
> create it in the non-rt group and there the CPU is not in the
> cpuset.cpus).
> Once you move the thread to the rt cgroup, it has a default mask and
> by that can be executed on other rt cores.

Good point. Perhaps you could work this around by having another level
of (non-root partition) cpuset cgroups for individual CPUs? (Maybe
there's more clever approach, this is just first to come into my mind.)

Michal
```
