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)
Sat, Nov 16, 10:15 PM
Unknown Object (File)
Fri, Nov 15, 1:29 PM
Unknown Object (File)
Thu, Nov 14, 3:17 PM
Unknown Object (File)
Tue, Nov 12, 1:44 AM
Unknown Object (File)
Mon, Nov 11, 10:42 PM
Unknown Object (File)
Mon, Nov 11, 6:05 PM
Unknown Object (File)
Dec 20 2023, 4:06 AM
Unknown Object (File)
Dec 13 2023, 6:15 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.