opnsense-src/sys
Attilio Rao 047dd67e96 Optimize lockmgr in order to get rid of the pool mutex interlock, of the
state transitioning flags and of msleep(9) callings.
Use, instead, an algorithm very similar to what sx(9) and rwlock(9)
alredy do and direct accesses to the sleepqueue(9) primitive.

In order to avoid writer starvation a mechanism very similar to what
rwlock(9) uses now is implemented, with the correspective per-thread
shared lockmgrs counter.

This patch also adds 2 new functions to lockmgr KPI: lockmgr_rw() and
lockmgr_args_rw().  These two are like the 2 "normal" versions, but they
both accept a rwlock as interlock.  In order to realize this, the general
lockmgr manager function "__lockmgr_args()" has been implemented through
the generic lock layer. It supports all the blocking primitives, but
currently only these 2 mappers live.

The patch drops the support for WITNESS atm, but it will be probabilly
added soon. Also, there is a little race in the draining code which is
also present in the current CVS stock implementation: if some sharers,
once they wakeup, are in the runqueue they can contend the lock with
the exclusive drainer.  This is hard to be fixed but the now committed
code mitigate this issue a lot better than the (past) CVS version.
In addition assertive KA_HELD and KA_UNHELD have been made mute
assertions because they are dangerous and they will be nomore supported
soon.

In order to avoid namespace pollution, stack.h is splitted into two
parts: one which includes only the "struct stack" definition (_stack.h)
and one defining the KPI.  In this way, newly added _lockmgr.h can
just include _stack.h.

Kernel ABI results heavilly changed by this commit (the now committed
version of "struct lock" is a lot smaller than the previous one) and
KPI results broken by lockmgr_rw() / lockmgr_args_rw() introduction,
so manpages and __FreeBSD_version will be updated accordingly.

Tested by:      kris, pho, jeff, danger
Reviewed by:    jeff
Sponsored by:   Google, Summer of Code program 2007
2008-04-06 20:08:51 +00:00
..
amd64 Add a MI intr_event_handle() routine for the non-INTR_FILTER case. This 2008-04-05 19:58:30 +00:00
arm Remove bus_space_generic.c from the per-plarform files. Having it in the 2008-04-05 21:57:11 +00:00
boot Add a couple of missing NIC driver modules. 2008-03-28 18:13:09 +00:00
bsm Merge OpenBSM 1.0 changes to src/sys/bsm: 2007-10-29 18:47:25 +00:00
cam Locking in the ses_ioctl handler doesn't have to be so strict because 2008-03-17 17:18:16 +00:00
cddl Add the new kernel-mode NFS Lock Manager. To use it instead of the 2008-03-26 15:23:12 +00:00
compat Regen 2008-03-31 12:12:27 +00:00
conf Move INTR_FILTER from opt_global.h to its own header. 2008-04-05 20:13:15 +00:00
contrib Make ALTQ cope with disappearing interfaces (particularly common with mpd 2008-03-29 00:24:36 +00:00
crypto Make test00 compilable again. 2008-01-15 18:34:47 +00:00
ddb enable dynamic addition of "show all" commands 2008-03-25 20:36:32 +00:00
dev Move INTR_FILTER from opt_global.h to its own header. 2008-04-05 20:13:15 +00:00
fs Optimize lockmgr in order to get rid of the pool mutex interlock, of the 2008-04-06 20:08:51 +00:00
gdb Commit SYSINIT() ;-adding patch missed in previous pass. 2008-03-16 13:02:04 +00:00
geom Change the order from SI_ORDER_FIRST to SI_ORDER_ANY (within 2008-03-29 17:33:29 +00:00
gnu Fix a nit with the 'nofoo' options where 'foo' is mapped to 'nonofoo' 2008-03-26 20:48:07 +00:00
i4b Spelling fix for interupt -> interrupt 2007-10-12 06:03:46 +00:00
i386 Add a MI intr_event_handle() routine for the non-INTR_FILTER case. This 2008-04-05 19:58:30 +00:00
ia64 Add a MI intr_event_handle() routine for the non-INTR_FILTER case. This 2008-04-05 19:58:30 +00:00
isa Back in the good old days, PC's had random pieces of rock for 2008-03-26 22:12:00 +00:00
kern Optimize lockmgr in order to get rid of the pool mutex interlock, of the 2008-04-06 20:08:51 +00:00
libkern Add prototype for __cmpd2(). 2008-02-23 22:40:05 +00:00
modules This update primarily addresses the ability to have both the em 2008-04-02 22:00:36 +00:00
net Add IFF_NEEDSGIANT to IFF_CANTCHANGE, to prevent user-level code 2008-03-27 18:02:30 +00:00
net80211 Fix adhoc mode to scan all available channels for a bss to join 2008-02-29 04:07:07 +00:00
netatalk Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
netatm Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
netgraph Rewrite node's r/w/q-lock semantics using only atomics instead of mutex 2008-04-06 15:26:32 +00:00
netinet Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
netinet6 Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
netipsec Fix a bug that when getting/dumping the soft lifetime we reported 2008-03-24 15:01:20 +00:00
netipx Make tcpstates[] static, and make sure TCPSTATES is defined before 2007-07-30 11:06:42 +00:00
netnatm
netncp lockmgrs need to be released before to be destroyed and draining doesn't 2008-03-30 18:16:33 +00:00
netsmb Really, smb_iod_main() is not totally MPSAFE, so just acquire and drop 2008-03-27 01:23:59 +00:00
nfs Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
nfs4client Add the new kernel-mode NFS Lock Manager. To use it instead of the 2008-03-26 15:23:12 +00:00
nfsclient Add the new kernel-mode NFS Lock Manager. To use it instead of the 2008-03-26 15:23:12 +00:00
nfsserver Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
nlm Minor changes to improve compatibility with older FreeBSD releases. 2008-03-28 09:50:32 +00:00
opencrypto Make ftruncate a 'struct file' operation rather than a vnode operation. 2008-01-07 20:05:19 +00:00
pc98 Add kernel module support for nfslockd and krpc. Use the module system 2008-03-27 11:54:20 +00:00
pccard
pci Padding more bytes than necessary one broke another variants of 2008-03-31 04:03:14 +00:00
powerpc Add a MI intr_event_handle() routine for the non-INTR_FILTER case. This 2008-04-05 19:58:30 +00:00
rpc Minor changes to improve compatibility with older FreeBSD releases. 2008-03-28 09:50:32 +00:00
security Add the support for the AT_FDCWD and fd-relative name lookups to the 2008-03-31 12:01:21 +00:00
sparc64 Add a MI intr_event_handle() routine for the non-INTR_FILTER case. This 2008-04-05 19:58:30 +00:00
sun4v Add a MI intr_event_handle() routine for the non-INTR_FILTER case. This 2008-04-05 19:58:30 +00:00
sys Optimize lockmgr in order to get rid of the pool mutex interlock, of the 2008-04-06 20:08:51 +00:00
tools Introduce a standalone shell script for embedding MFS image. 2008-02-05 10:46:30 +00:00
ufs Optimize lockmgr in order to get rid of the pool mutex interlock, of the 2008-04-06 20:08:51 +00:00
vm Introduce vm_reserv_reclaim_contig(). This function is used by 2008-04-06 18:09:28 +00:00
xdr Add the new kernel-mode NFS Lock Manager. To use it instead of the 2008-03-26 15:23:12 +00:00
Makefile o Add boot, gdb, nfsserver and opencrypto dirs to CSCOPEDIRS; sort. 2008-01-23 08:50:34 +00:00