Page MenuHomeFreeBSD

systat -vmstat incorrectly formatting rates between certain ranges
Needs ReviewPublic

Authored by sigsys_gmail.com on Feb 6 2020, 9:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 10 2024, 11:01 PM
Unknown Object (File)
Oct 9 2024, 9:20 AM
Unknown Object (File)
Oct 3 2024, 11:48 AM
Unknown Object (File)
Oct 3 2024, 11:48 AM
Unknown Object (File)
Oct 3 2024, 11:33 AM
Unknown Object (File)
Sep 20 2024, 11:36 AM
Unknown Object (File)
Sep 9 2024, 4:28 AM
Unknown Object (File)
Sep 8 2024, 1:55 AM
Subscribers
None

Details

Reviewers
kaktus
kevans
Group Reviewers
Contributor Reviews (src)
Summary

While the system was doing about 100k syscalls per second, "systat -vmstat 1" showed "0.1" in the "Sys" column. IIUC, the problem happens between 100k to 1M, between 100M to 1G, etc, for any field formatted with this function.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sigsys_gmail.com added inline comments.
usr.bin/systat/vmstat.c
666

Here "w" is the maximum width of the field in characters. humanize_number() expects available buffer space as its second argument. Not including an extra byte for the NUL leaves only space for 3 characters and causes humanize_number() to fallback to trying to format in decimal due to lack of space (but there isn't enough space for the suffix then). There's plenty of space in "buf" for the NUL, so just add 1 to "w".

There are other problems with systat -vmstat as we talked about on IRC. I'm going to create another diff and add you guys as reviewers if you don't mind. I'm sure that this patch is correct after spending more time with it and it's very small so I'll leave it as is to not lose it. The other changes might be more problematic.