History log of /freebsd-current/usr.bin/vmstat/vmstat.c
Revision Date Author Comments
# 1f36ca5d 07-Dec-2023 Alexander Motin <mav@FreeBSD.org>

vmstat: Rely on libxo for numbers humanization

This makes code cleaner, plus fixes such nonsense as humanized JSON
and XML, making all numbers raw without quotes, spaces, suffixes, etc.

MFC after: 2 weeks


# 598d1ac8 06-Dec-2023 Alexander Motin <mav@FreeBSD.org>

vmstat: Let libxo properly humanize -m numbers

Raw numbers can be seen in json/xml or with --libxo=no-humanize.

MFC after: 2 weeks


# 6f048e71 06-Dec-2023 Alexander Motin <mav@FreeBSD.org>

vmstat: Improve -z formatting for large names/values

MFC after: 2 weeks


# 62d47a4d 04-Dec-2023 Maxim Sobolev <sobomax@FreeBSD.org>

vmstat: fix column names broken in c168508655720

Loss of the trailing space in the multi-line format string has
resulted in column name being emitted as "FAILSLEEP", instead of
two columns "FAIL" and "SLEEP".


# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 7b21c447 15-Nov-2023 Alexander Motin <mav@FreeBSD.org>

vmstat: Make disks reporting some more reasonable

MFC after: 1 month


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# e5c30ac9 26-Nov-2022 Elliott Mitchell <ehem+freebsd@m5p.com>

vmstat: fix overflow of interrupt name buffer

sysctl() provides a count of number of bytes in the buffer. That is the
actual buffer length. Whereas looking for an interrupt entry with an
empty name could terminate too early, or overflow the end of the buffer.
The overflow will occur if the table of interrupt names is full.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36628


# d4d79718 20-Sep-2022 Elliott Mitchell <ehem+freebsd@m5p.com>

vmstat: remove shadow variables

These appear to simply be the style of arguments are left untouched and
only local variables are modified. While some may prefer that style
this simply serves to complicate things as they're perfectly writeable.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36628


# 42dc8696 29-Sep-2022 Elliott Mitchell <ehem+freebsd@m5p.com>

vmstat: remove processor counting from getcpuinfo()

As `ncpus` was otherwise unused, keeping track was pointless. Gets rid
of a warning from an unused variable.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36628


# 2abd4f85 08-Apr-2021 Andrew Turner <andrew@FreeBSD.org>

Add a way to map arm64 non-posted device memory

On arm64 we currently use a non-posted write for device memory, however
we should move to use posted writes. This is expected to work on most
hardware, however we will need to support a non-posted option for some
broken hardware.

Reviewed by: imp, manu, bcr (manpage)
Differential Revision: https://reviews.freebsd.org/D29722


# 15221c55 11-Apr-2021 Andrew Turner <andrew@FreeBSD.org>

Use if ... else when printing memory attributes

In vmstat there is a switch statement that converts these attributes to
a string. As some values can be duplicate we have to hide these from
userspace.

Replace this switch statement with an if ... else macro that lets us
repeat values without a compiler error.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: ABT Systems Ltd
Differential Revision: https://reviews.freebsd.org/D29703


# 6fcc846b 09-Nov-2020 Mateusz Guzik <mjg@FreeBSD.org>

vmstat: drop the HighUse field from malloc dump

It is hardwired to "-" since its introduction in 2005.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27141


# b54ed684 08-Nov-2020 Mateusz Guzik <mjg@FreeBSD.org>

vmstat: remove spurious newlines when reporting zones


# 828afdda 02-Nov-2020 Mateusz Guzik <mjg@FreeBSD.org>

malloc: export kernel zones instead of relying on them being power-of-2

Reviewed by: markj (previous version)
Differential Revision: https://reviews.freebsd.org/D27026


# dc04811c 28-Dec-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Move type casts into a single place. No functional changes.

MFC after: 2 weeks


# 75ad2fd0 08-Nov-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Humanize more columns in the vmstat(8) output and adjust widths.
The few columns that are not humanized are usually 0. This makes
the output mostly aligned.

Reviewed by: allanjude
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22185


# 5a84f74f 29-Oct-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Fix column title alignment.

MFC after: 2 weeks


# c1685086 06-Aug-2019 Jeff Roberson <jeff@FreeBSD.org>

Add two new kernel options to control memory locality on NUMA hardware.
- UMA_XDOMAIN enables an additional per-cpu bucket for freed memory that
was freed on a different domain from where it was allocated. This is
only used for UMA_ZONE_NUMA (first-touch) zones.
- UMA_FIRSTTOUCH sets the default UMA policy to be first-touch for all
zones. This tries to maintain locality for kernel memory.

Reviewed by: gallatin, alc, kib
Tested by: pho, gallatin
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20929


# 54a3a114 13-May-2019 Mark Johnston <markj@FreeBSD.org>

Provide separate accounting for user-wired pages.

Historically we have not distinguished between kernel wirings and user
wirings for accounting purposes. User wirings (via mlock(2)) were
subject to a global limit on the number of wired pages, so if large
swaths of physical memory were wired by the kernel, as happens with
the ZFS ARC among other things, the limit could be exceeded, causing
user wirings to fail.

The change adds a new counter, v_user_wire_count, which counts the
number of virtual pages wired by user processes via mlock(2) and
mlockall(2). Only user-wired pages are subject to the system-wide
limit which helps provide some safety against deadlocks. In
particular, while sources of kernel wirings typically support some
backpressure mechanism, there is no way to reclaim user-wired pages
shorting of killing the wiring process. The limit is exported as
vm.max_user_wired, renamed from vm.max_wired, and changed from u_int
to u_long.

The choice to count virtual user-wired pages rather than physical
pages was done for simplicity. There are mechanisms that can cause
user-wired mappings to be destroyed while maintaining a wiring of
the backing physical page; these make it difficult to accurately
track user wirings at the physical page layer.

The change also closes some holes which allowed user wirings to succeed
even when they would cause the system limit to be exceeded. For
instance, mmap() may now fail with ENOMEM in a process that has called
mlockall(MCL_FUTURE) if the new mapping would cause the user wiring
limit to be exceeded.

Note that bhyve -S is subject to the user wiring limit, which defaults
to 1/3 of physical RAM. Users that wish to exceed the limit must tune
vm.max_user_wired.

Reviewed by: kib, ngie (mlock() test changes)
Tested by: pho (earlier version)
MFC after: 45 days
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19908


# fd036dea 28-Aug-2018 John Baldwin <jhb@FreeBSD.org>

Dynamically allocate IRQ ranges on x86.

Previously, x86 used static ranges of IRQ values for different types
of I/O interrupts. Interrupt pins on I/O APICs and 8259A PICs used
IRQ values from 0 to 254. MSI interrupts used a compile-time-defined
range starting at 256, and Xen event channels used a
compile-time-defined range after MSI. Some recent systems have more
than 255 I/O APIC interrupt pins which resulted in those IRQ values
overflowing into the MSI range triggering an assertion failure.

Replace statically assigned ranges with dynamic ranges. Do a single
pass computing the sizes of the IRQ ranges (PICs, MSI, Xen) to
determine the total number of IRQs required. Allocate the interrupt
source and interrupt count arrays dynamically once this pass has
completed. To minimize runtime complexity these arrays are only sized
once during bootup. The PIC range is determined by the PICs present
in the system. The MSI and Xen ranges continue to use a fixed size,
though this does make it possible to turn the MSI range size into a
tunable in the future.

As a result, various places are updated to use dynamic limits instead
of constants. In addition, the vmstat(8) utility has been taught to
understand that some kernels may treat 'intrcnt' and 'intrnames' as
pointers rather than arrays when extracting interrupt stats from a
crashdump. This is determined by the presence (vs absence) of a
global 'nintrcnt' symbol.

This change reverts r189404 which worked around a buggy BIOS which
enumerated an I/O APIC twice (using the same memory mapped address for
both entries but using an IRQ base of 256 for one entry and a valid
IRQ base for the second entry). Making the "base" of MSI IRQ values
dynamic avoids the panic that r189404 worked around, and there may now
be valid I/O APICs with an IRQ base above 256 which this workaround
would incorrectly skip.

If in the future the issue reported in PR 130483 reoccurs, we will
have to add a pass over the I/O APIC entries in the MADT to detect
duplicates using the memory mapped address and use some strategy to
choose the "correct" one.

While here, reserve room in intrcnts for the Hyper-V counters.

PR: 229429, 130483
Reviewed by: kib, royger, cem
Tested by: royger (Xen), kib (DMAR)
Approved by: re (gjb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D16861


# 7b87f99a 20-Aug-2018 John Baldwin <jhb@FreeBSD.org>

Fully retire the unimplemented -t option from vmstat(8).

It was #ifdef'd out in the 4.4BSD import and hasn't been re-enabled
since then.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D16804


# baab2cf8 13-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

vmstat(1): various nits

Continue my parade on introspection tools by fixing:
- failed to check for null after reallocf
- avoid the comma operator
- mark usage as dead
- correct size of len


# fb3d9724 07-Feb-2018 Justin Hibbits <jhibbits@FreeBSD.org>

Temporarily widen count for interrupt rate calculations on 32-bit archs

If the interrupt count is very high (greater than ~42M), notably on one-shot
execution on long running systems, the intermediate multiplication step in the
rate calculation will overflow the width of a 32-bit architecture long (32
bits), causing the rest of the calculation to calculate with a truncated value,
and report very low rates (sometimes 0).

MFC after: 2 weeks


# aea10f36 14-Dec-2017 Mark Johnston <markj@FreeBSD.org>

Re-add spaces lost in r326436.

X-MFC with: r326436


# b05a4a9d 01-Dec-2017 Konstantin Belousov <kib@FreeBSD.org>

vmstat: fix style(9) violations and bump WARNS.

Based on the patch by: Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by: Mysterious Code Ltd. (Pawel),
The FreeBSD Foundation (me)
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13228


# 72f406a9 23-Nov-2017 Konstantin Belousov <kib@FreeBSD.org>

vmstat: use 64-bit counters from struct vmtotal.

Consistently print counters using unsigned intmax type.

Submitted by: Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by: Mysterious Code Ltd.
Differential revision: https://reviews.freebsd.org/D13199


# d5589c6c 23-Nov-2017 Konstantin Belousov <kib@FreeBSD.org>

Use C standard spelling uint64_t for u_int64_t.

Submitted by: Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by: Mysterious Code Ltd.
X-Differential revision: https://reviews.freebsd.org/D13199


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 125996b5 11-Nov-2017 Allan Jude <allanjude@FreeBSD.org>

vmstat: fix duplicate key in libxo output

In the libxo output from vmstat, the number of pages that have been
paged out uses the same key name as the number of times pages have been
paged. Appears to have been a typo or copy-pasto.

PR: 222198
Submitted by: Yavuz Tanriverdi <stemix@gmail.com>
Reviewed by: phil, garga
Differential Revision: https://reviews.freebsd.org/D12395


# d683d1a3 07-Aug-2017 Emmanuel Vadot <manu@FreeBSD.org>

vmstat: Always emit a space after the free-memory column

When displaying in non-human form, if the free-memory number
is large (more than 7 digits), there is no space between it and
the page fault column.

PR: 221290
Submitted by: Josuah Demangeon <mail@josuah.net> (Original version)


# 114e3832 23-May-2017 Mark Johnston <markj@FreeBSD.org>

Let vmstat -o recognize OBJT_MGTDEVICE objects.

MFC after: 1 week


# 89aa578f 20-Apr-2017 Gleb Smirnoff <glebius@FreeBSD.org>

- When reading VM stats, provide proper size argument to sysctl.
- While here, remove unused arguments from mysysctl().


# 83c9dea1 17-Apr-2017 Gleb Smirnoff <glebius@FreeBSD.org>

- Remove 'struct vmmeter' from 'struct pcpu', leaving only global vmmeter
in place. To do per-cpu stats, convert all fields that previously were
maintained in the vmmeters that sit in pcpus to counter(9).
- Since some vmmeter stats may be touched at very early stages of boot,
before we have set up UMA and we can do counter_u64_alloc(), provide an
early counter mechanism:
o Leave one spare uint64_t in struct pcpu, named pc_early_dummy_counter.
o Point counter(9) fields of vmmeter to pcpu[0].pc_early_dummy_counter,
so that at early stages of boot, before counters are allocated we already
point to a counter that can be safely written to.
o For sparc64 that required a whole dummy pcpu[MAXCPU] array.

Further related changes:
- Don't include vmmeter.h into pcpu.h.
- vm.stats.vm.v_swappgsout and vm.stats.vm.v_swappgsin changed to 64-bit,
to match kernel representation.
- struct vmmeter hidden under _KERNEL, and only vmstat(1) is an exclusion.

This is based on benno@'s 4-year old patch:
https://lists.freebsd.org/pipermail/freebsd-arch/2013-July/014471.html

Reviewed by: kib, gallatin, marius, lidl
Differential Revision: https://reviews.freebsd.org/D10156


# ee1acd86 10-Mar-2017 Marcelo Araujo <araujo@FreeBSD.org>

Bring back the cast removed in my previous commit to allow us build vmstat
with WARNS 2. This cast was first introduced at r87690.

Reported by: bde, pfg and ngie
MFC after: 3 weeks.


# 4e7ecee6 09-Mar-2017 Marcelo Araujo <araujo@FreeBSD.org>

Use nitems() from sys/param.h and also remove the cast.

Reviewed by: markj
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9937


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 320ab9c0 15-Nov-2016 Mark Johnston <markj@FreeBSD.org>

Remove a lingering reference to cache pages from vmstat(8).

Reported by: alc


# cc59e3a7 10-Nov-2016 Mark Johnston <markj@FreeBSD.org>

Add the laundry page count to the displays of systat, top, and vmstat.

Reviewed by: alc, kib
Differential Revision: https://reviews.freebsd.org/D8467


# ee03c16e 21-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use MIN() macro from sys/param.h.

MFC after: 2 weeks.


# 77624aed 23-Dec-2015 Craig Rodrigues <rodrigc@FreeBSD.org>

Remove extraneous characters

Noticed by: markj
Reviewed by: allanjude


# 34106634 01-Dec-2015 Allan Jude <allanjude@FreeBSD.org>

Some problems were introduced during the libxo-ification of vmstat, fix them

stop vmstat -i segfaulting
remove duplicate header from vmstat -i
do not pad the name of the interupt in encoded outputs
fix stray % and missing } in the header for vmstat -i
add outer container to vmstat -i
add missing xo_flush in vmstat -i (when run with an interval or delay)
add outer container to vmstat -m
do not pad the name of malloc areans
add outer container to vmstat -z
do not pad the name of memory zones

Reviewed by: rodrigc
Approved by: bapt (mentor)
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D4263


# f226507c 21-Nov-2015 Mark Johnston <markj@FreeBSD.org>

Add a missing brace to fix vmstat -s output.


# 0e51ea91 19-Nov-2015 Craig Rodrigues <rodrigc@FreeBSD.org>

Convert vmstat to use libxo.

This patch was based on this patch:
https://github.com/Juniper/libxo/blob/master/patches/vmstat.patch

by Phil Shafer at Juniper Networks, but updated to the latest
vmstat code.

Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D3935


# d73ce4c6 10-Sep-2015 Mark Johnston <markj@FreeBSD.org>

Remove the v_cache_min and v_cache_max sysctls. They are unused and have
no effect.

Reviewed by: alc
Sponsored by: EMC / Isilon Storage Division


# 696bb6ce 27-May-2015 John Baldwin <jhb@FreeBSD.org>

Trim spurious colon.


# ff87ae35 27-May-2015 John Baldwin <jhb@FreeBSD.org>

Export a list of VM objects in the system via a sysctl. The list can be
examined via 'vmstat -o'. It can be used to determine which files are
using physical pages of memory and how much each is using.

Differential Revision: https://reviews.freebsd.org/D2277
Reviewed by: alc, kib
MFC after: 2 weeks
Sponsored by: Norse Corp, Inc. (forward porting to HEAD/10)


# d0fde85e 23-Jan-2015 Will Andrews <will@FreeBSD.org>

Use clock_gettime to measure the time that we spent asleep during
"vmstat -i" instead of assuming it's what we asked for.

Submitted by: asomers
MFC after: 1 week
Sponsored by: Spectra Logic
MFSpectraBSD: 1066751 on 2014/06/04


# 157b158e 23-Jan-2015 Will Andrews <will@FreeBSD.org>

Use CLOCK_UPTIME to get the uptime instead of CLOCK_MONOTONIC.

Submitted by: asomers
MFC after: 1 week
Sponsored by: Spectra Logic
MFSpectraBSD: 1066740 on 2014/06/04


# 961a5dae 23-Jan-2015 Will Andrews <will@FreeBSD.org>

Make "vmstat -i" respect the -c <count> and -i <interval> options together.

Submitted by: asomers
MFC after: 1 week
Sponsored by: Spectra Logic
MFSpectraBSD: 1066735 on 2014/06/04


# 24244db0 26-Oct-2014 Kirk McKusick <mckusick@FreeBSD.org>

Replace update from -r271410 accidentally lost in -r273575.


# bcc63e85 23-Oct-2014 Kirk McKusick <mckusick@FreeBSD.org>

Fix formatting of vmstat (1) so that it looks cleaner on standard 80
column displays. In particular it wraps far less often.

Submitted by: Andy Kosela <akosela@andykosela.com>
PR: 191976


# 83a15ccf 10-Sep-2014 Hiroki Sato <hrs@FreeBSD.org>

Fix header output when -P is specified and (ncpus - 1) != maxid.

Reported by: Hiroaki Shimizu
PR: 152738


# e1ba604a 08-Aug-2014 Benjamin Kaduk <bjk@FreeBSD.org>

Update vmstat usage for last-argument count/wait parameters

Correct the usage in both the manpage and in usage() to indicate
that the wait interval and repetition count may be given either
with the respective -w/-c arguments, or as the final positional
arguments. [0]

The corresponding code to implement the positional arguments has
been conditional on the (always-enabled) BACKWARD_COMPATIBILITY
macro since the original 4.4-lite import. It's no longer reasonable
to remove the functionality, so remove the macro and conditional
instead.

Note that multiple disks may be given on the command line.

While here, sort arguments and apply minor mdoc fixes.

PR: 184755 [0]
Approved by: hrs (mentor, src committer)


# 1d212ea5 11-Jul-2014 Bryan Drewery <bdrewery@FreeBSD.org>

Fix vmstat -M after r263620 renamed 'cnt' to 'vm_cnt'.

This was showing as:
vmstat: undefined symbols:
_cnt

To remain backwards compatible with older dumps, if 'vm_cnt' symbol is not
found then try again with 'cnt'.

Reported by: pho
Sponsored by: EMC / Isilon Storage Division


# c71535cd 27-Jan-2013 Andrey Zonov <zont@FreeBSD.org>

- Show page faults requiring I/O when -s invoked.

Reviewed by: alc
MFC after: 2 weeks


# 2d780dbb 22-Mar-2012 Sergey Kandaurov <pluknet@FreeBSD.org>

Garbage collect defunct nlist(3) symbols.

MFC after: 1 week


# b7de4fa0 17-Dec-2011 Dimitry Andric <dim@FreeBSD.org>

In usr.bin/vmstat/vmstat.c, cast several printf field widths to int, and
use printf format specifiers from inttypes.h for uint64_t's.

MFC after: 1 week


# 8953ac43 18-Jul-2011 Sergey Kandaurov <pluknet@FreeBSD.org>

sintrcnt/sintrnames is the address of the size, not the actual size.
Use them appropriately to fetch the actual size.
That fixes vmstat -i with kvm backend.

Submitted by: peter
Approved by: re (kib)


# 521ea19d 18-Jul-2011 Attilio Rao <attilio@FreeBSD.org>

- Remove the eintrcnt/eintrnames usage and introduce the concept of
sintrcnt/sintrnames which are symbols containing the size of the 2
tables.
- For amd64/i386 remove the storage of intr* stuff from assembly files.
This area can be widely improved by applying the same to other
architectures and likely finding an unified approach among them and
move the whole code to be MI. More work in this area is expected to
happen fairly soon.

No MFC is previewed for this patch.

Tested by: pluknet
Reviewed by: jhb
Approved by: re (kib)


# aa7e4bb4 24-Jun-2011 Kevin Lo <kevlo@FreeBSD.org>

Remove duplicated header files


# ea9827d3 16-Mar-2011 Ed Maste <emaste@FreeBSD.org>

Remove uptime validity check that hasn't been necessary since r151417
switched to clock_gettime. vmstat will now not exit with an error
if run on a system with 10 years of uptime.


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# a48551fa 20-Nov-2010 Kevin Lo <kevlo@FreeBSD.org>

Remove unused variable


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# bf965959 15-Jun-2010 Sean Bruno <sbruno@FreeBSD.org>

Add a new column to the output of vmstat -z to indicate the number
of times the system was forced to sleep when requesting a new allocation.

Expand the debugger hook, db_show_uma, to display these results as well.

This has proven to be very useful in out of memory situations when
it is not known why systems have become sluggish or fail in odd ways.

Reviewed by: rwatson alc
Approved by: scottl (mentor) peter
Obtained from: Yahoo Inc.


# 8b10473d 21-May-2010 Sean Bruno <sbruno@FreeBSD.org>

Allow sub-second interval timings for iostat and vmstat.
e.g.
vmstat -w.5
iostat -w.5

Reviewed by: jhb
Approved by: scottl (mentor)
Obtained from: Yahoo Inc.
MFC after: 2 weeks


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 8da42c8a 06-Nov-2009 John Baldwin <jhb@FreeBSD.org>

MFC 198620:
When fetching sum stats (vmstat -s) from a crash dump, fetch per-CPU counts
and sum them to form the total counts.


# f786e2f8 29-Oct-2009 John Baldwin <jhb@FreeBSD.org>

When fetching sum stats (vmstat -s) from a crash dump, fetch per-CPU counts
and sum them to form the total counts.

PR: bin/135893
Submitted by: Mikolaj Golub to my trociny of gmail
MFC after: 1 week


# 61613f19 20-Feb-2009 Xin LI <delphij@FreeBSD.org>

Utilize calloc() instead of bzero'ing manually.


# e9d8f84b 04-Nov-2008 Giorgos Keramidas <keramida@FreeBSD.org>

Fix comment typo that managed to sneak in when I copy pasted some
comments & code from iostat.


# 4fb6032f 04-Nov-2008 Giorgos Keramidas <keramida@FreeBSD.org>

Repeat vmstat header after window.rows instead of a hardcoded 20.

Use ioctl() to get the window size in vmstat(8), and force a new
header to be prepended to the output every time the current window
size changes. Change the number of lines before each header to the
current lines of the terminal when the terminal is resized, so that
the full terminal length can be used for output lines.

Inspired by: svn change 175562 (same feature for iostat)
Reviewed by: ru (who fixed some of my bugs too)
MFC after: 1 week


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 32c9e3bd 19-Aug-2008 John Baldwin <jhb@FreeBSD.org>

Use kvm_getcptime(3) to fetch the global CPU time stats from a crashdump
since the 'cp_time' symbol doesn't exist in recent kernels. This fixes
iostat and vmstat on crash dumps.

MFC after: 1 week


# e83412c9 10-Apr-2008 Ruslan Ermilov <ru@FreeBSD.org>

Add forgotten -H, -h, and -P to usage().


# 248e52ad 18-Jan-2008 Peter Wemm <peter@FreeBSD.org>

Fix some boolean logic errors. && vs & and other sillyness. *blush*
This would prevent it from skipping non-present cpus in -P output.

Submitted by: Pieter de Goeje <pieter@degoeje.nl>


# 4adb5266 12-Dec-2007 Peter Wemm <peter@FreeBSD.org>

Add the -H, -h and -P flags to vmstat. -P causes per-cpu output of
user/system/idle stats. -h feeds the memory column through
humanize_number() to reduce the amount of column overflowing. -H turns
this off. -h is turned on by default if stdout is a tty.


# eaa29f1c 27-Jul-2007 Alan Cox <alc@FreeBSD.org>

Add a counter for the total number of pages cached and support for
reporting the value of this counter in the program "vmstat".

Approved by: re (rwatson)


# bad4d172 27-Nov-2006 Ruslan Ermilov <ru@FreeBSD.org>

- Revert signedness type changes to "struct vmtotal"; by making
them unsigned I made the possible overflows hard to detect,
and it only saved 1 bit which isn't principal, even less now
that the underlying issue with the total of virtual memory has
been fixed. (For the record, it will overflow with >=2T of
VM total, with 32-bit ints used to keep counters in pages.)

- While here, fix printing of other "struct vmtotal" members
such as t_rq, t_dw, t_pw, and t_sw as they are also signed.

Reviewed by: bde
MFC after: 3 days


# 9623c972 23-Nov-2006 Ruslan Ermilov <ru@FreeBSD.org>

Oops, fix the format specifier to what was intended.


# 5c88a11e 20-Nov-2006 Ruslan Ermilov <ru@FreeBSD.org>

- Fix types of "struct vmmeter" members so they are unsigned.

- Fix overflow bugs in sysctl(8), systat(1), and vmstat(8)
when printing values of "struct vmmeter" in kilobytes as
they don't necessarily fit into 32 bits. (Fix sysctl(8)
reporting of a total virtual memory; it's in pages too.)


# ddf32508 21-Oct-2006 Ruslan Ermilov <ru@FreeBSD.org>

- Add comma after REQUESTS field missed in previous commit.
- Widen some columns; make width of header columns less cryptic.


# d0c81050 21-Oct-2006 Gleb Smirnoff <glebius@FreeBSD.org>

Print the number of allocation failures in UMA zones.

PR: kern/102940


# bb6988aa 03-Jun-2006 David E. O'Brien <obrien@FreeBSD.org>

Increase the field widths of flt (total number of page faults), fr (pages
freed), & cs (CPU context switch rate). 'vmstat 1' output is now lined up
for today's typical machines vs. a VAX. [tested my modest 1.6ghz laptop]


# a21cbcb8 17-Oct-2005 Andre Oppermann <andre@FreeBSD.org>

Obtain true uptime through clock_gettime(CLOCK_MONOTONIC, struct *timespec)
instead of subtracting 'bootime' from 'now'.

Sponsored by: TCP/IP Optimization Fundraise 2005


# 768528ad 06-Aug-2005 Robert Watson <rwatson@FreeBSD.org>

Use libmemstat(3)'s kvm support for malloc(9) rather than hand-extracting
this information from the core dump.


# c753d56b 01-Aug-2005 Robert Watson <rwatson@FreeBSD.org>

Teach vmstat's domemstat_zone() to use memstat_kvm_uma() when the kvm
descriptor is non-NULL, restoring vmstat -z support for core dumps and
kmem access. These were broken with the introduction of UMA.


# b9dc1340 28-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

Minor syntax tweaks:

- Remove some extra blank lines.
- Remove comments that don't contribute to understanding.
- Remove additional blank lines in output added to maximize compatibility
with older vmstat output, but that is actually somewhat gratuitous.

Submitted by: bde
MFC with: other vmstat libmemstat(3) changes


# 8e73022d 25-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

Teach vmstat -m and vmstat -z to use libmemstat(3). Certain
statistics from -z are now a bit different due to changes in the
way statistics are now measured. Reproduce with some amount of
accuracy the slightly obscure layouts adopted by the two kernel
sysctls. In the future, we might want to normalize them.

GC dosysctl(), which is now no longer used.

MFC after: 1 week


# 147819cc 29-May-2005 Robert Watson <rwatson@FreeBSD.org>

Modify vmstat(8)'s domem() routine, which is responsible for extracting
malloc(9) statistics from kernel memory or a kernel coredump, to catch
up with recent changes to adopt per-CPU malloc(9) statistics. The new
routines walk the per-CPU statistics pools and coalesce them for
presentation to the user.


# f682f10c 21-May-2005 Ruslan Ermilov <ru@FreeBSD.org>

Sync program's usage() with manpage's SYNOPSIS.


# 043da612 21-Feb-2005 Paul Saab <ps@FreeBSD.org>

Fix an overflow when calculating the number of kilobytes from the
number of pages.

Obtained from: Yahoo!


# 22ab6be3 29-Jun-2004 Brian Feldman <green@FreeBSD.org>

Make vmstat -m work with -M/-N again. Note that making vmstat -z work
is much harder, and -m is grossly using unexported interfaces (that is,
the array of malloc zones/sizes does not have an exported type).


# 6d4ba9cd 23-Apr-2004 Tim J. Robbins <tjr@FreeBSD.org>

Print fork statistics with %u as they are unsigned quantities.

PR: 65889
Submitted by: Ken Stailey


# ab82970e 26-Mar-2004 Ruslan Ermilov <ru@FreeBSD.org>

Properly document the -M and -N options.


# c0445895 11-Mar-2004 Bruce Evans <bde@FreeBSD.org>

Fixed a misspelling of 0 as NULL.

Fixed a nearby bug. The "play it safe" code in dosysctl() was unsafe
because it overran the buffer by 1 if sysctl() filled all of the buffer.

Fixed a nearby style bug in output. Not just 1, but 2 extra newlines
were printed at the end by "vmstat -m" and "vmstat -z". Don't print
any newlines explicitly. This depends on 2 of the many formatting
bugs in the corresponding sysctls. First, the sysctls return an extra
newline at the end of the strings. This also messes up output from
sysctl(8). Second, the sysctls return an extra newline at the beginning
of the strings. This is good for separating the 2 tables output by
"vmstat -mz" and for starting the header on a new line in plain sysctl
output, but gives a bogus extra newline at the beginning for "vm -[m | z]"
and "sysctl -n [kern.malloc | vm.zone]".

Fixed some nearby style bugs in the source code:
- the same line that misspelled 0 as NULL also spelled NULL as 0.
- the size was doubled twice in the realloc loop.
- the "play it safe" comment was misleading. Terminating the buffer
is bogus because dosysctl() is only meant to work with sysctls that
return strings and the terminator is part of a string. However, the
kern.malloc sysctl has more than style bugs. It also doesn't return
a string. Termination is needed to work around this bug.


# 67206e04 24-Dec-2003 David Malone <dwmalone@FreeBSD.org>

Remove an unused variable.
Add some missing constness.


# 06849fd9 11-Dec-2003 Bruce Evans <bde@FreeBSD.org>

Fixed misplacement of __FBSDID(). Backed out editing of vendor id lines.
Just wrap them in #if 0...#endif.


# 56f9b096 11-Dec-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Revert part of revision 1.74 after bde reminded me of a detail I'd
forgotten about how sysctl works. This removes a potential (though
not very likely) race that 1.74 introduced.


# 1b62c241 10-Dec-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Whitespace cleanup.


# dc4ed4fe 10-Dec-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Remove debugging printf


# 7d268144 10-Dec-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix a couple of issues in the interrupt code:

- Replace overly-complicated (and buggy) -a logic with a much simpler
version: -a causes all interrupts to be displayed, otherwise only
those that have occurred are displayed. This removes the need for
any MD code.

- Instead of just making sure intrcnt is large enough, figure out the
exact size it needs to be. We derive nintr from this number, and we
don't want to risk printing garbage. Note that on sparc64, we end up
printing garbage anyway because the names of non-existent interrupts
are left uninitialized by the kernel.

Tested on: alpha, i386, sparc64


# 3c455bca 10-Dec-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

s/u_(int|long)\>/unsigned \1/


# e38926c1 10-Dec-2003 David Malone <dwmalone@FreeBSD.org>

Fix a couple of warnings (const a function parameter and change some
ints to size_ts to better match the types of variables they are used
with).

Glanced at by: des


# 7e00080c 08-Dec-2003 Marcel Moolenaar <marcel@FreeBSD.org>

Unbreak vmstat -i on ia64:
o nintr and inamlen must by of type size_t, not int,
o Remove now unnecessary casts,
o Handle the aflag differently, because the intr. names have a
fixed width and almost always have trailing spaces.


# c5163382 07-Dec-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Finish the transition from libkvm to sysctl that I started a while ago.
The use of libkvm for post-mortem analysis is still supported (though it
could use more testing). We can now remove vmstat's setgid bit.

While I'm here, hack the interrupt listing code to not display interrupts
that haven't occurred unless the -a option was given on the command line,
and document this change.


# 25d13677 09-Nov-2003 John-Mark Gurney <jmg@FreeBSD.org>

make minimum column size for interrupt name be the heading (depends upon
Total being shorter than interrupt)..

Pointed out by: bde


# 2eb7cf1a 08-Nov-2003 John-Mark Gurney <jmg@FreeBSD.org>

fix an overflow bug when scanning for length of names that I introduced in
the last commit...

include some minor style changes and fixes that bde sent me

Submitted by: bde


# a86e06a6 27-Oct-2003 John-Mark Gurney <jmg@FreeBSD.org>

take mux's fix to the next level, scan the names and make the field larger
as necessary... on sparcs where:
atapci0 vec1996
is a bit too long


# 3c93cfb5 14-Apr-2003 Tim J. Robbins <tjr@FreeBSD.org>

Reimplement the vmstat -f option (display fork statistics).

PR: 50924
Submitted by: Ken Stailey (with a few changes)


# 74d66b34 09-Apr-2003 Maxime Henrion <mux@FreeBSD.org>

Slightly rework formatting in vmstat -i so that it doesn't
break with "fooX irqY" lines that are a bit bigger.


# 7194d335 15-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Run a revision of the devstat interface:

Kernel:

Change statistics to use the *uptime() timescale (ie: relative to
boottime) rather than the UTC aligned timescale. This makes the
device statistics code oblivious to clock steps.

Change timestamps to bintime format, they are cheaper.

Remove the "busy_count", and replace it with two counter fields:
"start_count" and "end_count", which are updated in the down and
up paths respectively. This removes the locking constraint on
devstat.

Add a timestamp argument to devstat_start_transaction(), this will
normally be a timestamp set by the *_bio() function in bp->bio_t0.
Use this field to calculate duration of I/O operations.

Add two timestamp arguments to devstat_end_transaction(), one is
the current time, a NULL pointer means "take timestamp yourself",
the other is the timestamp of when this transaction started (see
above).

Change calculation of busy_time to operate on "the salami principle":
Only when we are idle, which we can determine by the start+end
counts being identical, do we update the "busy_from" field in the
down path. In the up path we accumulate the timeslice in busy_time
and update busy_from.

Change the byte_* and num_* fields into two arrays: bytes[] and
operations[].

Userland:

Change the misleading "busy_time" name to be called "snap_time" and
make the time long double since that is what most users need anyway,
fill it using clock_gettime(CLOCK_MONOTONIC) to put it on the same
timescale as the kernel fields.

Change devstat_compute_etime() to operate on struct bintime.

Remove the version 2 legacy interface: the change to bintime makes
compatibility far too expensive.

Fix a bug in systat's "vm" page where boot relative busy times would
be bogus.

Bump __FreeBSD_version to 500107

Review & Collaboration by: ken


# 571d13be 15-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Update to use current rev of devstat API.


# 190ff54e 16-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add #include <sys/resource.h>

My apologies for missing these #includes, I must have confused the
dependencies with a wrong timestamp or something.


# f341ca98 16-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove #include <sys/dkstat.h>


# f7550ecf 11-Jan-2003 Matthew Dillon <dillon@FreeBSD.org>

Make 'sysctl vm.vmtotal' work properly using updated patch from Hiten.
(the patch in the PR was stale).

PR: kern/5689
Submitted by: Hiten Pandya <hiten@unixdaemons.com>


# 95ba428c 09-Aug-2002 Thomas Moestl <tmm@FreeBSD.org>

The boottime variable in sys/kern/kern_tc.c is a struct timeval, not a
time_t, so do not use the latter as type when retrieving the variable
via libkvm. This should fix vmstat on sparc64.


# 6f267175 14-Apr-2002 Jeff Roberson <jeff@FreeBSD.org>

Remove malloc_type's ks_limit.

Updated the kmemzones logic such that the ks_size bitmap can be used as an
index into it to report the size of the zone used.

Create the kern.malloc sysctl which replaces the kvm mechanism to report
similar data. This will provide an easy place for statistics aggregation if
malloc_type statistics become per cpu data.

Add some code ifdef'd under MALLOC_PROFILING to facilitate a tool for sizing
the malloc buckets.


# e2cf5207 13-Apr-2002 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Fix a missed conversion of lld to llu for the uint64_t ks_calls and cast
to unsigned long long.

Don't be too overzealous with the printing of ks_calls in the total
statistics, cut back from 20 to 13 positions to print (which should last
a couple of years easily (20 digits is enough for 3168 years of calls at a
measly billion (10^9) calls per second.)).

Submitted by: bde


# 9e74ac9d 08-Apr-2002 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Cast totreq to unsigned long long, as needed on 64-bit machines.

Pointed out by: jeff


# 9333bd2a 08-Apr-2002 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Change totreq to uint64_t from a long (the PR has an int64_t, which didn't
make sense to me) and change the printf argument from %8ld to %20llu to
accompany the printing of the totals.
Realigned the header printed above it as well.

PR: 32342
Submitted by: ryan beasley <ryanb@goddamnbastard.org>
Reviewed by: jeff, Tim J Robbins


# 3f330d7d 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# 2294143a 19-Mar-2002 Jeff Roberson <jeff@FreeBSD.org>

Remove the kmembuckets stats in preparation for the UMA commit.


# d6bf6327 11-Dec-2001 Mark Murray <markm@FreeBSD.org>

WARNS=2 fixes, but set NO_WERROR, as there are some HardToFix(tm)
warnings originating in system headers.


# 3b7e5ccc 31-Aug-2001 Ruslan Ermilov <ru@FreeBSD.org>

SECURITY: Drop `setgid kmem' bit as early as possible.


# 9674f1d4 11-Aug-2001 Kenneth D. Merry <ken@FreeBSD.org>

Change the compute_stats() call to the new devstat_compute_statistics()
interface.

Cast the return of the rest of the printfs in here to void.

Submitted by: "Sergey A. Osokin" <osa@freebsd.org.ru>


# 1e543a50 29-Jul-2001 Thomas Moestl <tmm@FreeBSD.org>

Correct the old length argument passed to sysctl to be a pointer to a
size_t (not to an int).

MFC after: 2 days


# 9aa042f6 26-Jun-2001 Jens Schweikhardt <schweikh@FreeBSD.org>

Increase column widths when using -i (they are now wide enough to
hold a 64bit or 32bit ~0 value, i.e. 20 and 10; this anticipates
soon-to-be machines with Exahertz rtc interrupt frequencies. :-)

PR: bin/16206
Submitted by: John Capo <jc@irbs.com>
MFC after: 1 week


# f40be3e1 23-Jun-2001 Jens Schweikhardt <schweikh@FreeBSD.org>

Reduce field width for some columns so that the default output fits in <= 79
columns. 80 columns + newline is a problem for some terminals including syscons.

Requested by: bde
MFC after: 1 week


# ca513e5e 19-Jun-2001 Jens Schweikhardt <schweikh@FreeBSD.org>

Made all fields in default output be space separated. Run-together
columns confuse the heck out of other apps trying to parse vmstat output
(eg sscope). I made sure we're still <= 80 cols per line.
Fixed warnings about unused vars and printf %format mismatches.

Requested by: Eugene Aleynikov <eugenea@infospace.com>
Reviewed by: joerg (implicitly)
MFC after: 2 weeks


# 67d9fd5a 13-Jun-2001 Jens Schweikhardt <schweikh@FreeBSD.org>

Avoid the avm field joining the w field when avm is > 9.999.999 pages
which is slightly less than 4GB. To use a quote from someone who shall
remain nameless "No one will ever need more than 4 GB" :-) But FreeBSD
is prepared if we one day will.

Requested by: Eugene Aleynikov <eugenea@infospace.com>


# b1494cf0 12-Jun-2001 Jens Schweikhardt <schweikh@FreeBSD.org>

Increase field width by one for 'fre' to accomodate today's memory sizes.
PR: 25267
Submitted by: Eugene Aleynikov <eugene@infospace.com>
Reviewed by: joerg
MFC after: 2 weeks


# 3cf714fe 22-Feb-2001 Alfred Perlstein <alfred@FreeBSD.org>

fix usage statement (add missing [-n devs] option)

Submitted by: Maxim Konovalov <maxim@macomnet.ru>

Silence a warning by renaming the 'pgtok' #define to 'vmstat_pgtok' so
as not to conflict with the 'pgtok' #define in sys/param.h


# 5d22597f 23-Jan-2001 Hajimu UMEMOTO <ume@FreeBSD.org>

Add mibs to hold the number of forks since boot. New mibs are:

vm.stats.vm.v_forks
vm.stats.vm.v_vforks
vm.stats.vm.v_rforks
vm.stats.vm.v_kthreads
vm.stats.vm.v_forkpages
vm.stats.vm.v_vforkpages
vm.stats.vm.v_rforkpages
vm.stats.vm.v_kthreadpages

Submitted by: Paul Herman <pherman@frenchfries.net>
Reviewed by: alfred


# bec62dd8 22-Jan-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Use the vm.zone sysctl rather that grope through the zone allocator's
internal data structures.


# 97ace1c6 22-Jan-2001 Matt Jacob <mjacob@FreeBSD.org>

Update vm zone list traversal for changes made to kernel. Note that this
is ultimately silly because no locks are held in user space while traversing
the list via kvm_reads... really, this should use the sysctl interface
which *is* protected by a lock in the kernel.


# 30450ba4 05-May-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Remove unneeded #include <sys/buf.h>


# 0e8a43c5 01-Sep-1999 Poul-Henning Kamp <phk@FreeBSD.org>

unifdef -Uvax -Uhp300 -Uluna68k -Umips -Utahoe


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# e85dc44c 26-Jul-1999 Nick Hibma <n_hibma@FreeBSD.org>

Convert interrupt count from signed to unsigned and the total
from signed long to unsigned lon long.

PR: 12808
Submitted by: Kevin Day toasty@dragondata.com
Reviewed by: bde


# 6930c861 12-May-1999 Bruce Evans <bde@FreeBSD.org>

Backed out the previous commit, except for the parts that reduced
the magicness of 200. Cleaned up the remaining parts. Circularisation
of the list of malloc types was a kernel bug (now fixed). Interfering
with applications' definitions of pgtok is a system header bug (not
fixed).


# 7cbb70b3 09-May-1999 Warner Losh <imp@FreeBSD.org>

Sometime since this file was written, the list of kernel malloc types
changed from a simple list to a circular one. We compensate by only
looping until we see the first address again. Before, things would
terminate because it was limited to 200 iterations. This lead to
bogus statistics and repeating stats for memory types.

This should be merged into 3.2, as the same bug is there.


# 91e64226 15-Feb-1999 Bruce Evans <bde@FreeBSD.org>

Fixed bitrot in usage message and disordering of options in previous commit.

I'm not sure why we have `mvstat -z'. `sysctl vm.zone' gives more
information. OTOH, `sysctl vm.zone' shouldn't return ASCII data,
and reporting of memory use should be integrated, at least as an
option.


# 2e8c5eae 13-Feb-1999 Matthew Dillon <dillon@FreeBSD.org>

Add -z option to vmstat to dump data from the zone allocator


# 4faf42f3 09-Feb-1999 Kenneth D. Merry <ken@FreeBSD.org>

Fix vmstat display problems. The header printout wasn't quite right, and
the display wrapped around.

This decreases the default maximum number of disks shown to 2, so things
don't wrap around so easily. Also, it fixes the header display issues.

Submitted by: Bruce Evans <bde@FreeBSD.ORG>


# 2a888f93 09-Feb-1999 Kenneth D. Merry <ken@FreeBSD.org>

Add a prioritization field to the devstat_add_entry() call so that
peripheral drivers can determine where in the devstat(9) list they are
inserted.

This requires recompilation of libdevstat, systat, vmstat, rpc.rstatd, and
any ports that depend on the devstat code, since the size of the devstat
structure has changed. The devstat version number has been incremented as
well to reflect the change.

This sorts devices in the devstat list in "more interesting" to "less
interesting" order. So, for instance, da devices are now more important
than floppy drives, and so will appear before floppy drives in the default
output from systat, iostat, vmstat, etc.

The order of devices is, for now, kept in a central table in devicestat.h.
If individual drivers were able to make a meaningful decision on what
priority they should be at attach time, we could consider splitting the
priority information out into the various drivers. For now, though, they
have no way of knowing that, so it's easier to put them in an easy to find
table.

Also, move the checkversion() call in vmstat(8) to a more logical place.

Thanks to Bruce and David O'Brien for suggestions, for reviewing this, and
for putting up with the long time it has taken me to commit it. Bruce did
object somewhat to the central priority table (he would rather the
priorities be distributed in each driver), so his objection is duly noted
here.

Reviewed by: bde, obrien


# b5e7d113 27-Oct-1998 John Polstra <jdp@FreeBSD.org>

Back out previous work-around for "vmstat -i" failing on ELF
kernels. A better fix is now committed to "src/lib/libc/gen/nlist.c"
and "src/usr.sbin/kvm_mkdb/nlist.c".


# e74e8b8b 24-Oct-1998 Mike Smith <msmith@FreeBSD.org>

Work around some variables having N_UNDF types but valid values; this
makes vmstat work on ELF kernels again.
Submitted by: Daniel Rock <rock@cs.uni-sb.de>


# bcc6a3da 19-Sep-1998 Kenneth D. Merry <ken@FreeBSD.org>

Change the devstat generation number from an int to a long. The int-sized
generation was causing unaligned access faults on the Alpha.

I have incremented the devstat version number, since this is an interface
change. You'll need to recompile libdevstat, systat, iostat, vmstat and
rpc.rstatd along with your kernel.

Partially Submitted by: Andrew Gallatin <gallatin@cs.duke.edu>


# 8f82c3ea 16-Sep-1998 Matthew Dillon <dillon@FreeBSD.org>

vmstat shows all manually-specified devices rather then just the first
three.


# 8d2fbde5 15-Sep-1998 Justin T. Gibbs <gibbs@FreeBSD.org>

Update system to new device statistics code.

Submitted by: "Kenneth D. Merry" <ken@plutotech.com>


# 22694eba 06-Jul-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# 4d5459f7 07-Mar-1998 John Dyson <dyson@FreeBSD.org>

Support a couple of new "-s" stats.


# 188da0ef 05-Dec-1997 Bruce Evans <bde@FreeBSD.org>

Const poisoning from ks_shortdesc.


# 8c85509d 10-Oct-1997 Poul-Henning Kamp <phk@FreeBSD.org>

struct kmemstats was renamed.


# 327af189 10-Oct-1997 Poul-Henning Kamp <phk@FreeBSD.org>

Make vmstat understand the dynamic malloc stuff. There are a number
of ugly hardcoded constants in there.


# fed746a5 06-Oct-1997 Dima Ruban <dima@FreeBSD.org>

Be more specific about -f/-t options (they're not yet implemented),
not just exit with 0 status.

This definitely should go to 2.2.5.
If i won't have any objections - I'll commit it tonight.


# 495aecea 25-Aug-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). Add some %d to %ld changes.


# c44252b6 06-Jul-1997 Bruce Evans <bde@FreeBSD.org>

Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should
already have been imported.


# 1c8af878 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 54a06400 16-Mar-1997 Marc G. Fournier <scrappy@FreeBSD.org>

Slight visual formatting change to the output so that:

procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr w0 w1 in sy cs us sy id
1 0 04135184 6016 180 2 1 0 158 135 10 0 386 1820 77 20 6 74

looks like:

procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr w0 w1 in sy cs us sy id
1 0 0 4135188 6016 180 2 1 0 158 135 10 0 387 1821 77 20 6 74


# 1d66e218 03-Mar-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

Print number of second-level cache hits as per-directory, not per-process
(since they're per-directory now).
Learned from: Kirk McKusick's OS internals course.. :-)


# d376015e 13-Dec-1995 Bruce Evans <bde@FreeBSD.org>

Reduced vm dependencies. Only `struct vmmeter.h' is required.
Unfortunately, the sysctl number for reading this struct is
bogusly placed in <vm/vm_param.h> instead of with the declaration
of the struct.


# 5141eaa4 13-Dec-1995 Peter Wemm <peter@FreeBSD.org>

add a #include <sys/vmmeter.h> since we are using the vmmeter structures
and this was once (but no longer it seems) included by <vm/vm.h>
It should now compile again.


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# ff93e578 25-Mar-1995 David Greenman <dg@FreeBSD.org>

Removed object lookup/hit count and changed the order of things a little.


# 42d825e1 24-Mar-1995 David Greenman <dg@FreeBSD.org>

Removed printing of cnt.v_nzfod: we don't implement this in the kernel.


# 39b3568a 09-Jan-1995 David Greenman <dg@FreeBSD.org>

Added 'pages in VM cache' statistic.


# eb0a76a8 18-Oct-1994 David Greenman <dg@FreeBSD.org>

Made zero-fill stats a bit more clear.


# 204b7274 18-Oct-1994 David Greenman <dg@FreeBSD.org>

Updated to changes in struct vmmeter and reorganized -s stats to be more
logical.


# 8678b0eb 17-Oct-1994 David Greenman <dg@FreeBSD.org>

Restore all of my changes that Garrett clobbered in the previous commit.


# 379bb2d7 15-Oct-1994 Garrett Wollman <wollman@FreeBSD.org>

New way of getting disk drive names.


# d8041096 15-Oct-1994 David Greenman <dg@FreeBSD.org>

Updated to changes in struct vmmeter. Nuked !NEWVM code. Fixed rounding
bug when interval is 1 second.


# 3d9d72fc 04-Oct-1994 Poul-Henning Kamp <phk@FreeBSD.org>

Realigned the output of "vmstat -m", "MSDOSFS mount" was too wide for the
field. Saved some space and gained a little clarity by printing "128K"
instead of 131072 (and so on).


# 987df638 29-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

Add read_names support for i386, based on my original work from FreeBSD
and cleaned up slightly.


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources