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
Unknown Object (File)
Sat, Mar 9, 8:47 PM
Unknown Object (File)
Wed, Mar 6, 1:26 AM
Unknown Object (File)
Wed, Mar 6, 1:22 AM
Unknown Object (File)
Feb 14 2024, 7:57 AM
Unknown Object (File)
Dec 24 2023, 12:10 PM
Unknown Object (File)
Dec 24 2023, 12:10 PM
Unknown Object (File)
Dec 22 2023, 10:03 PM
Unknown Object (File)
Nov 27 2023, 10:13 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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?

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.

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

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.

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.