Commit Graph

38662 Commits

Author SHA1 Message Date
Matthew N. Dodd
69ed274634 - Style(9) changes.
- Remove unneeded assignment.
- Increment if_oerrors as per if_fddisubr.c.
- Wrap ISO code with conditional.
2003-03-15 22:37:11 +00:00
Matthew N. Dodd
94b3e4d32f Stray } forgotten by manual merging. 2003-03-15 22:28:51 +00:00
Matthew N. Dodd
bd3e6bb8b8 - Remove stray ).
- Add missing breaks.
- Add missing if_noproto++.
2003-03-15 22:25:06 +00:00
Poul-Henning Kamp
d15cd51001 One devstat_start_transaction_bio() is enough. 2003-03-15 22:20:38 +00:00
Matthew N. Dodd
0e96758da8 Revert part of 1.37; use bcopy() like if_fddisubr.c. 2003-03-15 22:09:29 +00:00
Matthew N. Dodd
2910fe6d37 - Increment ifp->if_noproto when appropriate.
- Use 'goto dropanyway' when appropriate.
- Move dropanyway label out of switch for readability.
2003-03-15 21:59:11 +00:00
Poul-Henning Kamp
7194d335cf 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
2003-03-15 21:59:06 +00:00
Matthew N. Dodd
0c61d694a8 Update interface statistics after MAC and IFF_UP|IFF_RUNNING checks. 2003-03-15 21:51:39 +00:00
Matthew N. Dodd
f156dd7b68 - Adopt tests for (IFF_UP|IFF_RUNNING) and non local unicast packets
in promiscuous mode from if_fddisubr.c.
- Add comment to reduce diffs.
2003-03-15 21:42:19 +00:00
Matthew N. Dodd
9a3c9f3971 Add MAC support.
This is the same code that was added in 1.70 of if_fddisubr.c
2003-03-15 21:30:00 +00:00
Matthew N. Dodd
15eccea260 Use llc_control rather than llc_snap.control. 2003-03-15 20:35:19 +00:00
Matthew N. Dodd
ad20d0f577 - Add comment.
- Whitespace fixes.
2003-03-15 20:33:30 +00:00
Matthew N. Dodd
06f684b004 Reduce code differences. 2003-03-15 19:37:44 +00:00
Matthew N. Dodd
a93a116153 Use ISO88025_ADDR_LEN where appropriate. 2003-03-15 19:25:00 +00:00
Matthew N. Dodd
dbd05f2e56 Don't use etherbroadcastaddr; use iso88025_broadcastaddr. 2003-03-15 19:16:39 +00:00
Matthew N. Dodd
fd87fbf6b8 - Remove definition of senderr() from iso88025.h.
- Use definition of senderr() from if_ethersubr.c.
2003-03-15 19:10:19 +00:00
Maxim Sobolev
71fbba351a Remove duplicate line introduced in the previous commit.
Submitted by:	bde
MFC after:	2 weeks
2003-03-15 18:49:41 +00:00
Matthew N. Dodd
386dca02cb Some whitespace/style/readability changes. 2003-03-15 17:54:49 +00:00
Matthew N. Dodd
7c16bd3a8b Add iso88025_resolvemulti().
Cribbed from net/if_fddisubr.c
2003-03-15 16:49:08 +00:00
Matthew N. Dodd
bf54cb290a Fix formatting of iso88025_ifattach(). 2003-03-15 16:41:35 +00:00
Matthew N. Dodd
fe7e109c6f Re-order and prune includes. 2003-03-15 16:37:28 +00:00
Maxim Sobolev
084254f807 - Add minimal support for TI16754 4xUART chip into sio(4) driver and remove
now unnecessary hack from the previous commit;
- Add support for Interrupt Latch Register (ILR) into puc(4). So far only
  ILRs compatible with specifications from Digi International are supported.
  Support for other types of ILRs could be easily added later;
- Correct clock frequency for IC Book Labs Dreadnought x16 Lite board;
- Enable ILR detection/usage for IC Book Labs Dreadnought x16 boards.

Sponsored by:   IC Book Labs
MFC after:      2 weeks
2003-03-15 16:25:40 +00:00
Matthew N. Dodd
40811c1473 Add module data and version. 2003-03-15 15:38:02 +00:00
Matthew N. Dodd
4fd80d5b9d s/llc_un.type_snap/llc_snap/g 2003-03-15 15:35:25 +00:00
Matthew N. Dodd
67df65de97 Formatting and whitespace changes. 2003-03-15 15:09:11 +00:00
Takanori Watanabe
869c12cbb4 Add module dependency. This makes udbp.ko to be loaded. 2003-03-15 13:03:30 +00:00
Poul-Henning Kamp
fe002e7546 Fix a bug I introduced by overlooking the fact that "unit number" can
be one of several things in this driver.

Spotted & Tested by:	alfred
2003-03-15 12:16:33 +00:00
Poul-Henning Kamp
0be3115328 Don't use the devstat->busy_count for state decisions in the device
drivers.  Doing so imposes atomicity and locking constraints on the
devstat API.

By:	ken
2003-03-15 11:00:56 +00:00
Poul-Henning Kamp
09a6b2aad6 Call devstat_start_transaction_bio() instead of devstat_start_transaction(). 2003-03-15 10:56:19 +00:00
Poul-Henning Kamp
1ecc485c1b Call devstat_start_transaction_bio() instead of devstat_start_transaction() 2003-03-15 10:50:44 +00:00
Poul-Henning Kamp
81876757ec Use devstat_{start,end}_transaction_bio().
Remember to set bio_resid correctly first.
2003-03-15 10:49:26 +00:00
Poul-Henning Kamp
9fa85de269 Add a devstat_start_transaction_bio() to match the
devstat_end_transaction_bio() we already have.

For now it just calls devstat_start_transaction(), but that will change
shortly.
2003-03-15 10:33:32 +00:00
Crist J. Clark
010dabb047 Add a 'verrevpath' option that verifies the interface that a packet
comes in on is the same interface that we would route out of to get to
the packet's source address. Essentially automates an anti-spoofing
check using the information in the routing table.

Experimental. The usage and rule format for the feature may still be
subject to change.
2003-03-15 01:13:00 +00:00
Mike Barcroft
13141dbc38 Add missing types, update standard namespaces, and use variable types
that don't require <sys/types.h>.
2003-03-14 16:09:48 +00:00
Maxime Henrion
40b63da2a9 Bah, get it right this time and add sys/lock.h before sys/mutex.h. 2003-03-14 13:30:31 +00:00
Jake Burkholder
7b66da6e32 lock.h must be included before mutex.h. 2003-03-14 07:19:29 +00:00
Jeff Roberson
8501ead911 - Add a forgotten BUF_LOCK()
Most sincere apologies to:	jake
2003-03-14 05:13:19 +00:00
David Xu
9a4b78c9da Export current time when returning from never blocked syscall. 2003-03-14 03:52:16 +00:00
Maxime Henrion
7541142438 Oops, add missing includes. Pass me the pointy hat.
Reported by:	jake
2003-03-14 00:04:37 +00:00
John Baldwin
2d055ab20f Trim some trailing whitespace. 2003-03-13 23:07:09 +00:00
Scott Long
6f420b1756 Now that bus_dmamem_alloc() handles its Giant mutex requirements itself,
don't bother doing the same in the code that calls it.
2003-03-13 22:56:11 +00:00
John Baldwin
b62f75cf44 - Change the linux_[gs]et_os{name, release, s_version}() functions to
take a thread instead of a proc for their first argument.
- Add a mutex to protect the system-wide Linux osname, osrelease, and
  oss_version variables.
- Change linux_get_prison() to take a thread instead of a proc for its
  first argument and to use td_ucred rather than p_ucred.  This is ok
  because a thread's prison does not change even though it's ucred might.
- Also, change linux_get_prison() to return a struct prison * instead of
  a struct linux_prison * since it returns with the struct prison locked
  and this makes it easier to safely unlock the prison when we are done
  messing with it.
2003-03-13 22:45:43 +00:00
John Baldwin
75768576cc Add a new userland-visible ktrace flag KTR_DROP and an internal ktrace flag
KTRFAC_DROP to track instances when ktrace events are dropped due to the
request pool being exhausted.  When a thread tries to post a ktrace event
and is unable to due to no available ktrace request objects, it sets
KTRFAC_DROP in its process' p_traceflag field.  The next trace event to
successfully post from that process will set the KTR_DROP flag in the
header of the request going out and clear KTRFAC_DROP.

The KTR_DROP flag is the high bit in the type field of the ktr_header
structure.  Older kdump binaries will simply complain about an unknown type
when seeing an entry with KTR_DROP set.  Note that KTR_DROP being set on a
record in a ktrace file does not tell you anything except that at least one
event from this process was dropped prior to this event.  The user has no
way of knowing what types of events were dropped nor how many were dropped.

Requested by:	phk
2003-03-13 18:31:15 +00:00
John Baldwin
a5881ea55a - Cache a reference to the credential of the thread that starts a ktrace in
struct proc as p_tracecred alongside the current cache of the vnode in
  p_tracep.  This credential is then used for all later ktrace operations on
  this file rather than using the credential of the current thread at the
  time of each ktrace event.
- Now that we have multiple ktrace-related items in struct proc that are
  pointers, rename p_tracep to p_tracevp to make it less ambiguous.

Requested by:	rwatson (1)
2003-03-13 18:24:22 +00:00
Maxime Henrion
c0796d1cb4 Grab Giant around calls to contigmalloc() and contigfree() so
that drivers converted to be MP safe don't have to deal with it.
2003-03-13 17:18:48 +00:00
Maxime Henrion
ea458bbcdb Memory allocated with contigmalloc() should be freed with
contigfree(), not with free().
2003-03-13 17:10:54 +00:00
Hartmut Brandt
57648f8aae This corrects a longstanding endian bug in processing LLC/SNAP encoded
frames. A comment in if_atm.h suggests that both macros, that for extracting
the ethertype and that for inserting it, handle their argument in host
byte order. In fact, the inserting macro treated its argument as an opposite
host order short and the calling code feeds it the result of htons(). This
happens to work on i386, but fails on sparc. Make the macro use real host
endianess.

Reviewed by:	kjc, atm@
2003-03-13 12:44:06 +00:00
Jeffrey Hsu
7792ea2700 Greatly simplify the unlocking logic by holding the TCP protocol lock until
after FIN_WAIT_2 processing.

Helped with debugging:	Doug Barton
2003-03-13 11:46:57 +00:00
Søren Schmidt
f711eff1d2 Remove the check for more than one open if one is a write op.
This allows using DVD+RW and DVD-RW as random storage, provided
the 32K blocksize is honoured for DVD-RW (DVD+RW has built in
read-modify-write).
2003-03-13 09:12:17 +00:00
Søren Schmidt
6918962fad Dont free the stats struct, this has been changed by the new stat code.
Spotted by: Ian Dowse <iedowse@maths.tcd.ie>
2003-03-13 09:09:10 +00:00
Søren Schmidt
394046e66f Dont call dma->free unless dma is there.
Spotted by: Ian Dowse <iedowse@maths.tcd.ie>
2003-03-13 09:04:55 +00:00
Ian Dowse
a80cc4e104 In m_dup_pkthdr(), convert the supplied `how' argument into malloc
flags when passing it into m_tag_copy_chain(), as m_tag* functions
use malloc, not mbuf flags.
2003-03-13 09:02:19 +00:00
Søren Schmidt
64eca1e1f2 Add pci id# for the sis648 2003-03-13 07:55:53 +00:00
Jeff Roberson
749ffa4ecd - Add a lock for protecting against msleep(bp, ...) wakeup(bp) races.
- Create a new function bdone() which sets B_DONE and calls wakup(bp). This
   is suitable for use as b_iodone for buf consumers who are not going
   through the buf cache.
 - Create a new function bwait() which waits for the buf to be done at a set
   priority and with a specific wmesg.
 - Replace several cases where the above functionality was implemented
   without locking with the new functions.
2003-03-13 07:31:45 +00:00
Jeff Roberson
e99215a614 - Remove a dead check for bp->b_vp == vp in vtruncbuf(). This has not been
possible for some time.
 - Lock the buf before accessing fields.  This should very rarely be locked.
 - Assert that B_DELWRI is set after we acquire the buf.  This should always
   be the case now.
2003-03-13 07:22:53 +00:00
Jeff Roberson
09f11da5a3 - Remove a race between fsync like functions and flushbufqueues() by
requiring locked bufs in vfs_bio_awrite().  Previously the buf could
   have been written out by fsync before we acquired the buf lock if it
   weren't for giant.  The cluster_wbuild() handles this race properly but
   the single write at the end of vfs_bio_awrite() would not.
 - Modify flushbufqueues() so there is only one copy of the loop.  Pass a
   parameter in that says whether or not we should sync bufs with deps.
 - Call flushbufqueues() a second time and then break if we couldn't find
   any bufs without deps.
2003-03-13 07:19:23 +00:00
Jeff Roberson
f5f0dee483 - Lock the buf before clearing flags. 2003-03-13 07:07:16 +00:00
Jeff Roberson
c033bdc013 - Lock bufs before inspecting their flags. 2003-03-13 07:05:22 +00:00
Jeff Roberson
619bddc702 - Lock the buf before inspecting its contents. 2003-03-13 07:04:11 +00:00
Alfred Perlstein
569d3c4bf0 Make sure we actually have a dev before dereferencing in case someone
botches and sends us a NULL pointer.  The other code in this file seems
to expect it to be able to handle it behaving this way.
2003-03-13 06:29:44 +00:00
Jeff Roberson
de950c003c - Tune down read_max. For single disks we get no gain out of reading more
than a MAXPHYS size block ahead.  Having this set too high just leaves
   other processes starved for IO and screws up interactive response.  Let the
   users with RAID set it higher when they need it.
2003-03-13 06:17:59 +00:00
Jeffrey Hsu
da3a8a1a4f Add support for RFC 3390, which allows for a variable-sized
initial congestion window.
2003-03-13 01:43:45 +00:00
Tim J. Robbins
6ec62361c8 Tidy up previous change: move comment about obtaining an exclusive
reference where it belongs, and remove a blank line to make it more
obvious what the comment applies to.
2003-03-13 00:57:47 +00:00
Tim J. Robbins
262c27b846 Back out previous. The locking here needs a rethink. 2003-03-13 00:54:53 +00:00
Maxime Henrion
f3b8b63b15 Pass the correct malloc flags to m_tag_alloc(). 2003-03-13 00:30:31 +00:00
David Schultz
72d97679ff - When the VM daemon is out of swap space and looking for a
process to kill, don't block on a map lock while holding the
  process lock.  Instead, skip processes whose map locks are held
  and find something else to kill.
- Add vm_map_trylock_read() to support the above.

Reviewed by:	alc, mike (mentor)
2003-03-12 23:13:16 +00:00
Jeffrey Hsu
582a954b00 Implement the Limited Transmit algorithm (RFC 3042). 2003-03-12 20:27:28 +00:00
John Baldwin
8510f2a833 - Various little style fixes.
- If SYSCTL_OUT() fails in sysctl_kern_proc_args(), return the error
  instead of ignoring it if we have new arguments for the process.
- If the new arguments for a process are too long, return ENOMEM instead of
  returning success but not doing the actual copy.

Submitted by:	bde
2003-03-12 20:17:40 +00:00
Maxim Sobolev
525e5ed929 Correct clock frequency for the IC Book Labs' cards, so that it's possible
to use speeds higher than 115200.

Sponsored by:	IC Book Labs
MFC after:	2 weeks
2003-03-12 17:56:03 +00:00
Maxim Sobolev
a2a101e766 Add initial support for IC Book Labs Dreadnought x16 Pro 16-ports card. Since
this card is based on 16750 UART, modify sio(4) a bit to ignore 16750-specific
7th bit of MCR when probing card. This allows card to be detected and attached
as 16550A-compatible device. More work needs to be done in order to enable
nice 16750-specific features such as larger fifo buffer and higher speeds.

Sponsored by:	IC Book Labs
MFC after:	2 weeks
2003-03-12 17:20:24 +00:00
John Baldwin
4bc6471b53 - Avoid dropping the proc lock around a simple permissions check and just
hold hold it across the check to avoid extra lock operations in the
  common case.
- Copy in the new args to a temporary pargs structure before we drop the
  reference to the old one.  Thus, if the copyin() fails, the process
  arguments are unchanged rather than being deleted.  Also, p_args is no
  longer NULL during the sysctl operation.
2003-03-12 16:14:55 +00:00
Søren Schmidt
deff57d72c Correct the last commit, only look for subfunctions on the same PCI slot. 2003-03-12 15:45:52 +00:00
Orion Hodson
b2a0f525e6 Correct CS4205 base vendor id.
Reported by:    Christophe Juniet and Mark Santcroos.
2003-03-12 15:11:25 +00:00
Sam Leffler
4a692a1fc2 correct two more flag misuses; m_tag* use malloc flags 2003-03-12 14:45:22 +00:00
Ruslan Ermilov
99bca5069e Simplify the assignment statement. 2003-03-12 14:32:46 +00:00
Søren Schmidt
5b24125046 Cleanup the probe code a bit. 2003-03-12 12:05:17 +00:00
Tim J. Robbins
a7cbe87a5e Acquire sched_lock around use of FOREACH_KSEGRP_IN_PROC, accesses
to kg_nice and calls to sched_nice() in getpriority() and setpriority()
(really donice()).
2003-03-12 11:24:41 +00:00
Tim J. Robbins
3890793e9c In wait1(), remove the zombie process from zombproc before removing
it from its pgrp to avoid leaving zombies around with p_pgrp == NULL.
This bug was apparent as a NULL-dereference in the pid selection code
in fork1().
2003-03-12 11:10:04 +00:00
Søren Schmidt
9eb8572ea2 Dont hang the channel on enclosures without sensors. 2003-03-12 10:59:35 +00:00
Hidetoshi Shimokawa
d067ce208d Put back including sys/devicestat.h for 4-stable. 2003-03-12 10:36:53 +00:00
Kenjiro Cho
fec4b7015e clean up the en driver since it will survice for a while by
Harti Brandt's effort.
remove the DMA test to detect problems of the first generation PCI chipsets
back in 1998.
it is no longer needed and has been the source of the false alarm that
the driver uses too much stack space.
2003-03-12 10:28:26 +00:00
Jake Burkholder
4d3f408cee - Added support for multiple page directory pages to pmap_pinit and
pmap_release.
- Merged pmap_release and pmap_release_free_page.  When pmap_release is
  called only the page directory page(s) can be left in the pmap pte object,
  since all page table pages will have been freed by pmap_remove_pages and
  pmap_remove.  In addition, there can only be one reference to the pmap and
  the page directory is wired, so the page(s) can never be busy.  So all there
  is to do is clear the magic mappings from the page directory and free the
  page(s).

Sponsored by:	DARPA, Network Associates Laboratories
2003-03-12 07:38:37 +00:00
Sam Leffler
9adc8e4d75 correct malloc flag argument
Reported by:	Kris Kennaway <kris@obsecurity.org>
2003-03-12 06:08:48 +00:00
Alexander Kabaev
46300030ec Do not depend on namespace pollution, explicitly include sys/sx.h 2003-03-12 02:55:20 +00:00
Sam Leffler
98822e3945 fix module building; drivers now require opt_{ubsec,hifn}.h 2003-03-11 23:20:43 +00:00
Sam Leffler
cff5befbba FIPS 140-2 rng data tester for h/w crypto devices. This driver periodically
monitors the entropy data harvested by crypto drivers to verify it complies
with FIPS 140-2.  If data fails any test then the driver discards it and
commences continuous testing of harvested data until it is deemed ok.
Results are collected in a statistics block and, optionally, reported on
the console.  In normal use the overhead associated with this driver is
not noticeable.

Note that drivers must (currently) be compiled specially to enable use.

Obtained from:	original code by Jason L. Wright
2003-03-11 22:54:44 +00:00
Sam Leffler
b7c4858f1e o add crypto driver glue for using the new rndtest driver/module; this is
conditional in each driver on foo_RNDTEST being defined_
o bring HIFN_DEBUG and UBSEC_DEBUG out to be visible options; they control
  the debugging printfs that are set with hw.foo.debug (e.g. hw.hifn.debug)
2003-03-11 22:47:06 +00:00
John Baldwin
2ca9461a05 Trim an extra blank line that snuck into the last commit. 2003-03-11 22:33:42 +00:00
Sam Leffler
bd17515b68 gack; revert previous commit; not only did I read things backward but
I was in the wrong tree
2003-03-11 22:23:19 +00:00
Sam Leffler
44cc7634a3 sync with current: reduce default maxbatch setting from 5 to 1
Reviewed by:	re (sort of, consider this part of my previous request)
2003-03-11 22:20:43 +00:00
Alexander Kabaev
c162e9c2eb Rename vfs_stdsync function to vfs_stdnosync which matches more
closely what function is really doing. Update all existing consumers
to use the new name.

Introduce a new vfs_stdsync function, which iterates over mount
point's vnodes and call FSYNC on each one of them in turn.

Make nwfs and smbfs use this new function instead of rolling their
own identical sync implementations.

Reviewed by:	jeff
2003-03-11 22:15:10 +00:00
John Baldwin
427b3a6549 - Change witness_displaydescendants() to accept the indentation level as
a parameter instead of using the level of a given witness.  When
  recursing, pass an indent level of indent + 1.
- Make use of the information witness_levelall() provides in
  witness_display_list() to use an O(n) algorithm instead of an O(n^2)
  algo to decide which witnesses to display hierarchies from.  Basically,
  we only display a hierarchy for witnesses with a level of 0.
- Add a new per-witness flag that is reset at the start of
  witness_display() for all witness's and is set the first time a witness
  is displayed in witness_displaydescendants().  If a witness is
  encountered more than once in the lock order tree (which happens often),
  witness_displaydescendants() marks the later occurrences with the string
  "(already displayed)" and doesn't display the subtree under that
  witness.  This avoids duplicating large amounts of the lock order tree
  in the 'show witness' output in DDB.

All these changes serve to make 'show witness' a lot more readable and
useful than it was previously.
2003-03-11 22:14:21 +00:00
John Baldwin
f82c6950be - Split the itismychild() function into two functions: insertchild()
adds a witness to the child list of a parent witness.  rebalancetree()
  runs through the entire tree removing direct descendants of witnesses
  who already have said child witness as an indirect descendant through
  another direct descendant.  itismychild() now calls insertchild()
  followed by rebalancetree() and no longer needs the evil hack of
  having static recursed variable.
- Add a function reparentchildren() that adds all the direct descendants
  of one witness as direct descendants of another witness.
- Change the return value of itismychild() and similar functions so that
  they return 0 in the case of failure due to lack of resources instead
  of 1.  This makes the return value more intuitive.
- Check the return value of itismychild() when defining the static lock
  order in witness_initialize().
- Don't try to setup a lock instance in witness_lock() if itismychild()
  fails.  Witness is hosed anyways so no need to do any more witness
  related activity at that point.  It also makes the code flow easier to
  understand.
- Add a new depart() function as the opposite of enroll().  When the
  reference count of a witness drops to 0 in witness_destroy(), this
  function is called on that witness.  First, it runs through the
  lock order tree using reparentchildren() to reparent direct descendants
  of the departing witness to each of the witness' parents in the tree.
  Next, it releases it's own child list and other associated resources.
  Finally it calls rebalanacetree() to rebalance the lock order tree.
- Sort function prototypes into something closer to alphabetical order.

As a result of these changes, there should no longer be 'dead' witnesses
in the order tree, and repeatedly loading and unloading a module should no
longer exhaust witness of its internal resources.

Inspired by:	gallatin
2003-03-11 22:07:35 +00:00
John Baldwin
d5b13ee082 Trim useless "../" leading strings from filenames passed into witness. 2003-03-11 21:53:12 +00:00
John Baldwin
28e4d137a2 Adjust style of #ifdef's and #endif's to be more consistent and in line
with recent additions to style(9).
2003-03-11 21:38:49 +00:00
John Baldwin
d278a7f9ba Do the lock order check skip for the LOP_TRYLOCK case after the check for
recursing on a lock instead of before.  This fixes a bug where WITNESS
could get a little confused if you did an sx_tryslock() on a sx lock that
you already had an slock on.  WITNESS would still function correctly but
it could result in weirdness in the output of 'show locks'.  This also
makes it possible for mtx_trylock() to recurse on a lock.
2003-03-11 20:54:37 +00:00
John Baldwin
ecdf4409f9 Rework the eventhandler locking for hopefully the last time. The scheme
used popped into my head during my morning commute a few weeks ago, but
it is also very similar (though a bit simpler) to a patch that mini@
developed a while ago.  Basically, each eventhandler list has a mutex and
a run count.  During an eventhandler invocation, the mutex is held while
we traverse the list but is dropped while we execute actual handlers.  Also,
a runcount counter is incremented at the start of an invocation and
decremented at the end of an invocation.  Adding to the list is not a big
deal since the reference of a thread currently executing the handlers
remains valid across an add operation.  Whether or not new handlers are
executed by threads currently executing the handlers for a given list is
indeterminate however.  The harder case is when a handler is removed from
the list.  If the runcount is zero, the handler is simply removed from the
list directly.  If the runcount is not zero, then another thread is
currently executing the handlers of this list, so the priority of this
handler is set to a magic value (currently -1) to mark it as dead.  Dead
handlers are not executed during an invocation.  If the runcount is zero
after it is decremented at the end of an invocation, then a new
eventhandler_prune_list() function is called to remove dead handlers from
the list.

Additional minor notes:
- All the common parts of EVENTHANDLER_INVOKE() and
  EVENTHANDLER_FAST_INVOKE() have been merged into a common
  _EVENTHANDLER_INVOKE() macro to reduce duplication and ease maintenance.
- KTR logging for eventhandlers is now available via the KTR_EVH mask.
- The global eventhander_mutex is no longer recursive.

Tested by:	scottl (SMP i386)
2003-03-11 20:17:00 +00:00
John Baldwin
8d25e77a0d Retire the KTR_LOCKMGR bit and use it to log eventhandler messages
instead as KTR_EVH.
2003-03-11 20:07:22 +00:00
John Baldwin
75d468ee12 Axe the useless MTX_SLEEPABLE flag. mutexes are not sleepable locks.
Nothing used this flag and WITNESS would have panic'd during mtx_init()
if anything had.
2003-03-11 20:02:57 +00:00
John Baldwin
740190593a Use a shorter and less redundant name for the sysctl tree lock. 2003-03-11 20:01:51 +00:00