Page MenuHomeFreeBSD

vmstat: use 64-bit counters from struct vmtotal
ClosedPublic

Authored by kaktus on Nov 22 2017, 10:46 PM.

Details

Summary

Following struct vmtotal changes, make vmstat use and correctly display 64-bit counters. While here, adjust format for uintmax_t fields.

Submited by: Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by: Mysterious Code Ltd.
PR: 2137

Test Plan

Allocate large amount of virtual memory, run vmstat or vmstat -H, observe avm and fre fields.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kaktus created this revision.Nov 22 2017, 10:46 PM
kaktus added inline comments.Nov 22 2017, 10:46 PM
usr.bin/vmstat/vmstat.c
825 ↗(On Diff #35619)

bde@ mentioned that u_int64_t is a "typo". Should I change it to uint64_t or uintmax_t?

kaktus edited the summary of this revision. (Show Details)Nov 22 2017, 11:25 PM
kib added inline comments.Nov 23 2017, 10:20 AM
usr.bin/vmstat/vmstat.c
825 ↗(On Diff #35619)

He mean that u_int_64_t is pre-standard spelling for uint64_t.

I prefer uintmax_t, really there is no reason to use fixed-size types. So uintmax_t is better because it does not impose useless restrictions on the implementation. OTOH, if a future platform appear where intmax_t become 128bit or larger, it also would cause unneeded overhead.

But because this value is passed to prthuman()->humanize_number and that functions take exactly-sized type, this place should simply use uint64_t.

kaktus updated this revision to Diff 35661.Nov 23 2017, 12:56 PM

Change u_int64_t to uint64_t in prthuman() and all invocations.

kib added inline comments.Nov 23 2017, 3:53 PM
usr.bin/vmstat/vmstat.c
833 ↗(On Diff #35661)

Following Bruce advise in the parallel discussion, you may avoid the cast there by applying it in the vmstat_pgtok() definition.

kaktus updated this revision to Diff 35663.Nov 23 2017, 4:30 PM

Move uintmax_t cast to vmstat_pgtok macro.

vmstat(1) is full of style(9) violations, mostly related to libxo integration. I'd like to clean this in a separate patch.

This revision was automatically updated to reflect the committed changes.