Пример #1
0
TError TMemorySubsystem::SetDirtyLimit(TCgroup &cg, uint64_t limit) {
    if (!SupportDirtyLimit())
        return TError::Success();
    if (limit)
        return cg.SetUint64(DIRTY_LIMIT, limit);
    return cg.SetUint64(DIRTY_RATIO, 50);
}
Пример #2
0
 TError SetGuarantee(TCgroup &cg, uint64_t guarantee) const {
     if (!SupportGuarantee())
         return TError::Success();
     return cg.SetUint64(LOW_LIMIT, guarantee);
 }
Пример #3
0
 TError SetSoftLimit(TCgroup &cg, uint64_t limit) const {
     return cg.SetUint64(SOFT_LIMIT, limit);
 }
Пример #4
0
TError TCpuSubsystem::SetCpuPolicy(TCgroup &cg, const std::string &policy,
                                   double guarantee, double limit) {
    TError error;

    if (HasQuota) {
        int64_t quota = std::ceil(limit * BasePeriod);

        if (quota < 1000)
            quota = 1000;

        if (limit >= GetNumCores())
            quota = -1;

        error = cg.Set("cpu.cfs_quota_us", std::to_string(quota));
        if (error)
            return error;
    }

    if (HasReserve) {
        uint64_t reserve = std::floor(guarantee * BasePeriod);
        uint64_t shares = BaseShares, reserve_shares = BaseShares;

        if (policy == "rt") {
            shares *= 16;
            reserve_shares *= 256;
        } else if (policy == "normal") {
            reserve_shares *= 16;
        } else if (policy == "idle") {
            shares /= 16;
        }

        error = cg.SetUint64("cpu.shares", shares);
        if (error)
            return error;

        error = cg.SetUint64("cpu.cfs_reserve_shares", reserve_shares);
        if (error)
            return error;

        error = cg.SetUint64("cpu.cfs_reserve_us", reserve);
        if (error)
            return error;

    } else if (HasShares) {
        uint64_t shares = std::floor((guarantee + 1) * BaseShares);

        if (policy == "rt" && (!HasSmart || !config().container().enable_smart()))
            shares *= 16;
        else if (policy == "idle")
            shares /= 16;

        error = cg.SetUint64("cpu.shares", shares);
        if (error)
            return error;
    }

    if (HasSmart) {
        error = cg.SetUint64("cpu.smart", (policy == "rt" &&
                    config().container().enable_smart()) ? 1 : 0);
        if (error)
            return error;
    }

    return TError::Success();
}
Пример #5
0
TError TMemorySubsystem::SetIopsLimit(TCgroup &cg, uint64_t limit) {
    if (!SupportIoLimit())
        return TError::Success();
    return cg.SetUint64(FS_IOPS_LIMIT, limit);
}