尝试设置cpu限制时遇到的cgroups v2问题

时间:2019-07-01 12:20:29

标签: linux-kernel cgroups cgroupsv2

Env:x86_64 Fedora 29上的自定义5.0.0 Linux内核

当尝试使用cgroups v2设置CPU限制时,我通过传递有效地禁用了cgroups v1

cgroup_no_v1=all 

作为内核cmdline选项。似乎很好,现在/sys/fs/cgroup/unified/cgroup.controllers下显示了各种控制器(cpu,io,内存等)。

但是,这样做:

# mkdir /sys/fs/cgroup/unified/test1
# echo "+cpu " > /sys/fs/cgroup/unified/test1/cgroup.subtree_control
bash: echo: write error: No such file or directory
# 

我理解这是预料之中的,正如手册页cgroups(7)所述:

    As at Linux 4.15, the cgroups v2 cpu controller does not support 
control of realtime processes, and the controller can be enabled in the 
root cgroup only if all realtime threads are in the root cgroup. (If there 
are realtime processes in nonroot cgroups, then a write(2) of the string 
"+cpu" to the cgroup.subtree_control file fails with the error EINVAL. 
However, on some systems, systemd(1) places certain realtime processes in 
nonroot cgroups in the v2 hierarchy. On such systems, these processes must 
first be moved to the root cgroup before the cpu controller can be 
enabled.

我的问题是:“将实时过程移动到根cgroup”到底是如何进行的?命令是什么?而且,如何识别哪些过程?那些已调度了SCHED_FIFO或SCHED_RR策略的服务器?使用实用程序包装程序会更简单吗? (libcgroup,cgmanager等)-它们在cgroups2中玩得很好吗? TIA!

0 个答案:

没有答案