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)
Wed, Oct 15, 2:25 AM
Unknown Object (File)
Thu, Oct 9, 2:46 PM
Unknown Object (File)
Tue, Sep 30, 8:23 AM
Unknown Object (File)
Sat, Sep 20, 4:31 PM
Unknown Object (File)
Sep 14 2025, 6:29 PM
Unknown Object (File)
Aug 31 2025, 1:12 AM
Unknown Object (File)
Aug 27 2025, 5:42 PM
Unknown Object (File)
Aug 12 2025, 4:53 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.