Home | History | Annotate | Download | only in systat
History log of /src/usr.bin/systat/vmstat.c
RevisionDateAuthorComments
 1.92  28-Mar-2023  kre PR bin/56014 from Kouichi Hashikawa

Don't try to optimise away placing the "s" or " " after "N user"
(" " where N==1, "s" otherwise) when it seems unnecessary, as that
fails when the number of users hasn't changed, but the screen is
being redrawn from nothing (as in after being resumed from a ^Z,
as in the PR, but just doing a ^L would make the same thing happen).

XXX pullup -10 (maybe -9 as well - seems too trivial for -8).
 1.91  09-Nov-2021  nia branches: 1.91.2;
systat(1): convert realloc(x * y) to reallocarr, eliminate a temp var
 1.90  21-Aug-2021  christos PR/56331: Paul Goyette: Add -z option to display 0 instead of ' ' in vmstat.
 1.89  24-Jul-2021  simonb Instead of getting an estimate of the number of kernel buffers,
allocating memory for them, requesting all the metadata contents of
these buffers (and repeating in the unlikely case of the number of
buffers increasing too much since the estimate) and then straight away
throwing all the contents out just to count how many buffers there were,
just get the initial estimate from the kernel and subtract the slop.

Reduces system CPU usage of "systat vm" by approx 80% for any system
with a reasonable number of buffers.
 1.88  02-Mar-2020  mrg increase slot slop space from 100 to 1000 before giving up.

from Paul Ripke on current-users. thanks!
 1.87  30-Jun-2019  he branches: 1.87.2;
Make the scaling of the "bytes written" sticky, so that if we go
to K, we don't return to unscaled, and similar for higher scales
(though it takes some effort, due to the wide field...)
Fixes PR#54334.
 1.86  25-Jan-2019  christos no need for curses.h
 1.85  25-Jan-2019  christos PR/53906: Paul Ripke: systat(1) vmstat & syscall get
"alternate system clock has died" on terminal resize (SIGWINCH)
 1.84  08-Jan-2019  tih Remove a format character from a non-format string.
 1.83  26-Dec-2018  sevan Extend "systat vm" output to provide better insight about buffercache and
document it.

From Greg A. Woods in PR bin/36542
 1.82  15-Jul-2017  mlelstv branches: 1.82.2; 1.82.4; 1.82.6;
Use I/O timestamps to compute disk statistics for better precisison.
 1.81  24-Dec-2014  dennis branches: 1.81.8;
Update stats-keeping in sys/kern/vfs_cache.c to remove (most)
races while allowing consistent lockless sampling of the per-cpu
statistics without atomic operations. Update comment describing
the locking protocol to include this.

These files were fumble-fingered out of the last commit.
 1.80  20-Jun-2014  njoly Remove fagile test which ensured that first namelist element (was
X_NCHSTATS) had a known type. Make disk stats available again for
vmstat display.
 1.79  14-Jun-2014  joerg GC X_NCHSTATS
 1.78  03-Jun-2014  joerg Provide sysctl for namecache statistics.
 1.77  30-Apr-2010  njoly branches: 1.77.12; 1.77.22;
Add per process cache values to the total name translations count.
 1.76  30-Apr-2010  njoly In vmstat display, add one more column to output memory values. Avoid
overflow with more than 100GB.
 1.75  21-Oct-2009  rmind Remove uarea swap-out functionality:

- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code. Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
 1.74  21-Oct-2009  wiz Fix problems with SIGWINCH. From Paul Ripke in PR 42161.
 1.73  13-Apr-2009  lukem Fix -Wsign-compare issues
 1.72  09-Mar-2009  njoly In vmstat display, increase software interrupt count output from 5 to
6 columns.
 1.71  13-Jul-2008  dholland branches: 1.71.4; 1.71.6; 1.71.10;
Clarify how one is supposed to use the pointers returned by getutentries()
(the utmpentry.c code), specifically with respect to who owns them and
when to free them. Now they're owned by utmpentry.c, only. Abolish the
freeutentries() function, which was the wrong abstraction; add instead
endutentries(), which flushes out the internally managed memory.

Update callers as necessary. Some (e.g. talkd) had been leaking memory;
others (e.g. syslogd) had been accidentally freeing and reloading utmp
more often than necessary. There are a couple untidy bits in users and
rwhod that someone should look after sometime, maybe.

Fixes PR bin/35131, which was about talkd's memory leak.
 1.70  11-Feb-2008  dyoung branches: 1.70.6;
#include <sys/evcnt.h> instead of <sys/device.h>, since the former
is sufficient, anyway. Do not needlessly #include <sys/device.h>.

Note well: device_t is not part of the kernel ABI.
 1.69  22-Oct-2006  christos branches: 1.69.8;
use c99 initializers
consistently terminate nlist arrays with NULL not ""
 1.68  21-May-2006  dsl Reduce the field widths for the summary line of traps, system calls
and interrupts so that the numbers don't all run into one.
 1.67  14-May-2006  christos branches: 1.67.2;
Gcc 4 needs to have the enum declaration in scope to determine the enum size.
 1.66  11-May-2006  yamt include errno.h directly rather than via user.h.
 1.65  14-Apr-2006  blymn Update to use new kernel io statistics.
 1.64  20-Mar-2006  dsl free() intrnamebuf, intrname and intrloc on entry so we don't leak them
every time initvmstat() is called.
Change intrnamebuf to be static so this works.
Inspired by Coverty CID 2072 (incorrectly) reporting that the memory assigned
to intrnamebuf wasn't being freed.
 1.63  18-Mar-2006  dsl Make the functions that display the top 8 lines externally visible so
they can be used to head other pages (not ready to commit yet...).
Use puthumanint() for oversize numbers when display_mode is RUN or BOOT (when
very big numbers are to be expected).
Allow an extra column for Csw..Flt.
Adjust some #defines to avoid use of global s & s1.
 1.62  05-Feb-2006  dsl Split dkreadstats() into dkreadstats(), tkreadstats() and cpureadstats().
Similarly for dkswap().
Allows code to only call one of these.
Rename struct _disk to _vminfo to be nearer its contents.
Change 'systat vm' so that it always shows the 'current' cpu times, even
after ':run' or ':boot' commands. The code in vmstat.c doesn't support :run.
 1.61  07-Aug-2005  blymn Add tape statistics.
 1.60  22-May-2005  chs do not rely on the pre-evcnt interrupt counter kernel symbols being present.
if they do not exist, then interrupt stats are all in evcnts.
 1.59  26-Feb-2005  dsl WARNS=3
 1.58  22-Feb-2005  christos PR/29505: Nicolas Joly: Increase width of csw value in systat vmstat.
 1.57  03-Feb-2005  christos PR/29213: Nicolas Joly: sysstat(1) vmstat cannot display large memory values
 1.56  13-Jun-2004  mycroft Fix a display glitch when blanking out drive columns.
 1.55  19-Sep-2003  itojun realloc pedant
 1.54  30-Aug-2003  dsl Use correct size when copying interrupt counters.
Fixes second part of bin/10095 (first part fixed in rev 1.25)
 1.53  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.52  05-Aug-2003  grant Discs->Disks
 1.51  11-Jun-2003  drochner no need to #include <sys/dkstat.h>
 1.50  15-May-2003  itojun use strlcpy
 1.49  18-Feb-2003  dsl Pivot the disk stats into extra lines if they run out of columns
(approved by christos)
 1.48  17-Feb-2003  dsl Fiddle with screen layout to generate room for longer labels on the
interrupt count fields.
(approved by christos)
 1.47  13-Feb-2003  dsl Avoid displaying "intr" for all interrupt counter titles
(approved by christos)
 1.46  20-Jan-2003  dsl Make kernel address arg of kvm_ckread() const void * so caller doesn't
need a cast.
(approved by christos)
 1.45  18-Jan-2003  christos kill warns.
 1.44  18-Jan-2003  dsl pull interrupt stats from event counts
fix disk xfer byte count
fix absolute counts - were divided by time interval
 1.43  01-Nov-2002  mrg iostat(8) and systat(8) support for separate read/write disk statistics.
"iostat -x" now shows these (ala linux/solaris), but this is only splitting
the read/write bytes/transactions, not adding any new metrics. "systat
iostat" now has two new commands to switch between combined/separate mode
for both it's numbers & bar modes.
 1.42  25-Sep-2002  christos PR/18408: Chris Demetriou: Kilo is abbreviated using a small k not a CAPITAL K.
 1.41  08-Aug-2002  abs introduce puthumanint() which calls humanize_number(), and use to
display disk transfer values (Suggested by Simon Burge). Also clip
%busy to 100 and display as an int which has the useful side effect
of stopping it overflowing into the next column (100.0).
 1.40  01-Aug-2002  christos scan utmpx/utmp.
 1.39  30-Jun-2002  sommerfeld Since the KERN_CP_TIME sysctl reports total clock ticks across all
cpus and hz is measured in ticks per cpu, divide tick count by ncpu to
determine elapsed time since last sample.

Fixes I/O rate deflation observed on multiprocessors.
 1.38  15-May-2002  kleink branches: 1.38.2;
From Simon Burge: remove orphaned reference to _total; fixes PR bin/16804.
 1.37  28-Jan-2002  augustss branches: 1.37.2;
Make it compile (more vmstat fallout).
 1.36  28-Sep-2001  augustss Since the system call and trap rates are often 5 digit numbers these
days we move the columns a little to avoid running into other numbers.
 1.35  01-Dec-2000  simonb Remove extern variables and functions now declared in dkstats.h.
While here, remove 77 (!) unneed #includes.
 1.34  29-Nov-2000  simonb Use the vm.uvmexp2 sysctl.
 1.33  05-Jul-2000  ad - Add `boot', `run', `time' and `zero' commands to all IP displays. These work
as in the `vmstat' display mode. The default mode is now `time', not `boot'.
- ANSIfy.
- s@kre\(@vmstat\(@.
- __RCSID() police.
- Tweak inet.icmp display visual a little.
 1.32  29-Jun-2000  mrg remove include of <vm/vm.h>
 1.31  05-Jun-2000  mycroft branches: 1.31.2;
Display disk busy statistics as `%busy', as it's less confusing.
 1.30  04-Jun-2000  mycroft Use hline() and variants in a bunch of places.
 1.29  04-Jun-2000  mycroft Fix a check so that holding down the space bar doesn't cause systat to lose.
 1.28  04-Jun-2000  mycroft Fix the CPU usage bar graph.
 1.27  04-Jun-2000  thorpej Use kern.cp_time to fetch cp_time[]. Don't support fetching it from
crash dumps yet, as that requires determining which CPU we should fetch
it from, etc.
 1.26  04-Jun-2000  perry include sys/sched.h to get definition of CPUSTATES
 1.25  29-May-2000  simonb Another cp_time size fix - also, there are 5 CPUSTATES now not four...
 1.24  21-Jan-2000  mycroft branches: 1.24.2;
Nuke `extern int errno;' in code we compile with -Wstrict-prototypes. We get
the correct definition from errno.h.
 1.23  20-Dec-1999  jwise Fix error handling throughout. First off, it is not true as claimed in swap.c
that `systat doesn't handle errors'. Second off, errx should not be used directly, since
the terminal should be cleaned up before bailing. Third off, whatever we do we need
to be consistent.

There, I feel better now.
 1.22  20-Dec-1999  jwise Two things:

1.) fix a bug which caused coredumps when starting with no mode arguments
2.) move to table-lookup for mode-specific command parsing as well.
all command matching is now table-driven.
 1.21  10-Oct-1999  mrg let "systat vmstat" say "1 user" not "1 users"
 1.20  30-Sep-1999  soren There's room in the systat-vmstat-iostat display, so allow four-letter
device names like e.g. ccd0 and print an extra digit of precision in
the 'sec' line like iostat(8) does.
 1.19  24-Mar-1999  mrg branches: 1.19.2; 1.19.4;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.18  26-Dec-1998  marc display the seconds in the timestamp in the corner, too.
 1.17  19-Dec-1998  drochner avoid integer overflow in free memory report
 1.16  06-Dec-1998  mycroft Add missing braces, so PUTRATE() works correctly as an if clause.
 1.15  19-Jul-1998  drochner Fix handling of privileges - the gid was given up before dkinit()
was called.
Pass the gid to use for KVM access explicitely to dkinit(), the caller
decides whether to call setgid(getgid()) or not.
 1.14  12-Jul-1998  mrg - KNF
- use snprintf
- don't overwrite the keyboard buffer (and make this sized on
the window size).
 1.13  09-Feb-1998  mrg clean up memory totals in UVM case.
 1.12  09-Feb-1998  mrg make "systat vmstat" much much much more UVM friendly.
 1.11  07-Feb-1998  mrg build and run with -DUVM. this isn't yet finished but it does run and partially work.
 1.10  19-Oct-1997  lukem fix .Nm usage, deprecate register, getopt returns -1 not EOF, s/[br]*/[ms]*/
 1.9  25-Aug-1997  kleink Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.
 1.8  21-Jul-1997  mrg - some KNF.
- use __RCSID().
- WARNS=1
 1.7  13-Dec-1996  scottr Freshen up a bit:

- Replace deprecated sigblock() with sigprocmask()
- Redraw the current display if SIGWINCH is caught
- Style police
 1.6  11-Aug-1996  explorer remove nlist lookup of _dk_*
 1.5  10-May-1996  thorpej New userland code to read the statistics kept by the NetBSD generic
disk framework, from John M. Vinopal <banshee@gabriella.resort.com>
 1.4  29-Apr-1995  cgd various includes, casts, and cleanups...
 1.3  22-Mar-1995  mycroft Use err*(3)/warn*(3).
 1.2  20-Jan-1995  jtc Changed to conform to NetBSD's new RCS Id convention.
 1.1  20-Jan-1995  jtc branches: 1.1.1;
Initial revision
 1.1.1.1  20-Jan-1995  jtc imported from 44lite
 1.19.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.2.1  23-Jan-2000  he Pull up revision 1.24 (requested by mycroft):
Always do the errno indirection hack, so that non-threaded
libraries get the right errno value when linked with -lpthread.
This means "always include <errno.h> and never declare errno
yourself".
 1.24.2.1  23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.31.2.1  01-Sep-2000  ad Pull up the following revisions, approved by releng-1-5:

- Add "boot", "run", "time" and "zero" commands to all IP displays. These work
as in the "vmstat" display mode. The default mode is now "time", not "boot".
- ANSIfy.
- s@kre\(@vmstat\(@.
- __RCSID() police.
- Tweak inet.icmp display visual a little.

netstat.c 1.19
pigs.c 1.20
ps.c 1.16
swap.c 1.13
systat.1 1.20
systat.h 1.7
tcp.c 1.7
vmstat.c 1.33
 1.37.2.2  12-Nov-2002  skrll Catch up to -current.
 1.37.2.1  28-Jan-2002  skrll file vmstat.c was added on branch nathanw_sa on 2002-11-12 16:55:00 +0000
 1.38.2.1  30-Jun-2002  lukem Pull up revision 1.39 (requested by sommerfeld in ticket #406):
Since the KERN_CP_TIME sysctl reports total clock ticks across all
cpus and hz is measured in ticks per cpu, divide tick count by ncpu to
determine elapsed time since last sample.
Fixes I/O rate deflation observed on multiprocessors.
 1.67.2.1  19-Jun-2006  chap Sync with head.
 1.69.8.1  23-Mar-2008  matt sync with HEAD
 1.70.6.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.71.10.1  21-Apr-2010  matt sync to netbsd-5
 1.71.6.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.71.4.1  27-Oct-2009  bouyer Pull up following revision(s) (requested by wiz in ticket #1110):
usr.bin/systat/vmstat.c: revision 1.74
usr.bin/systat/syscall.c: revision 1.7
Fix problems with SIGWINCH. From Paul Ripke in PR 42161.
 1.77.22.1  10-Aug-2014  tls Rebase.
 1.77.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.81.8.3  11-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #1926):

usr.bin/systat/vmstat.c: revision 1.92

PR bin/56014 from Kouichi Hashikawa

Don't try to optimise away placing the "s" or " " after "N user"
(" " where N==1, "s" otherwise) when it seems unnecessary, as that
fails when the number of users hasn't changed, but the screen is
being redrawn from nothing (as in after being resumed from a ^Z,
as in the PR, but just doing a ^L would make the same thing happen).
 1.81.8.2  30-Jan-2019  martin Pull up following revision(s) (requested by christos in ticket #1176):

usr.bin/systat/main.c: revision 1.55
usr.bin/systat/extern.h: revision 1.47
usr.bin/systat/syscall.c: revision 1.10
usr.bin/systat/iostat.c: revision 1.39
usr.bin/systat/vmstat.c: revision 1.85
usr.bin/systat/vmstat.c: revision 1.86

no need for curses.h

-

PR/53906: Paul Ripke: systat(1) vmstat & syscall get
"alternate system clock has died" on terminal resize (SIGWINCH)
 1.81.8.1  25-Jul-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #138):
usr.bin/systat/iostat.c: revision 1.38
usr.bin/systat/vmstat.c: revision 1.82
usr.bin/vmstat/drvstats.c: revision 1.11
usr.bin/vmstat/drvstats.h: revision 1.5
usr.bin/vmstat/vmstat.c: revision 1.217
usr.sbin/iostat/iostat.c: revision 1.65
Use I/O timestamps to compute disk statistics for better precision.
Disk statistics are collected in a fixed size array, that got corrupted
when a disk was detached. Adapt by skipping entries of detached disks
and detect reused disknames at the array end.
--
Use I/O timestamps to compute disk statistics for better precisison.
 1.82.6.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.82.6.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.82.6.1  10-Jun-2019  christos Sync with HEAD
 1.82.4.3  26-Jan-2019  pgoyette Sync with HEAD
 1.82.4.2  18-Jan-2019  pgoyette Synch with HEAD
 1.82.4.1  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.82.2.2  15-Jul-2017  mlelstv 3327190
 1.82.2.1  15-Jul-2017  mlelstv file vmstat.c was added on branch perseant-stdc-iso10646 on 2017-07-15 08:22:24 +0000
 1.87.2.1  11-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #1777):

usr.bin/systat/vmstat.c: revision 1.92

PR bin/56014 from Kouichi Hashikawa

Don't try to optimise away placing the "s" or " " after "N user"
(" " where N==1, "s" otherwise) when it seems unnecessary, as that
fails when the number of users hasn't changed, but the screen is
being redrawn from nothing (as in after being resumed from a ^Z,
as in the PR, but just doing a ^L would make the same thing happen).
 1.91.2.1  10-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #489):

usr.bin/systat/vmstat.c: revision 1.92

PR bin/56014 from Kouichi Hashikawa

Don't try to optimise away placing the "s" or " " after "N user"
(" " where N==1, "s" otherwise) when it seems unnecessary, as that
fails when the number of users hasn't changed, but the screen is
being redrawn from nothing (as in after being resumed from a ^Z,
as in the PR, but just doing a ^L would make the same thing happen).

RSS XML Feed