我正在尝试使用cgroups来限制CPU的使用。我正在使用这个指南https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/sec-cpu_and_memory-use_case.html
我的/etc/cgconfig.conf文件如下
mount {
cpu = /mnt/cgroup/cpu,cpuacct;
cpuacct = /mnt/cgroup/cpu,cpuacct;
}
group wheel {
cpu {
cpu.shares="800";
}
cpuacct {
cpuacct.usage="0";
}
}
group test1 {
cpu {
cpu.shares="200";
}
cpuacct {
cpuacct.usage="0";
}
}我的cgrules.conf如下
@wheel cpu,cpuacct wheel
@test1 cpu,cpuacct test1尽管当我试着跑的时候:
dd if=/dev/zero of=/dev/null bs=1024k我看到用户的cpu使用率为100%,属于组wheel和test1
我已检查具有服务cgconfig状态的服务,并已启动
Loaded: loaded (/usr/lib/systemd/system/cgconfig.service; disabled)
Active: active (exited) since Mon 2015-03-02 17:29:19 EET; 7min ago
Process: 1240 ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -e (code=exited, status=3)
Process: 56536 ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664 (code=exited, status=0/SUCCESS)
Main PID: 56536 (code=exited, status=0/SUCCESS)谁能告诉我我做错了什么?非常感谢
发布于 2015-03-03 07:27:59
cpu cgroup是工作守恒,即。如果没有竞争,任务将不会停止使用cpu。如果您想对任务可以使用的cpu数量进行硬性限制,请尝试设置cpu.cfs_quota_us和cpu.cfs_period_us。
请查看文档here。
https://stackoverflow.com/questions/28814002
复制相似问题