Repository navigation
vmstat: report -s memory lines in KiB and add SReclaimable to swap cache - #816
Open
SichenLiang wants to merge 2 commits into
Open
SichenLiang wants to merge 2 commits into
SichenLiang wants to merge 2 commits into
Conversation
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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sylvestre
reviewed
Oct 6, 2026
| ( | ||
| "K total memory".to_string(), | ||
| memory_info.mem_total.0 / bytesize::KB, | ||
| memory_info.mem_total.0 / bytesize::KIB, |
Contributor
There was a problem hiding this comment.
a small to_kib closure would avoid repeating .0 / bytesize::KIB 10 times :)
sylvestre
reviewed
Oct 6, 2026
| 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()), |
Contributor
There was a problem hiding this comment.
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?
Contributor
Author
There was a problem hiding this comment.
moved to small build_proc_data helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Print the memory lines of
vmstat -sin 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/procdata, every line ofvmstat -snow matches procps-ng 4.0.7.The new unit test covers both changes.
Fixes #815