Tweak cgroup logic
This commit is contained in:
Родитель
7066e7ad51
Коммит
eba220f688
|
@ -88,6 +88,10 @@ void CGroupCPU::SetShares(uint64_t val) {
|
|||
AppendUint64(_dir + CGROUP_CPU_SHARES_FILE, val);
|
||||
}
|
||||
|
||||
bool CGroupCPU::HasCFSQuotaUS() {
|
||||
return PathExists(_dir + CGROUP_CPU_PERIOD_US_FILE);
|
||||
}
|
||||
|
||||
uint64_t CGroupCPU::GetCFSPeriodUS() {
|
||||
return ReadUint64(_dir + CGROUP_CPU_PERIOD_US_FILE);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
uint64_t GetCFSPeriodUS();
|
||||
void SetCFSPeriodUS(uint64_t val);
|
||||
|
||||
bool HasCFSQuotaUS();
|
||||
uint64_t GetCFSQuotaUS();
|
||||
void SetCFSQuotaUS(uint64_t val);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ std::shared_ptr<CGroupCPU> CPULimits::CGFromConfig(const Config& config, const s
|
|||
|
||||
auto cg = CGroups::OpenCPU(cg_name);
|
||||
|
||||
if (hard_limit < MAX_PCT) {
|
||||
if (hard_limit < MAX_PCT && cg->HasCFSQuotaUS()) {
|
||||
uint64_t period = cg->GetCFSPeriodUS();
|
||||
uint64_t quota = static_cast<uint64_t>(static_cast<double>(period)*(hard_limit/100));
|
||||
cg->SetCFSQuotaUS(quota);
|
||||
|
|
Загрузка…
Ссылка в новой задаче