Page MenuHomeFreeBSD

vmstat: use 64-bit counters from struct vmtotal
ClosedPublic

Authored by kaktus on Nov 22 2017, 10:46 PM.
Tags
None
Referenced Files
F106038012: D13199.id35661.diff
Tue, Dec 24, 7:12 AM
Unknown Object (File)
Mon, Dec 23, 6:31 AM
Unknown Object (File)
Sun, Dec 22, 5:51 AM
Unknown Object (File)
Sun, Dec 22, 5:50 AM
Unknown Object (File)
Nov 21 2024, 6:50 AM
Unknown Object (File)
Oct 4 2024, 8:48 PM
Unknown Object (File)
Oct 4 2024, 8:50 AM
Unknown Object (File)
Oct 1 2024, 8:27 PM
Subscribers

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

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

usr.bin/vmstat/vmstat.c
825

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

usr.bin/vmstat/vmstat.c
825

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.

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

usr.bin/vmstat/vmstat.c
833

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

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.