Ejemplo n.º 1
0
// Cpu
void TCpuSubsystem::InitializeSubsystem() {
    TCgroup cg = RootCgroup();

    HasShares = cg.Has("cpu.shares");
    if (HasShares && cg.GetUint64("cpu.shares", BaseShares))
        BaseShares = 1024;

    HasQuota = cg.Has("cpu.cfs_quota_us") &&
               cg.Has("cpu.cfs_period_us");

    HasReserve = HasShares && HasQuota &&
                 cg.Has("cpu.cfs_reserve_us") &&
                 cg.Has("cpu.cfs_reserve_shares");

    if (HasQuota && cg.GetUint64("cpu.cfs_period_us", BasePeriod))
        BasePeriod = 100000;

    HasSmart = cg.Has("cpu.smart");

    L_SYS() << GetNumCores() << " cores" << std::endl;
    if (HasShares)
        L_SYS() << "base shares " << BaseShares << std::endl;
    if (HasQuota)
        L_SYS() << "quota period " << BasePeriod << std::endl;
    if (HasReserve)
        L_SYS() << "support reserves" << std::endl;
    if (HasSmart)
        L_SYS() << "support smart" << std::endl;
}
Ejemplo n.º 2
0
TError TMemorySubsystem::GetAnonUsage(TCgroup &cg, uint64_t &usage) const {
    if (cg.Has(ANON_USAGE))
        return cg.GetUint64(ANON_USAGE, usage);

    TUintMap stat;
    TError error = Statistics(cg, stat);
    if (!error)
        usage = stat["total_inactive_anon"] +
                stat["total_active_anon"] +
                stat["unevictable"] +
                stat["total_swap"];
    return error;
}
Ejemplo n.º 3
0
TError TMemorySubsystem::SetAnonLimit(TCgroup &cg, uint64_t limit) const {
    if (cg.Has(ANON_LIMIT))
        return cg.Set(ANON_LIMIT, limit ? std::to_string(limit) : "-1");
    return TError::Success();
}