Skip to content

Commit 5406557

Browse files
authored
Merge pull request #655 from Deepak8858/fix/issue-389-vmstat-cache-info
fix: vmstat cache column should include SReclaimable
2 parents d8c0419 + 3c7d6b1 commit 5406557

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/uu/vmstat/src/parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ pub struct Meminfo {
204204
pub mem_available: bytesize::ByteSize,
205205
pub buffers: bytesize::ByteSize,
206206
pub cached: bytesize::ByteSize,
207+
pub s_reclaimable: bytesize::ByteSize,
207208
pub swap_cached: bytesize::ByteSize,
208209
pub active: bytesize::ByteSize,
209210
pub inactive: bytesize::ByteSize,
@@ -226,6 +227,8 @@ impl Meminfo {
226227
bytesize::ByteSize::from_str(proc_map.get("MemAvailable").unwrap()).unwrap();
227228
let buffers = bytesize::ByteSize::from_str(proc_map.get("Buffers").unwrap()).unwrap();
228229
let cached = bytesize::ByteSize::from_str(proc_map.get("Cached").unwrap()).unwrap();
230+
let s_reclaimable =
231+
bytesize::ByteSize::from_str(proc_map.get("SReclaimable").unwrap()).unwrap();
229232
let swap_cached =
230233
bytesize::ByteSize::from_str(proc_map.get("SwapCached").unwrap()).unwrap();
231234
let active = bytesize::ByteSize::from_str(proc_map.get("Active").unwrap()).unwrap();
@@ -238,6 +241,7 @@ impl Meminfo {
238241
mem_available,
239242
buffers,
240243
cached,
244+
s_reclaimable,
241245
swap_cached,
242246
active,
243247
inactive,

src/uu/vmstat/src/picker.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,10 @@ fn get_memory_info(
354354
}
355355

356356
let buffer = with_unit(memory_info.buffers.as_u64(), matches);
357-
let cache = with_unit(memory_info.cached.as_u64(), matches);
357+
let cache = with_unit(
358+
(memory_info.cached + memory_info.s_reclaimable).as_u64(),
359+
matches,
360+
);
358361

359362
vec![
360363
(len, format!("{swap_used}")),

0 commit comments

Comments
 (0)