summaryrefslogtreecommitdiff
path: root/sys/kern/subr_devstat.c
Commit message (Collapse)AuthorAgeFilesLines
* Use NULL in preference to 0 in pointer contexts.Warner Losh2009-02-031-3/+3
| | | | Notes: svn path=/head/; revision=188063
* - Remove two mtx_asserts that can incorrectly trigger ifJeff Roberson2005-05-031-4/+0
| | | | | | | | | | | devstat_end_transaction is called from a fast interrupt. Presently there is no way for mtx_assert to determine that we're not executing in a real thread context. Submitted by: jhusted@isilon.com Notes: svn path=/head/; revision=145823
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139804
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-1/+1
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* Device megapatch 4/6:Poul-Henning Kamp2004-02-211-0/+2
| | | | | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags. Notes: svn path=/head/; revision=126080
* The present defaults for the open and close for device drivers whichPoul-Henning Kamp2003-09-271-2/+0
| | | | | | | | | | | | | | | | | provide no methods does not make any sense, and is not used by any driver. It is a pretty hard to come up with even a theoretical concept of a device driver which would always fail open and close with ENODEV. Change the defaults to be nullopen() and nullclose() which simply does nothing. Remove explicit initializations to these from the drivers which already used them. Notes: svn path=/head/; revision=120506
* It is not an error to have no devices in the kernel: Return thePoul-Henning Kamp2003-08-171-4/+4
| | | | | | | generation number and start it from one instead of zero. Notes: svn path=/head/; revision=119028
* Use __FBSDID().David E. O'Brien2003-06-111-2/+3
| | | | Notes: svn path=/head/; revision=116182
* Unbreak vinum, iostat and systat on sparc64 by changing the devstatHartmut Brandt2003-04-171-3/+3
| | | | | | | | | | generation number back to a long (sizeof(u_int) != sizeof(long) on sparc64). The alternative would have been to heavily change the libdevstat API. Discussed with: phk, ken Notes: svn path=/head/; revision=113599
* - Add vm_paddr_t, a physical address type. This is required for systemsJake Burkholder2003-03-251-1/+1
| | | | | | | | | | | | | | | | | | where physical addresses larger than virtual addresses, such as i386s with PAE. - Use this to represent physical addresses in the MI vm system and in the i386 pmap code. This also changes the paddr parameter to d_mmap_t. - Fix printf formats to handle physical addresses >4G in the i386 memory detection code, and due to kvtop returning vm_paddr_t instead of u_long. Note that this is a name change only; vm_paddr_t is still the same as vm_offset_t on all currently supported platforms. Sponsored by: DARPA, Network Associates Laboratories Discussed with: re, phk (cdevsw change) Notes: svn path=/head/; revision=112569
* long != int. Use SYSCTL_UINT for kern.devstat.generation. Fixes bootingJake Burkholder2003-03-181-1/+1
| | | | | | | on sparc64. Notes: svn path=/head/; revision=112388
* If devstat_new_entry() is passed a unit number of -1 assume thatPoul-Henning Kamp2003-03-181-4/+12
| | | | | | | | | | | | | | | | | | the devstat is for an "interior" GEOM node and register using the name argument as a geom identity pointer. Do not put these devstat structures on the list returned by the sysctl. This gives us the ability to tell the two kinds of nodes apart and leave the current "strictly physical" view of devstat intact without modifications, yet be able to use devstat for both kinds of devices. It also saves us bloating struct devstat with another 48 bytes of space for the name. At least for now. Reviewed by: ken Notes: svn path=/head/; revision=112369
* Make devstat fully Giant agnostic:Poul-Henning Kamp2003-03-181-42/+135
| | | | | | | | | | | | | | | | | | | | | | | | Add a mutex and protect the allocation and traversal of the list with it. When we allocate a page for devstat use we drop the mutex and use M_WAITOK this is not nice, but under the given circumstances the best we can do. In the sysctl handler for returning the devstat entries we do not want to hold the mutex across copyout(9) calls, so we keep a very careful eye on the devstat_generation count, and abandon with EBUSY if it changes under our feet. Specifically test for BIO_WRITE, rather than default non-read,non-deletes as write. Make the default be DEVSTAT_NO_DATA. Add atomic increments of the sequence[01] fields so applications using the mmap'ed view stand a chance of detecting updates in progress. Reviewed by: ken Notes: svn path=/head/; revision=112368
* Make devstat_new_entry() take a const void * rather than const char *Poul-Henning Kamp2003-03-181-5/+5
| | | | | | | argument, GEOM nodes are not identified by ascii string. Notes: svn path=/head/; revision=112365
* Add a #define for the device name of the mmap device for devstat.Poul-Henning Kamp2003-03-161-1/+1
| | | | | | | Constify the geom identification pointer. Notes: svn path=/head/; revision=112326
* One devstat_start_transaction_bio() is enough.Poul-Henning Kamp2003-03-151-7/+0
| | | | Notes: svn path=/head/; revision=112292
* Run a revision of the devstat interface:Poul-Henning Kamp2003-03-151-40/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=112288
* Add a devstat_start_transaction_bio() to match thePoul-Henning Kamp2003-03-151-0/+7
| | | | | | | | | | devstat_end_transaction_bio() we already have. For now it just calls devstat_start_transaction(), but that will change shortly. Notes: svn path=/head/; revision=112258
* Note that MAJOR_AUTO is now the default if d_maj is not initialized. ThisPoul-Henning Kamp2003-03-091-1/+0
| | | | | | | | | | | is more robust and prevents the hijacking of /dev/console for the typical mistake. Remove unneeded MAJOR_AUTO uses, it is only needed explicitly now if the driver source has cross-branch compatibility to old releases. Notes: svn path=/head/; revision=112037
* Retire devstat_add_entry() as a public function and bump __FreeBSD_versionPoul-Henning Kamp2003-03-081-1/+6
| | | | | | | to mark this act. Notes: svn path=/head/; revision=112007
* Introduce a device driver for /dev/devstat, this will allow us to mmapPoul-Henning Kamp2003-03-081-0/+112
| | | | | | | | | | the device statistics structures into userland instead of using sysctl. Introduce new devstat_new_entry() function which allocates the devstat structure an calls devstat_add_entry() on it. Notes: svn path=/head/; revision=112001
* Use strlcpy() instead of strncpy() to copy NUL terminated stringsRobert Drehmel2002-10-171-2/+1
| | | | | | | for safety and consistency. Notes: svn path=/head/; revision=105354
* GC: BIO_ORDERED, various infrastructure dealing with BIO_ORDERED.Poul-Henning Kamp2002-02-221-2/+1
| | | | Notes: svn path=/head/; revision=91063
* Export the head structure for the device statistics STAILQ inThomas Moestl2001-08-041-1/+1
| | | | | | | | sys/devicestat.h, so that the queue can be walked in crashdumps using libkvm. Notes: svn path=/head/; revision=81129
* Another round of the <sys/queue.h> FOREACH transmogriffer.Poul-Henning Kamp2001-02-041-2/+1
| | | | | | | | Created with: sed(1) Reviewed by: md5(1) Notes: svn path=/head/; revision=72012
* Support for unsigned integer and long sysctl variables. Update theJohn Baldwin2000-07-051-1/+1
| | | | | | | | | | | | SYSCTL_LONG macro to be consistent with other integer sysctl variables and require an initial value instead of assuming 0. Update several sysctl variables to use the unsigned types. PR: 15251 Submitted by: Kelly Yancey <kbyanc@posi.net> Notes: svn path=/head/; revision=62622
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.Poul-Henning Kamp2000-07-041-1/+1
| | | | | | | Pointed out by: bde Notes: svn path=/head/; revision=62573
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:Poul-Henning Kamp2000-07-031-1/+1
| | | | | | | | | | | Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our sources: -sysctl_vm_zone SYSCTL_HANDLER_ARGS +sysctl_vm_zone (SYSCTL_HANDLER_ARGS) Notes: svn path=/head/; revision=62454
* Back out the previous change to the queue(3) interface.Jake Burkholder2000-05-261-2/+2
| | | | | | | | | It was not discussed and should probably not happen. Requested by: msmith and others Notes: svn path=/head/; revision=60938
* Change the way that the queue(3) structures are declared; don't assume thatJake Burkholder2000-05-231-2/+2
| | | | | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd Notes: svn path=/head/; revision=60833
* Remove devstat_end_transaction_buf() everybody usesPoul-Henning Kamp2000-05-061-18/+0
| | | | | | | devstat_end_transaction_bio() now. Notes: svn path=/head/; revision=60072
* Separate the struct bio related stuff out of <sys/buf.h> intoPoul-Henning Kamp2000-05-051-0/+1
| | | | | | | | | | | | | | | | | | <sys/bio.h>. <sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall not be made a nested include according to bdes teachings on the subject of nested includes. Diskdrivers and similar stuff below specfs::strategy() should no longer need to include <sys/buf.> unless they need caching of data. Still a few bogus uses of struct buf to track down. Repocopy by: peter Notes: svn path=/head/; revision=60041
* Clone bio versions of certain bits of infrastructure:Poul-Henning Kamp2000-04-021-0/+17
| | | | | | | | | | | | | | | | devstat_end_transaction_bio() bioq_* versions of bufq_* incl bioqdisksort() the corresponding "buf" versions will disappear when no longer used. Move b_offset, b_data and b_bcount to struct bio. Add BIO_FORMAT as a hack for fd.c etc. We are now largely ready to start converting drivers to use struct bio instead of struct buf. Notes: svn path=/head/; revision=58942
* Move B_ERROR flag to b_ioflags and call it BIO_ERROR.Poul-Henning Kamp2000-04-021-1/+1
| | | | | | | | | | | | | | | | (Much of this done by script) Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED. Move b_pblkno and b_iodone_chain to struct bio while we transition, they will be obsoleted once bio structs chain/stack. Add bio_queue field for struct bio aware disksort. Address a lot of stylistic issues brought up by bde. Notes: svn path=/head/; revision=58934
* Remove B_READ, B_WRITE and B_FREEBUF and replace them with a newPoul-Henning Kamp2000-03-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | field in struct buf: b_iocmd. The b_iocmd is enforced to have exactly one bit set. B_WRITE was bogusly defined as zero giving rise to obvious coding mistakes. Also eliminate the redundant struct buf flag B_CALL, it can just as efficiently be done by comparing b_iodone to NULL. Should you get a panic or drop into the debugger, complaining about "b_iocmd", don't continue. It is likely to write on your disk where it should have been reading. This change is a step in the direction towards a stackable BIO capability. A lot of this patch were machine generated (Thanks to style(9) compliance!) Vinum users: Greg has not had time to test this yet, be careful. Notes: svn path=/head/; revision=58345
* This is a partial commit of the patch from PR 14914:Poul-Henning Kamp1999-11-161-2/+2
| | | | | | | | | | | | | | | | Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY structures for list operations. This patch makes all list operations in sys/kern use the queue(3) macros, rather than directly accessing the *Q_{HEAD,ENTRY} structures. This batch of changes compile to the same object files. Reviewed by: phk Submitted by: Jake Burkholder <jake@checker.org> PR: 14914 Notes: svn path=/head/; revision=53212
* Removed unnecessary splclock() protection for getmicrotime() andBruce Evans1999-10-021-16/+1
| | | | | | | | | | | getmicrouptime(). Removed unused includes. Reviewed by: ken Notes: svn path=/head/; revision=51856
* Stylistic cleanup.Poul-Henning Kamp1999-09-221-5/+3
| | | | | | | Submitted by: ken. Notes: svn path=/head/; revision=51559
* Move an end-paren to its intended place.Poul-Henning Kamp1999-09-191-1/+1
| | | | Notes: svn path=/head/; revision=51397
* Count "free" operations in their own new tranaction type.Poul-Henning Kamp1999-09-181-1/+25
| | | | | | | | | | WARNING: libdevstat, iostat, vmstat, systat etc etc will need a recompile. Add devstat_end_transaction_buf() which pulls all the vital data out of a struct buf which is ready for biodone(). Notes: svn path=/head/; revision=51375
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Add sysctl descriptions to many SYSCTL_XXXsBill Fumerola1999-05-031-7/+7
| | | | | | | | | | PR: kern/11197 Submitted by: Adrian Chadd <adrian@FreeBSD.org> Reviewed by: billf(spelling/style/minor nits) Looked at by: bde(style) Notes: svn path=/head/; revision=46381
* Staticize.Eivind Eklund1999-04-111-2/+2
| | | | Notes: svn path=/head/; revision=45569
* Add a prioritization field to the devstat_add_entry() call so thatKenneth D. Merry1999-02-101-5/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=43819
* Fix some 64bit truncation problems which crept into SYSCTL_LONG() with theDoug Rabson1998-12-271-2/+2
| | | | | | | | | | | last cleanup. Since the oid_arg2 field of struct sysctl_oid is not wide enough to hold a long, the SYSCTL_LONG() macro has been modified to only support exporting long variables by pointer instead of by value. Reviewed by: bde Notes: svn path=/head/; revision=42095
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()Archie Cobbs1998-12-041-1/+2
| | | | | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com> Notes: svn path=/head/; revision=41514
* Now that the wd driver is fixed (Thanks Bruce!), re-enable theKenneth D. Merry1998-11-151-10/+2
| | | | | | | | | | devstat_end_transaction error message that gets printed whenever the busy count is < 0. This will help catch drivers that improperly implement devstat(9) support. Notes: svn path=/head/; revision=41193
* My changes to the new device interface:Garrett Wollman1998-11-141-2/+2
| | | | | | | | | | | | | | | | | - Interface wth the new resource manager. - Allow for multiple drivers implementing a single devclass. - Remove ordering dependencies between header files. - Style cleanup. - Add DEVICE_SUSPEND and DEVICE_RESUME methods. - Move to a single-phase interrupt setup scheme. Kernel builds on the Alpha are brken until Doug gets a chance to incorporate these changes on that side. Agreed to in principle by: dfr Notes: svn path=/head/; revision=41153
* Disable the 'devstat_end_transaction' busy count printf until after 3.0Kenneth D. Merry1998-10-141-2/+10
| | | | | | | | | | | | | release goes out the door. We know there's a bug in the devstat implementation in the wd driver, but bde and msmith haven't been able to fix it yet. So, disable the printf to avoid confusing/worrying people. Suggested by: msmith Notes: svn path=/head/; revision=40359
* Make the printf when busy_time < 0 a little more descriptive. This mayKenneth D. Merry1998-10-061-2/+4
| | | | | | | | | | | help track down bugs in the devstat implementation in various drivers. (i.e., any situation where the driver does not call the devstat routines once and only once for each transaction initiation and completion) Prompted by: msmith Notes: svn path=/head/; revision=39985