diff options
author | Pasha Vorobyev <plv@fb.com> | 2022-04-13 09:44:51 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2022-04-13 09:44:51 -0700 |
commit | 981e4db94913eab8b55601a8b8acbea13b1d72e1 (patch) | |
tree | 730abade4ab3399836e1558d08d594caf611724f | |
parent | 7ca4ec5db4df4e1d93c30454937e7538663c966b (diff) |
Add support for memory.zswap.current
Summary: We want to collect memory.zswap.current so that we can easily debug & monitor rollout of the `memory.zswap.current` cgroup file
Reviewed By: dschatzberg, lnyng, brianc118
Differential Revision: D35581379
fbshipit-source-id: 81d1f50952ec9183023931cdd668ff4ba49904b3
-rw-r--r-- | below/cgroupfs/src/lib.rs | 6 | ||||
-rw-r--r-- | below/cgroupfs/src/test.rs | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/below/cgroupfs/src/lib.rs b/below/cgroupfs/src/lib.rs index f2ef3da6..672e6544 100644 --- a/below/cgroupfs/src/lib.rs +++ b/below/cgroupfs/src/lib.rs @@ -185,6 +185,12 @@ impl CgroupReader { self.read_singleline_stat_file("memory.swap.current") } + /// Read memory.zswap.current - returning current cgroup memory + /// zswap consumption in bytes + pub fn read_memory_zswap_current(&self) -> Result<u64> { + self.read_singleline_stat_file("memory.zswap.current") + } + /// Read cpu.stat - returning assorted cpu consumption statistics pub fn read_cpu_stat(&self) -> Result<CpuStat> { CpuStat::read(&self) diff --git a/below/cgroupfs/src/test.rs b/below/cgroupfs/src/test.rs index d5ed41b5..b79943e3 100644 --- a/below/cgroupfs/src/test.rs +++ b/below/cgroupfs/src/test.rs @@ -135,6 +135,18 @@ fn test_memory_swap_current_success() { } #[test] +fn test_memory_zswap_current_success() { + let cgroup = TestCgroup::new(); + cgroup.create_file_with_content("memory.zswap.current", b"1234\n"); + + let cgroup_reader = cgroup.get_reader(); + let val = cgroup_reader + .read_memory_zswap_current() + .expect("Failed to read memory.zswap.current"); + assert_eq!(val, 1234); +} + +#[test] fn test_memory_high_success() { let cgroup = TestCgroup::new(); cgroup.create_file_with_content("memory.high", b"1234\n"); |