summaryrefslogtreecommitdiffstats
path: root/usr.bin/systat/vmstat.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* don't reuse global between functions; the value is wrong.tedu2019-01-201-3/+5
| | | | reported by Bryan Linton
* Add new KERN_CPUSTATS sysctl(2) so we can identify offline CPUs.cheloha2018-11-171-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because of hw.smt we need a way to determine whether a given CPU is "online" or "offline" from userspace. KERN_CPTIME2 is an array, and so cannot be cleanly extended for this purpose, so add a new sysctl(2) KERN_CPUSTATS with an extensible struct. At the moment it's just KERN_CPTIME2 with a flags member, but it can grow as needed. KERN_CPUSTATS appears to have been defined by BSDi long ago, but there are few (if any) packages in the wild still using the symbol so breakage in ports should be near zero. No other system inherited the symbol from BSDi, either. Then, use the new sysctl(2) in systat(1) and top(1): - systat(1) draws placeholder marks ('-') instead of percentages for offline CPUs in the cpu view. - systat(1) omits offline CPU ticks when drawing the "big bar" in the vmstat view. The upshot is that the bar isn't half idle when half your logical CPUs are disabled. - top(1) does not draw lines for offline CPUs; if CPUs toggle on or offline in interactive mode we redraw the display to expand/reduce space for the new/missing CPUs. This is consistent with what some top(1) implementations do on Linux. - top(1) omits offline CPUs from the totals when CPU totals are combined into a single line (the '-1' flag). Originally prompted by deraadt@. Discussed endlessly with deraadt@, ketennis@, and sthen@. Tested by jmc@ and jca@. Earlier versions also discussed with jca@. Earlier versions tested by jmc@, tb@, and many others. docs ok jmc@, kernel bits ok ketennis@, everything ok sthen@, "Is your stuff in yet?" deraadt@
* Revert KERN_CPTIME2 ENODEV changes in kernel and userspace.cheloha2018-10-051-26/+7
| | | | ok kettenis deraadt
* KERN_CPTIME2: set ENODEV if the CPU is offline.cheloha2018-09-261-7/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lets userspace distinguish between idle CPUs and those that are not schedulable because hw.smt=0. A subsequent commit probably needs to add documentation for this to sysctl.2 (and perhaps elsewhere) after the dust settles. Also included here are changes to systat(1) and top(1) that account for the ENODEV case and adjust behavior accordingly: - systat(1)'s cpu view prints placeholder marks ('-') instead of percentages for each state if the given CPU is offline. - systat(1)'s vmstat view checks for offline CPUs when computing the machine state total and excludes them, so the CPU usage graph only represents the states for online CPUs. - top(1) does not draw CPU rows for offline CPUs when the view is redrawn. If CPUs "go offline", percentages for each state are replaced by placeholder marks ('-'); the view will need to be redrawn to remove these rows. If CPUs "go online" the view will need to be redrawn to show these new CPUs. In "combined CPU" mode, the count and the state totals only represent online CPUs. Ports using KERN_CPTIME2 will need to be updated. The changes described above to make systat(1) and top(1) aware of the ENODEV case *and* gracefully handle a changing HW_NCPUONLINE while the application is running are not necessarily appropriate for each and every port. The changes described above are so extensive in part to demonstrate one way a program *might* be made robust to changing CPU availability. In particular, changing hw.smt after boot is an extremely rare event, and this needs to be weighed when updating ports. The logic needed to account for the KERN_CPTIME2 ENODEV case is very roughly: if (sysctl(...) == -1) { if (errno != ENODEV) { /* Actual error occurred. */ } else { /* CPU is offline. */ } } else { /* CPU is online and CPU states were set by sysctl(2). */ } Prompted by deraadt@. Basic idea for ENODEV from kettenis@. Discussed at length with kettenis@. Additional testing by tb@. No complaints from hackers@ after a week. ok kettenis@, "I think you should commit [now]" deraadt@
* Constrain IPKTS/OPKTS from floating down beyond the rest of thekrw2018-06-221-19/+24
| | | | | | displayed lines. Makes vmstat view in tall windows easier to read. ok sthen@
* Do not ignore nice time in systat(1). The sum would not be 100%,bluhm2018-05-191-4/+6
| | | | | | | a busy machine would look idle. As %Nic does not fit in the columns, add it to %Usr. Introduce @ for spinning time to keep the characters people are used to. Put %Spn between %Int and %Sys like in top. OK visa@ mpi@
* Stopping counting and reporting CPU time spent spinning on a lock asmpi2018-05-141-5/+5
| | | | | | | | | system time. Introduce a new CP_SPIN "scheduler state" and modify userland tools to display the % of timer a CPU spents spinning. Based on a diff from jmatthew@, ok pirofti@, bluhm@, visa@, deraadt@
* test for failing allocation using the standard idiom; prompted by Nan Xiaootto2018-05-031-2/+4
| | | | ok tb@
* Remove statements that have no effect from X(), Y() and Z() #define's.krw2016-12-181-4/+4
| | | | | | | Leftovers from the re-engining of systat eight years ago. Makes gcc quieter. ok otto@ deraadt@
* Convert quad_t to int64_t and %q to %llguenther2016-08-241-9/+9
| | | | | | Convert bzero() to memset() and bcopy() to memcpy() ok natano@ millert@
* Do not cast result of malloc/calloc/realloc* if stdlib.h is in scopederaadt2015-08-201-2/+2
| | | | ok krw millert
* first batch of programs adapting to the namespace cleanupderaadt2015-01-161-5/+8
| | | | | (pfvar.h nameser.h proc.h ucred.h) ok guenther millert, and some review from doug as well.
* <sys/buf.h> isn't actually needed hereguenther2014-11-231-2/+1
| | | | ok tedu@
* Remove non-standard <sys/dkstat.h> header. It has not contained anythingmiod2014-09-151-6/+5
| | | | | | | | | | related to disk stastics for almost 17 years, and the remaining userland-visible defines duplicate those found in <sys/sched.h>. Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and update all users to cope with this. ok kettenis@
* Use VM_UVMEXP instead of VM_METER for memory usages and directlympi2014-04-081-3/+2
| | | | | | | include <sys/vmmeter.h> where it is needed instead of relying on it being included by <uvm/uvm_extern.h>. miod@ likes it, ok guenther@
* sometimes we find .h we no longer needderaadt2013-10-311-2/+3
|
* Don't display swapin/swapout uvmexp fieldsmiod2013-05-141-3/+1
|
* Make KERN_CPTIME return an avarage number of ticks across all CPUsmikeb2010-11-191-11/+2
| | | | tedu agreed with an idea, tested by Luis Useche and me; ok deraadt
* rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andderaadt2009-10-271-8/+1
| | | | | | | unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
* tie IPKTS/OPKTS to bottom corner for smaller screensderaadt2009-08-141-10/+6
|
* there are louder and louder moans about the inability to see packetderaadt2009-08-131-2/+14
| | | | | | rates at the same time as interrupt counts, so sneak them into the bottom corner of the vmstat screen ok dlg
* Hinge at the natural rollover point 9999x instead of 1024x when switching todrahn2009-05-031-4/+4
| | | | the next unit K->M->G. ok deraadt@
* allow the disk transfer speed numbers to show useable numbers when disksderaadt2009-03-301-4/+30
| | | | get really fast; ok canacar
* Warning cleanup including unused variables and shadowed namescanacar2008-12-071-28/+28
|
* Improve reporting of cache misses in the vmstat view. Previouslycanacar2008-11-011-4/+4
| | | | | | | | the misses field may report negative values. The hit/miss numbers does not exactly reflect the statistics collected by the kernel but this is close enough. Report & patch from Bjorn Anderss, input from beck@ and thib@
* compile on older gcc; no decl after codederaadt2008-06-131-4/+3
|
* New display engine for systat, based on pftop. Adds new views for pfcanacar2008-06-121-38/+81
| | | | | | | | (status, state, rule, queue). While all displays work, some keyboard comands are not implemented yet. Other features include better handling of display resize and scrolling for long views. Committing now to fix the remaining issues in the tree. Testing and comments by otto@ and harding@, ok deraadt@
* malloc(n * m) -> calloc(n, m); from zinovikderaadt2007-09-011-3/+3
|
* use the 1 line load line from 'systat vm' on all the other displays, givingderaadt2007-02-251-48/+11
| | | | them more room. much cleaner, and it is less code too; ok deanna
* fix macro abuse leading to stray numbers in the vm display.otto2006-11-131-4/+6
| | | | ok a whole lot of devs@
* remove comments that says we dont count intr time and remove some code thatdlg2006-04-141-15/+2
| | | | | fudges the output to stay clean when intr time wasnt shown. not needed since we show it now.
* show cpu time spent in interrupts. ive been wanting this for years.dlg2006-04-141-11/+7
| | | | tweaks by deraadt@ ok by many
* spacingderaadt2006-03-311-3/+3
|
* fairly simple cleanup, lots of testing donederaadt2006-03-311-8/+8
|
* give more space to the memory columns in vm page; deraadt@ okmickey2006-03-281-11/+11
|
* - when we run out of static kernel map entries, grab a fresh page usingpedro2005-09-281-3/+7
| | | | | | | | the uvm_km_page allocator and use it instead of calling panic() - add a counter to uvmexp so we can keep track of how many map entries we have in use idea from tedu@, long ago, okay deraadt@
* nlist.h not neededderaadt2005-04-041-3/+2
|
* adapt to KERN_INTRCNT_CNT returning a quad, from danh (imported now toderaadt2004-09-231-13/+39
| | | | avoid tree breakage)
* remove post-mortem stuff (sysctl only here)deraadt2004-07-091-25/+2
|
* Remove special #if defined(__i386__) code from systat and vmstat. We now useaaron2004-06-281-140/+50
| | | | | | sysctl to fetch interrupt counters on all architectures. Also add new '-z' flag to vmstat which means show all devices, even those that have not yet generated an interrupt. deraadt@ tholo@ drahn@ millert@ ok
* divide etime by ncpuderaadt2004-06-111-3/+13
|
* oopsderaadt2004-06-111-4/+4
|
* on i386 machines, attempt to peek inside apic_intrhand[] as well, so thatderaadt2004-06-111-2/+48
| | | | | MP machines get interrupt counters. will be replaced by a MI subsystem one day. most code from drahn, few final bugs fixed by me
* with modern disks data transfers rates above 10000 kByte/s are seenhenning2004-05-221-4/+4
| | | | | regularily, make the disk columns a little wider so it doesn't run into the neighboring column, theo ok
* don't print stats until they're stable, prevents seeing weird stuff intedu2004-04-231-4/+9
| | | | disk columns. tested by jolan@. from pedro martelletto
* 'split' command for iostat modetedu2004-02-151-3/+3
| | | | from Pedro Martelletto <pbastos@rdc.puc-rio.br>
* new arg to disk_unbusy, to record separate read/write statistics.tedu2004-02-151-4/+6
| | | | | looked at by various, testing henning@ mcbride@ dan weeks mostly from netbsd via Pedro Martelletto <pbastos@rdc.puc-rio.br>
* duhmickey2003-10-161-3/+3
|
* also print the uvmexp.zeropages if there is space in vm screenmickey2003-10-151-2/+6
|
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-031-7/+3
| | | | rescinded 22 July 1999. Proofed by myself and Theo.