bmahler commented on code in PR #564: URL: https://github.com/apache/mesos/pull/564#discussion_r1573045523
########## src/linux/cgroups2.hpp: ########## @@ -243,6 +243,41 @@ Try<BandwidthLimit> max(const std::string& cgroup); // See: https://docs.kernel.org/admin-guide/cgroup-v2.html namespace memory { +// Memory usage statistics. +// +// Snapshot of the 'memory.stat' control file. +// +// Note: +// We only record a subset of the memory statistics; a complete list can be +// found in the kernel documentation. +// https://docs.kernel.org/admin-guide/cgroup-v2.html#memory-interface-files +struct Stats +{ + // Anonymous memory usage. Review Comment: let's just use the cgroups names and docs for these? ########## src/linux/cgroups2.cpp: ########## @@ -964,6 +1005,17 @@ Result<Bytes> high(const string& cgroup) return internal::parse_bytelimit(*contents); } + +Try<Stats> stats(const string& cgroup) +{ + Try<string> contents = cgroups2::read<string>(cgroup, control::STAT); + if (contents.isError()) { + return Error("Failed to read 'memory.stat': " + contents.error()); + } + + return control::stat::parse(strings::trim(*contents)); Review Comment: hm.. the parse function should know how to parse without the trimming, was this actually needed? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
