summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_devstat.c
Commit message (Collapse)AuthorAgeFilesLines
* Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.rnoland2009-12-291-1/+2
| | | | | | | | | | | | | This replaces d_mmap() with the d_mmap2() implementation and also changes the type of offset to vm_ooffset_t. Purge d_mmap2(). All driver modules will need to be rebuilt since D_VERSION is also bumped. Reviewed by: jhb@ MFC after: Not in this lifetime...
* Don't allocate new unnecessary pages when devstat_alloc() looses theattilio2009-09-181-16/+27
| | | | | | | | run for re-acuiring the lock, but recheck if new pages are allocatable from the pool and free the previously allocated ones. Tested by: pho, Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
* Use NULL in preference to 0 in pointer contexts.imp2009-02-031-3/+3
|
* - Remove two mtx_asserts that can incorrectly trigger ifjeff2005-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
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Do the dreaded s/dev_t/struct cdev */phk2004-06-161-1/+1
| | | | Bump __FreeBSD_version accordingly.
* Device megapatch 4/6:phk2004-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.
* The present defaults for the open and close for device drivers whichphk2003-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.
* It is not an error to have no devices in the kernel: Return thephk2003-08-171-4/+4
| | | | generation number and start it from one instead of zero.
* Use __FBSDID().obrien2003-06-111-2/+3
|
* Unbreak vinum, iostat and systat on sparc64 by changing the devstatharti2003-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
* - Add vm_paddr_t, a physical address type. This is required for systemsjake2003-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)
* long != int. Use SYSCTL_UINT for kern.devstat.generation. Fixes bootingjake2003-03-181-1/+1
| | | | on sparc64.
* If devstat_new_entry() is passed a unit number of -1 assume thatphk2003-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
* Make devstat fully Giant agnostic:phk2003-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
* Make devstat_new_entry() take a const void * rather than const char *phk2003-03-181-5/+5
| | | | argument, GEOM nodes are not identified by ascii string.
* Add a #define for the device name of the mmap device for devstat.phk2003-03-161-1/+1
| | | | Constify the geom identification pointer.
* One devstat_start_transaction_bio() is enough.phk2003-03-151-7/+0
|
* Run a revision of the devstat interface:phk2003-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
* Add a devstat_start_transaction_bio() to match thephk2003-03-151-0/+7
| | | | | | | devstat_end_transaction_bio() we already have. For now it just calls devstat_start_transaction(), but that will change shortly.
* Note that MAJOR_AUTO is now the default if d_maj is not initialized. Thisphk2003-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.
* Retire devstat_add_entry() as a public function and bump __FreeBSD_versionphk2003-03-081-1/+6
| | | | to mark this act.
* Introduce a device driver for /dev/devstat, this will allow us to mmapphk2003-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.
* Use strlcpy() instead of strncpy() to copy NUL terminated stringsrobert2002-10-171-2/+1
| | | | for safety and consistency.
* GC: BIO_ORDERED, various infrastructure dealing with BIO_ORDERED.phk2002-02-221-2/+1
|
* Export the head structure for the device statistics STAILQ intmm2001-08-041-1/+1
| | | | | sys/devicestat.h, so that the queue can be walked in crashdumps using libkvm.
* Another round of the <sys/queue.h> FOREACH transmogriffer.phk2001-02-041-2/+1
| | | | | Created with: sed(1) Reviewed by: md5(1)
* Support for unsigned integer and long sysctl variables. Update thejhb2000-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>
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.phk2000-07-041-1/+1
| | | | Pointed out by: bde
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:phk2000-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)
* Back out the previous change to the queue(3) interface.jake2000-05-261-2/+2
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-231-2/+2
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* Remove devstat_end_transaction_buf() everybody usesphk2000-05-061-18/+0
| | | | devstat_end_transaction_bio() now.
* Separate the struct bio related stuff out of <sys/buf.h> intophk2000-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
* Clone bio versions of certain bits of infrastructure:phk2000-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.
* Move B_ERROR flag to b_ioflags and call it BIO_ERROR.phk2000-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.
* Remove B_READ, B_WRITE and B_FREEBUF and replace them with a newphk2000-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.
* This is a partial commit of the patch from PR 14914:phk1999-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
* Removed unnecessary splclock() protection for getmicrotime() andbde1999-10-021-16/+1
| | | | | | | | getmicrouptime(). Removed unused includes. Reviewed by: ken
* Stylistic cleanup.phk1999-09-221-5/+3
| | | | Submitted by: ken.
* Move an end-paren to its intended place.phk1999-09-191-1/+1
|
* Count "free" operations in their own new tranaction type.phk1999-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().
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Add sysctl descriptions to many SYSCTL_XXXsbillf1999-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)
* Staticize.eivind1999-04-111-2/+2
|
* Add a prioritization field to the devstat_add_entry() call so thatken1999-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
* Fix some 64bit truncation problems which crept into SYSCTL_LONG() with thedfr1998-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
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()archie1998-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>
* Now that the wd driver is fixed (Thanks Bruce!), re-enable theken1998-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.
* My changes to the new device interface: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
OpenPOWER on IntegriCloud