使用Cgroup限制CPU使用率

SteveGr2015:

我试图使用cgroups来限制CPU使用率。我正在使用本指南https://access.redhat.com/documentation/zh-CN/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

当我尝试跑步时,Althouth:

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)

谁能告诉我我在做什么错?非常感谢

罗希特·纳格(Rohit Jnagal):

cpu cgroup可以节省工作,即。如果没有竞争,则不会停止使用cpu的任务。如果您想严格限制任务可以使用的CPU数量,请尝试设置cpu.cfs_quota_uscpu.cfs_period_us

这里查看文档

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章