Skip to content

vmstat: report -s memory lines in KiB and add SReclaimable to swap cache - #816

Open
SichenLiang wants to merge 2 commits into
uutils:mainfrom
SichenLiang:vmstat-s-memory-lines
Open

SichenLiang wants to merge 2 commits into
uutils:mainfrom
SichenLiang:vmstat-s-memory-lines

Conversation

@SichenLiang

Copy link
Copy Markdown
Contributor

Print the memory lines of vmstat -s in KiB, the unit of /proc/meminfo, and count SReclaimable in swap cache, as the cache column of the default output already does. With the same fixed /proc data, every line of vmstat -s now matches procps-ng 4.0.7.

The new unit test covers both changes.

Fixes #815

The "K ..." memory lines of `vmstat -s` divided the meminfo byte counts
by 1000, so they were 2.4% larger than the kB values in /proc/meminfo.
Divide by 1024 instead, and count SReclaimable in "swap cache" as the
cache column of the default output already does.
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.42%. Comparing base (67832aa) to head (a358c11).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/vmstat/src/picker.rs 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #816      +/-   ##
==========================================
+ Coverage   19.20%   19.42%   +0.22%     
==========================================
  Files          68       68              
  Lines       10156    10210      +54     
  Branches      546      552       +6     
==========================================
+ Hits         1950     1983      +33     
- Misses       8206     8227      +21     
Flag Coverage Δ
macos_latest 6.75% <ø> (ø)
ubuntu_latest 19.78% <0.00%> (+0.22%) ⬆️
windows_latest 0.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/uu/vmstat/src/picker.rs Outdated
(
"K total memory".to_string(),
memory_info.mem_total.0 / bytesize::KB,
memory_info.mem_total.0 / bytesize::KIB,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a small to_kib closure would avoid repeating .0 / bytesize::KIB 10 times :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done

Comment thread src/uu/vmstat/src/picker.rs Outdated
let stat = HashMap::from([
("cpu".to_string(), "0 0 0 0 0 0 0 0 0 0".to_string()),
("intr".to_string(), "0".to_string()),
("ctxt".to_string(), "0".to_string()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this setup is almost the same as in stats_user_ticks_use_raw_user
could be dedup with a small helper building the ProcData, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to small build_proc_data helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmstat: -s prints memory in 1000-byte units and leaves SReclaimable out of swap cache

2 participants