Question about SCHED_DEADLINE and cgroupv2/cpuset interaction
Hi there,
I'm currently pondering on an odd behaviour that I'm seeing when using SCHED_DEADLINE in combination with cgroupv2/cpuset.
A bit about my setup. The hardware is a Raspi CM4 module on some custom mainboard.
Kernel is rpi-6.12.y from here: https://github.com/raspberrypi/linux
Although I don't think that this matters much. There's barely any difference between vanilla and the Raspi fork when it comes to the scheduler. I've also tried this whole thing out with rpi-6.18.y, but I'm getting the same behavior there. Kernel config is nothing special, except for the fact that CONFIG_PREEMPT_RT=y.
root@cm4-fat:~# uname -a Linux cm4-fat 6.12.81+ #1 SMP PREEMPT_RT Tue Apr 14 13:06:22 CEST 2026 aarch64 GNU/Linux
Anyway, for our application (in the sense of "how do we use the CM4 module") we have partitioned the CPU resources into two groups. CPUs 0 and 1 are for all the "menial" tasks, and CPUs 2 and 3 are for everything real-time. We use systemd slices for the partitioning, i.e. systemd does the cpuset controller setup for us.
Basically it's this setup: https://documentation.suse.com/sle-rt/15-SP7/html/SLE-RT-all/cha-shielding-with-systemd.html
We have assigned CPUs 0 and 1 to the machine and the user slice.
Also we have some kernel cmdline arguments that might be relevant for this: irqaffinity=0-1 isolcpus=2-3 nohz_full=2-3
For the RT work we have these slices.
root@cm4-fat:/etc/systemd/system# cat workload.slice [Slice] AllowedCPUs=2-3
root@cm4-fat:/etc/systemd/system# cat workload-core2.slice [Slice] AllowedCPUs=2
Note that core2 is a child of workload, i.e. on the cgroup level it looks like this.
root@cm4-fat:~# find /sys/fs/cgroup/ -name workload\*.slice /sys/fs/cgroup/workload.slice /sys/fs/cgroup/workload.slice/workload-core2.slice
So what's exactly this problem I'm seeing? It's this here.
root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p676-i976.service; invocation ID: d59dc443f66f46a6ba2dfd125e04f830 Press ^] three times within 1s to disconnect TTY. chrt: failed to set pid 0's policy: Operation not permitted
What works however is this here.
root@cm4-fat:~# systemd-run --slice=workload.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p670-i970.service Press ^] three times within 1s to disconnect TTY. this works
I double checked the slice settings, and they apply.
root@cm4-fat:~# systemd-run --slice=workload.slice --pty bash -c 'grep Cpus_allowed_list /proc/$BASHPID/status' Running as unit: run-p727-i1027.service Press ^] three times within 1s to disconnect TTY. Cpus_allowed_list: 2-3
Once again for the core2 slice.
root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty bash -c 'grep Cpus_allowed_list /proc/$BASHPID/status' Running as unit: run-p732-i1032.service Press ^] three times within 1s to disconnect TTY. Cpus_allowed_list: 2
This really puzzled here. Why would this work for AllowedCPUs=2-3, but not for AllowedCPUs=2?
I then dove in the documentation and the code, trying to understand where the -EPERM was coming from. I finally decided to disable the bandwidth check that the kernel performs.
root@cm4-fat:~# echo -1 > /proc/sys/kernel/sched_rt_runtime_us root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p760-i1060.service Press ^] three times within 1s to disconnect TTY. this works
And voila, suddenly everything works. I fail to understand though why the bandwidth check fails here. I mean, 100000 / 200000, that's fifty percent, so the check should pass.
And apparantly the ratio itself doesn't seem to have any effect. I enabled the check again and reduced the runtime so that the ratio is just 5%. Still the same.
root@cm4-fat:~# echo 950000 > /proc/sys/kernel/sched_rt_runtime_us root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 1000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p838-i1138.service Press ^] three times within 1s to disconnect TTY. chrt: failed to set pid 0's policy: Operation not permitted
I looked around some more, made sure that CONFIG_RT_GROUP_SCHED=n, but the more I think about, the more I get the impression that I totally misunderstand how the bandwidth check works.
To be explicit, by bandwidth check I mean the line that is found in section 4.1. here: https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.rst
Would be nice if someone could shed some light on this. Thanks in advance!
With best wishes,
Tobias Jakobi
Hi Tobias,
giving my 2 cents here.
Quoted 10 lines · Tobias Jakobi
For the RT work we have these slices.
root@cm4-fat:/etc/systemd/system# cat workload.slice [Slice] AllowedCPUs=2-3root@cm4-fat:/etc/systemd/system# cat workload-core2.slice [Slice] AllowedCPUs=2
Applying the configuration above, I get both slices as member partitions (not root):
head /sys/fs/cgroup/workload.slice/{,*/}cpuset.cpus.partition ==> /sys/fs/cgroup/workload.slice/cpuset.cpus.partition <== member
==> /sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partition <== member
Running your example in either slice doesn't work in my case. That's because in the admission control we "Don't allow tasks with an affinity mask smaller than the entire root_domain to become SCHED_DEADLINE" [1].
In short that's to make the admission control able to give guarantees.
Setting the partition as root:
echo root > /sys/fs/cgroup/workload.slice/cpuset.cpus.partition
echo root > /sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partition
Fixes the issue in my case.
I don't really know how to specify that in systemd and I'm assuming your version/configuration of systemd was somehow setting workload- slice as root automatically, that's likely why it was working.
Could you try this on your side?
Cheers,
Gabriele
[1] -
https://elixir.bootlin.com/linux/v7.0.1/source/kernel/sched/syscalls.c#L627
Quoted 91 lines
Note that core2 is a child of workload, i.e. on the cgroup level it looks like this.
root@cm4-fat:~# find /sys/fs/cgroup/ -name workload\*.slice /sys/fs/cgroup/workload.slice /sys/fs/cgroup/workload.slice/workload-core2.sliceSo what's exactly this problem I'm seeing? It's this here.
root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p676-i976.service; invocation ID: d59dc443f66f46a6ba2dfd125e04f830 Press ^] three times within 1s to disconnect TTY. chrt: failed to set pid 0's policy: Operation not permittedWhat works however is this here.
root@cm4-fat:~# systemd-run --slice=workload.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p670-i970.service Press ^] three times within 1s to disconnect TTY. this worksI double checked the slice settings, and they apply.
root@cm4-fat:~# systemd-run --slice=workload.slice --pty bash -c 'grep Cpus_allowed_list /proc/$BASHPID/status' Running as unit: run-p727-i1027.service Press ^] three times within 1s to disconnect TTY. Cpus_allowed_list: 2-3Once again for the core2 slice.
root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty bash - c 'grep Cpus_allowed_list /proc/$BASHPID/status' Running as unit: run-p732-i1032.service Press ^] three times within 1s to disconnect TTY. Cpus_allowed_list: 2This really puzzled here. Why would this work for AllowedCPUs=2-3, but
not for AllowedCPUs=2?I then dove in the documentation and the code, trying to understand where the
-EPERMwas coming from. I finally decided to disable the bandwidth check that the kernel performs.root@cm4-fat:~# echo -1 > /proc/sys/kernel/sched_rt_runtime_us root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p760-i1060.service Press ^] three times within 1s to disconnect TTY. this worksAnd voila, suddenly everything works. I fail to understand though why the bandwidth check fails here. I mean, 100000 / 200000, that's fifty percent, so the check should pass.
And apparantly the ratio itself doesn't seem to have any effect. I enabled the check again and reduced the runtime so that the ratio is just 5%. Still the same.
root@cm4-fat:~# echo 950000 > /proc/sys/kernel/sched_rt_runtime_us root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 1000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p838-i1138.service Press ^] three times within 1s to disconnect TTY. chrt: failed to set pid 0's policy: Operation not permittedI looked around some more, made sure that
CONFIG_RT_GROUP_SCHED=n, but
the more I think about, the more I get the impression that I totally misunderstand how the bandwidth check works.To be explicit, by bandwidth check I mean the line that is found in section 4.1. here:
https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.rstWould be nice if someone could shed some light on this. Thanks in advance!
With best wishes,
Tobias Jakobi
Hello Gabriele,
thanks for your feedback!
Quoted 22 lines · Gabriele Monaco
Hi Tobias,
giving my 2 cents here.
Quoted 10 lines · Tobias Jakobi
For the RT work we have these slices.
root@cm4-fat:/etc/systemd/system# cat workload.slice [Slice] AllowedCPUs=2-3root@cm4-fat:/etc/systemd/system# cat workload-core2.slice [Slice] AllowedCPUs=2Applying the configuration above, I get both slices as member partitions (not root):
head
/sys/fs/cgroup/workload.slice/{,*/}cpuset.cpus.partition==>/sys/fs/cgroup/workload.slice/cpuset.cpus.partition<== member
Quoted 7 lines
==>
/sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partition<== memberRunning your example in either slice doesn't work in my case. That's because in the admission control we "Don't allow tasks with an affinity mask smaller than the entire
root_domainto becomeSCHED_DEADLINE" [1].
Actually I saw this comment during my investigation. But I disregarded it quickly, reasons see below.
Anyway, I saw this term "root_domain" being mentioned a few times in the documentation (https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.rst). But only there. It is not mentioned at all in the rest of the docs. Nor have I found a definition for it. Might as well ask this here, what exactly is this root_domain supposed to be? Yes, there is this comment for struct root_domain in sched/sched.h, but honestly, without heavy knowledge about the scheduler codebase this tells me almost nothing... :-(
Quoted 7 lines
In short that's to make the admission control able to give guarantees.
Setting the partition as root:
echo root >
/sys/fs/cgroup/workload.slice/cpuset.cpus.partition
echo root >/sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partition
Quoted 6 lines
Fixes the issue in my case.
I don't really know how to specify that in systemd and I'm assuming your version/configuration of systemd was somehow setting workload- slice as root automatically, that's likely why it was working.Could you try this on your side?
Sure, as I said above I disregarded the comment in syscalls.c after fiddling with this.
So, first of all, when doing nothing on top of what systemd does, then both cpuset.cpus.partition are member. What I did not mention in the initial mail was that I tried to change the partition type. Unsuccessfully however.
root@cm4-fat:/sys/fs/cgroup/workload.slice# echo root > cpuset.cpus.partition root@cm4-fat:/sys/fs/cgroup/workload.slice# echo root > workload-core2.slice/cpuset.cpus.partition root@cm4-fat:/sys/fs/cgroup/workload.slice# cat cpuset.cpus.partition root invalid (partition config conflicts with housekeeping setup) root@cm4-fat:/sys/fs/cgroup/workload.slice# cat workload-core2.slice/cpuset.cpus.partition root invalid (Invalid cpu list in cpuset.cpus.exclusive) root@cm4-fat:/sys/fs/cgroup/workload.slice# grep . cpuset.* cpuset.cpus:2-3 cpuset.cpus.effective:2-3 cpuset.cpus.partition:root invalid (partition config conflicts with housekeeping setup) cpuset.mems.effective:0 root@cm4-fat:/sys/fs/cgroup/workload.slice# cd workload-core2.slice/ root@cm4-fat:/sys/fs/cgroup/workload.slice/workload-core2.slice# grep . cpuset.* cpuset.cpus:2 cpuset.cpus.effective:2 cpuset.cpus.partition:root invalid (Invalid cpu list in cpuset.cpus.exclusive) cpuset.mems.effective:0
I then remembered reading something in the systemd documentation about cgroup delegation and that changing anything cgroup related right under systemd's nose was asking for trouble. I guess this is what "partition config conflicts with housekeeping setup" is supposed to tell me here?
After I wasn't getting anywhere here I focused on the bandwidth check. And since the whole thing worked after disabling the check, I disregarded the root_domain/partition idea.
But I guess the real cause is the root_domain then?
With best wishes,
Tobias
Quoted 98 lines
Cheers,
Gabriele[1] -
https://elixir.bootlin.com/linux/v7.0.1/source/kernel/sched/syscalls.c#L627Quoted 91 lines
Note that core2 is a child of workload, i.e. on the cgroup level it looks like this.
root@cm4-fat:~# find /sys/fs/cgroup/ -name workload\*.slice /sys/fs/cgroup/workload.slice /sys/fs/cgroup/workload.slice/workload-core2.sliceSo what's exactly this problem I'm seeing? It's this here.
root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p676-i976.service; invocation ID: d59dc443f66f46a6ba2dfd125e04f830 Press ^] three times within 1s to disconnect TTY. chrt: failed to set pid 0's policy: Operation not permittedWhat works however is this here.
root@cm4-fat:~# systemd-run --slice=workload.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p670-i970.service Press ^] three times within 1s to disconnect TTY. this worksI double checked the slice settings, and they apply.
root@cm4-fat:~# systemd-run --slice=workload.slice --pty bash -c 'grep Cpus_allowed_list /proc/$BASHPID/status' Running as unit: run-p727-i1027.service Press ^] three times within 1s to disconnect TTY. Cpus_allowed_list: 2-3Once again for the core2 slice.
root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty bash - c 'grep Cpus_allowed_list /proc/$BASHPID/status' Running as unit: run-p732-i1032.service Press ^] three times within 1s to disconnect TTY. Cpus_allowed_list: 2This really puzzled here. Why would this work for AllowedCPUs=2-3, but
not for AllowedCPUs=2?I then dove in the documentation and the code, trying to understand where the
-EPERMwas coming from. I finally decided to disable the bandwidth check that the kernel performs.root@cm4-fat:~# echo -1 > /proc/sys/kernel/sched_rt_runtime_us root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p760-i1060.service Press ^] three times within 1s to disconnect TTY. this worksAnd voila, suddenly everything works. I fail to understand though why the bandwidth check fails here. I mean, 100000 / 200000, that's fifty percent, so the check should pass.
And apparantly the ratio itself doesn't seem to have any effect. I enabled the check again and reduced the runtime so that the ratio is just 5%. Still the same.
root@cm4-fat:~# echo 950000 > /proc/sys/kernel/sched_rt_runtime_us root@cm4-fat:~# systemd-run --slice=workload-core2.slice --pty chrt --sched-runtime 1000 --sched-period 200000 --deadline 0 echo this works Running as unit: run-p838-i1138.service Press ^] three times within 1s to disconnect TTY. chrt: failed to set pid 0's policy: Operation not permittedI looked around some more, made sure that
CONFIG_RT_GROUP_SCHED=n, but
the more I think about, the more I get the impression that I totally misunderstand how the bandwidth check works.To be explicit, by bandwidth check I mean the line that is found in section 4.1. here:
https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.rstWould be nice if someone could shed some light on this. Thanks in advance!
With best wishes,
Tobias Jakobi
Hello Tobias,
Quoted 11 lines · Tobias Jakobi
Actually I saw this comment during my investigation. But I disregarded it quickly, reasons see below.
Anyway, I saw this term "
root_domain" being mentioned a few times in the documentation
(https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.rst).
But only there. It is not mentioned at all in the rest of the docs. Nor have I found a definition for it. Might as well ask this here, what exactly is thisroot_domainsupposed to be? Yes, there is this comment for structroot_domaininsched/sched.h, but honestly, without heavy knowledge about the scheduler codebase this tells me almost nothing... :-(
The reason why you need a root cpuset is the same why you cannot simply taskset:
if all your tasks can migrate freely you can use as admission control total utilisation < number of cpus (kinda, read more in the references if you're interested), but if some tasks have constraints on what CPUs they can migrate to, that formula is no longer sufficient.
The way this is solved is by splitting scheduling domain into independent chunks, and a root partition does exactly that: if you give CPU2 to your root partition, no other partition can use CPU2, so you can apply the formula above only on that partition (with a single CPU).
Without setting the partition as root, you're saying all tasks in the cpuset can only use CPU2, but CPU2 can be used by other cpusets as well, it's impossible to guarantee anything on your cpuset in this case because you'd need to consider also the others.
You should be able to find more about cpuset partitions in Documentation/admin- guide/cgroup-v2.rst
Quoted 38 lines
Quoted 8 lines
In short that's to make the admission control able to give guarantees.
Setting the partition as root:
echo root >
/sys/fs/cgroup/workload.slice/cpuset.cpus.partitionecho root >/sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partitionQuoted 6 lines
Fixes the issue in my case.
I don't really know how to specify that in systemd and I'm assuming your version/configuration of systemd was somehow setting workload- slice as root automatically, that's likely why it was working.Could you try this on your side?
Sure, as I said above I disregarded the comment in
syscalls.cafter fiddling with this.So, first of all, when doing nothing on top of what systemd does, then both cpuset.cpus.partition are member. What I did not mention in the initial mail was that I tried to change the partition type. Unsuccessfully however.
root@cm4-fat:/sys/fs/cgroup/workload.slice# echo root > cpuset.cpus.partition root@cm4-fat:/sys/fs/cgroup/workload.slice# echo root > workload-core2.slice/cpuset.cpus.partition root@cm4-fat:/sys/fs/cgroup/workload.slice# cat cpuset.cpus.partition root invalid (partition config conflicts with housekeeping setup) root@cm4-fat:/sys/fs/cgroup/workload.slice# cat workload-core2.slice/cpuset.cpus.partition root invalid (Invalid cpu list in cpuset.cpus.exclusive) root@cm4-fat:/sys/fs/cgroup/workload.slice# grep . cpuset.* cpuset.cpus:2-3 cpuset.cpus.effective:2-3 cpuset.cpus.partition:root invalid (partition config conflicts with housekeeping setup) cpuset.mems.effective:0
Quoted 8 lines
root@cm4-fat:/sys/fs/cgroup/workload.slice# cd workload-core2.slice/ root@cm4-fat:/sys/fs/cgroup/workload.slice/workload-core2.slice# grep . cpuset.* cpuset.cpus:2 cpuset.cpus.effective:2 cpuset.cpus.partition:root invalid (Invalid cpu list in cpuset.cpus.exclusive) cpuset.mems.effective:0
Here you got other issues though, by making a partition root, you are taking exclusivity on it's CPUs, so system tasks cannot use those CPUs any longer, pretty much like when you make them (domain) isolated.
The thing is that unlike isolated CPUs, root domains have load balancing among the exclusive CPUs, that fights with the fact 2-3 are also isolated!
Now you have 2 ways how to solve this: as far as I could test, an isolated partition counts as root, so you could keep your isolcpus and do:
echo isolated > /sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partition
OR you could ditch isolcpus entirely (nohz_full can stay) and use root for both, since the workload domains are exclusive, this shouldn't really make a difference.
Quoted 4 lines
I then remembered reading something in the systemd documentation about cgroup delegation and that changing anything cgroup related right under systemd's nose was asking for trouble. I guess this is what "partition config conflicts with housekeeping setup" is supposed to tell me here?
I don't think systemd is to blame here (it seems not to care about partition types at all). But since it doesn't seem to support those it may be a good idea to find alternatives (e.g. plain cgroup).
Quoted 3 lines
After I wasn't getting anywhere here I focused on the bandwidth check. And since the whole thing worked after disabling the check, I disregarded the root_domain/partition idea.
Of course also disabling the bandwidth check (like you did initially) works, but you don't really want that.
Quoted 4 lines
But I guess the real cause is the
root_domainthen?With best wishes,
Tobias
I hope I didn't make it more confusing than it actually is!
Gabriele
Hey Gabriele,
once again thanks for the help!
Quoted 25 lines · Gabriele Monaco
Hello Tobias,
Quoted 11 lines · Tobias Jakobi
Actually I saw this comment during my investigation. But I disregarded it quickly, reasons see below.
Anyway, I saw this term "
root_domain" being mentioned a few times in the documentation
(https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.rst).
But only there. It is not mentioned at all in the rest of the docs. Nor have I found a definition for it. Might as well ask this here, what exactly is thisroot_domainsupposed to be? Yes, there is this comment for structroot_domaininsched/sched.h, but honestly, without heavy knowledge about the scheduler codebase this tells me almost nothing... :-(The reason why you need a root cpuset is the same why you cannot simply taskset:
if all your tasks can migrate freely you can use as admission control total utilisation < number of cpus (kinda, read more in the references if you're interested), but if some tasks have constraints on what CPUs they can migrate to, that formula is no longer sufficient.The way this is solved is by splitting scheduling domain into independent chunks, and a root partition does exactly that: if you give CPU2 to your root partition, no other partition can use CPU2, so you can apply the formula above only on that partition (with a single CPU).
Quoted 7 lines
Without setting the partition as root, you're saying all tasks in the cpuset can only use CPU2, but CPU2 can be used by other cpusets as well, it's impossible to guarantee anything on your cpuset in this case because you'd need to consider also the others.
You should be able to find more about cpuset partitions in
Documentation/admin-guide/cgroup-v2.rst
Yeah, that makes things a lot clearer! You need a disjoint union of the CPUs, so that you can keep using the scheduling algorithms efficiently.
Quoted 52 lines
Quoted 38 lines
Quoted 9 lines
In short that's to make the admission control able to give guarantees.
Setting the partition as root:
echo root >
/sys/fs/cgroup/workload.slice/cpuset.cpus.partitionecho root >/sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partitionQuoted 6 lines
Fixes the issue in my case.
I don't really know how to specify that in systemd and I'm assuming your version/configuration of systemd was somehow setting workload- slice as root automatically, that's likely why it was working.Could you try this on your side?
Sure, as I said above I disregarded the comment in
syscalls.cafter fiddling with this.So, first of all, when doing nothing on top of what systemd does, then both cpuset.cpus.partition are member. What I did not mention in the initial mail was that I tried to change the partition type. Unsuccessfully however.
root@cm4-fat:/sys/fs/cgroup/workload.slice# echo root > cpuset.cpus.partition root@cm4-fat:/sys/fs/cgroup/workload.slice# echo root > workload-core2.slice/cpuset.cpus.partition root@cm4-fat:/sys/fs/cgroup/workload.slice# cat cpuset.cpus.partition root invalid (partition config conflicts with housekeeping setup) root@cm4-fat:/sys/fs/cgroup/workload.slice# cat workload-core2.slice/cpuset.cpus.partition root invalid (Invalid cpu list in cpuset.cpus.exclusive) root@cm4-fat:/sys/fs/cgroup/workload.slice# grep . cpuset.* cpuset.cpus:2-3 cpuset.cpus.effective:2-3 cpuset.cpus.partition:root invalid (partition config conflicts with housekeeping setup) cpuset.mems.effective:0Quoted 8 lines
root@cm4-fat:/sys/fs/cgroup/workload.slice# cd workload-core2.slice/ root@cm4-fat:/sys/fs/cgroup/workload.slice/workload-core2.slice# grep . cpuset.* cpuset.cpus:2 cpuset.cpus.effective:2 cpuset.cpus.partition:root invalid (Invalid cpu list in cpuset.cpus.exclusive) cpuset.mems.effective:0Here you got other issues though, by making a partition root, you are taking exclusivity on it's CPUs, so system tasks cannot use those CPUs any longer, pretty much like when you make them (domain) isolated.
The thing is that unlike isolated CPUs, root domains have load balancing among the exclusive CPUs, that fights with the fact 2-3 are also isolated!
Quoted 8 lines
Now you have 2 ways how to solve this: as far as I could test, an isolated partition counts as root, so you could keep your isolcpus and do:
echo isolated >
/sys/fs/cgroup/workload.slice/workload-core2.slice/cpuset.cpus.partitionOR you could ditch isolcpus entirely (
nohz_fullcan stay) and use root for both, since the workload domains are exclusive, this shouldn't really make a difference.
OK, so I've proceeded by ditching both isolcpus and nohz_full. Upon reading about the tradeoffs (overhead of kernel entry/exit) I decided that nohz_full is probably not really helping the team that writes our userspace application. An application that makes heavy use of socket-based IPC.
Anyway, with these two parameters removed I can setup the partition as root.
I have moved things around a bit, and this is how it currently looks like.
root@cm5-slim:/sys/fs/cgroup/workload.slice# grep . cpuset.* cpuset.cpus:2-3 cpuset.cpus.exclusive.effective:2-3 cpuset.cpus.partition:root cpuset.mems.effective:0-7 root@cm5-slim:/sys/fs/cgroup/workload.slice# cd workload-group0.slice root@cm5-slim:/sys/fs/cgroup/workload.slice/workload-group0.slice# grep . cpuset.* cpuset.cpus:2 cpuset.cpus.effective:2 cpuset.cpus.exclusive.effective:2 cpuset.cpus.partition:root cpuset.mems.effective:0-7 root@cm5-slim:/sys/fs/cgroup/workload.slice/workload-group0.slice# cd ../workload-group1.slice root@cm5-slim:/sys/fs/cgroup/workload.slice/workload-group1.slice# grep . cpuset.* cpuset.cpus:3 cpuset.cpus.effective:3 cpuset.cpus.exclusive.effective:3 cpuset.cpus.partition:root cpuset.mems.effective:0-7
sched_rt_runtime_us has its default value and I can spawn processes with SCHED_DEADLINE in both workload-group0.slice and workload-group1.slice. So far, so good!
Quoted 8 lines
Quoted 5 lines
I then remembered reading something in the systemd documentation about cgroup delegation and that changing anything cgroup related right under systemd's nose was asking for trouble. I guess this is what "partition config conflicts with housekeeping setup" is supposed to tell me here?
I don't think systemd is to blame here (it seems not to care about partition types at all). But since it doesn't seem to support those it may be a good idea to find alternatives (e.g. plain cgroup).
Hmm, I'm not sure if going for plain cgroup is feasible for us. The system I'm currently testing on is not the final thing. That's going to be some bigger AMD Epyc where each CCD becomes one of the group slices. With a lot of processes running inside the slices. The current architecture design intends to let systemd do the heavy lifting here.
I think I'm going to at least ask the systemd folks if I'm looking for trouble here. At the moment I'm using a small helper service unit that sets up the slice/cgroup.
root@cm5-slim:~# systemctl cat workload-compute0.service # /etc/systemd/system/workload-compute0.service [Unit] Description=Spawn compute workload on group 0 [email protected] [email protected]
[Service]
Slice=workload-group0.slice
ExecStart=/usr/bin/chrt --sched-runtime 80000 --sched-period 200000 --deadline 0 /usr/bin/dd if=/dev/urandom of=/dev/zero bs=1M
That is not exactly beautiful, but also not terribly ugly. Also all workload service units are auto-generated from a template anyway, so it's just a matter of adding something to the template.
Quoted 4 lines
Quoted 4 lines
After I wasn't getting anywhere here I focused on the bandwidth check. And since the whole thing worked after disabling the check, I disregarded the root_domain/partition idea.
Quoted 8 lines
Of course also disabling the bandwidth check (like you did initially) works, but you don't really want that.
Quoted 4 lines
But I guess the real cause is the
root_domainthen?With best wishes,
TobiasI hope I didn't make it more confusing than it actually is!
Not at all! I agree though that it's not easy to wrap you around all this the first time around. :-D
With best wishes,
Tobias
Quoted 3 lines
Gabriele
Quoted 5 lines · Tobias Jakobi
OK, so I've proceeded by ditching both isolcpus and
nohz_full. Upon reading about the tradeoffs (overhead of kernel entry/exit) I decided thatnohz_fullis probably not really helping the team that writes our userspace application. An application that makes heavy use of socket-based IPC.
Yeah that's better, nohz_full is basically asking the kernel to be out of your way. It's useful mostly when you have a single userspace task per CPU and you don't want interruptions.
I'd say unless you have a benchmark proving nohz_full behaves better with your workload, just live without it.
Quoted 27 lines
Anyway, with these two parameters removed I can setup the partition as root.
I have moved things around a bit, and this is how it currently looks like.
root@cm5-slim:/sys/fs/cgroup/workload.slice# grep . cpuset.* cpuset.cpus:2-3 cpuset.cpus.exclusive.effective:2-3 cpuset.cpus.partition:root cpuset.mems.effective:0-7 root@cm5-slim:/sys/fs/cgroup/workload.slice# cd workload-group0.slice root@cm5-slim:/sys/fs/cgroup/workload.slice/workload-group0.slice# grep . cpuset.* cpuset.cpus:2 cpuset.cpus.effective:2 cpuset.cpus.exclusive.effective:2 cpuset.cpus.partition:root cpuset.mems.effective:0-7 root@cm5-slim:/sys/fs/cgroup/workload.slice/workload-group0.slice# cd ../workload-group1.slice root@cm5-slim:/sys/fs/cgroup/workload.slice/workload-group1.slice# grep . cpuset.* cpuset.cpus:3 cpuset.cpus.effective:3 cpuset.cpus.exclusive.effective:3 cpuset.cpus.partition:root cpuset.mems.effective:0-7
Quoted 4 lines
sched_rt_runtime_ushas its default value and I can spawn processes withSCHED_DEADLINEin both workload-group0.slice and workload-group1.slice. So far, so good!
Great!
Quoted 16 lines
Quoted 9 lines
Quoted 5 lines
I then remembered reading something in the systemd documentation about cgroup delegation and that changing anything cgroup related right under systemd's nose was asking for trouble. I guess this is what "partition config conflicts with housekeeping setup" is supposed to tell me here?
I don't think systemd is to blame here (it seems not to care about partition types at all). But since it doesn't seem to support those it may be a good idea
to find alternatives (e.g. plain cgroup).Hmm, I'm not sure if going for plain cgroup is feasible for us. The system I'm currently testing on is not the final thing. That's going to be some bigger AMD Epyc where each CCD becomes one of the group slices. With a lot of processes running inside the slices. The current architecture design intends to let systemd do the heavy lifting here.
Quoted 3 lines
I think I'm going to at least ask the systemd folks if I'm looking for trouble here. At the moment I'm using a small helper service unit that sets up the slice/cgroup.
I had a look at the systemd code and I don't see any reason why doing
ExecStart=/bin/sh -c 'echo root > /sys/fs/cgroup/cpuset/<name>.slice/cpuset.partition'
would cause any trouble.
I opened a PR to systemd to add an official way to do it though [1], anyway do ask the systemd folks, they surely know better than I do ;)
[1] - https://github.com/systemd/systemd/pull/42013
Quoted 8 lines
root@cm5-slim:~# systemctl cat workload-compute0.service # /etc/systemd/system/workload-compute0.service [Unit] Description=Spawn compute workload on group 0 [email protected] [email protected]
Quoted 9 lines
[Service]
Slice=workload-group0.slice
ExecStart=/usr/bin/chrt --sched-runtime 80000 --sched-period 200000 --deadline 0/usr/bin/ddif=/dev/urandom of=/dev/zero bs=1MThat is not exactly beautiful, but also not terribly ugly. Also all workload service units are auto-generated from a template anyway, so it's just a matter of adding something to the template.
Yeah, that's quite a pity systemd doesn't support the deadline scheduler..
Quoted 13 lines
Quoted 13 lines
Quoted 5 lines
After I wasn't getting anywhere here I focused on the bandwidth check. And since the whole thing worked after disabling the check, I disregarded the root_domain/partition idea.
Of course also disabling the bandwidth check (like you did initially) works, but
you don't really want that.Quoted 4 lines
But I guess the real cause is the
root_domainthen?With best wishes,
Tobias
Quoted 7 lines
Quoted 1 line
I hope I didn't make it more confusing than it actually is!
Not at all! I agree though that it's not easy to wrap you around all this the first time around. :-D
With best wishes,
Tobias
Happy to help.
Cheers,
Gabriele