10

CPU 使用率を制限するために cgroups を使用しようとしています。このガイドを使用しています 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

ユーザーの 100% の CPU 使用率がグループ wheel と test1 に属していることがわかります

service cgconfig status でサービスを確認し、稼働しています

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)

誰が私が間違っているのか教えてもらえますか? どうもありがとう

4

1 に答える 1

21

cpu cgroup は作業保存型です。競合がなければ、タスクは CPU の使用を停止されません。タスクが使用できる CPU の量に厳しい制限を設けたい場合は、 と を設定cpu.cfs_quota_usしてみてくださいcpu.cfs_period_us

こちらのドキュメントをご覧ください。

于 2015-03-02T23:27:58.550 に答える