1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-24 16:10:11 +00:00
freebsd/sys
Luigi Rizzo de240d1013 merge code from ipfw3-head to reduce contention on the ipfw lock
and remove all O(N) sequences from kernel critical sections in ipfw.

In detail:

 1. introduce a IPFW_UH_LOCK to arbitrate requests from
     the upper half of the kernel. Some things, such as 'ipfw show',
     can be done holding this lock in read mode, whereas insert and
     delete require IPFW_UH_WLOCK.

  2. introduce a mapping structure to keep rules together. This replaces
     the 'next' chain currently used in ipfw rules. At the moment
     the map is a simple array (sorted by rule number and then rule_id),
     so we can find a rule quickly instead of having to scan the list.
     This reduces many expensive lookups from O(N) to O(log N).

  3. when an expensive operation (such as insert or delete) is done
     by userland, we grab IPFW_UH_WLOCK, create a new copy of the map
     without blocking the bottom half of the kernel, then acquire
     IPFW_WLOCK and quickly update pointers to the map and related info.
     After dropping IPFW_LOCK we can then continue the cleanup protected
     by IPFW_UH_LOCK. So userland still costs O(N) but the kernel side
     is only blocked for O(1).

  4. do not pass pointers to rules through dummynet, netgraph, divert etc,
     but rather pass a <slot, chain_id, rulenum, rule_id> tuple.
     We validate the slot index (in the array of #2) with chain_id,
     and if successful do a O(1) dereference; otherwise, we can find
     the rule in O(log N) through <rulenum, rule_id>

All the above does not change the userland/kernel ABI, though there
are some disgusting casts between pointers and uint32_t

Operation costs now are as follows:

  Function				Old	Now	  Planned
-------------------------------------------------------------------
  + skipto X, non cached		O(N)	O(log N)
  + skipto X, cached			O(1)	O(1)
XXX dynamic rule lookup			O(1)	O(log N)  O(1)
  + skipto tablearg			O(N)	O(1)
  + reinject, non cached		O(N)	O(log N)
  + reinject, cached			O(1)	O(1)
  + kernel blocked during setsockopt()	O(N)	O(1)
-------------------------------------------------------------------

The only (very small) regression is on dynamic rule lookup and this will
be fixed in a day or two, without changing the userland/kernel ABI

Supported by: Valeria Paoli
MFC after:	1 month
2009-12-22 19:01:47 +00:00
..
amd64 - Create a separate section in in the MI NOTES file for PCI wireless NIC 2009-12-18 16:13:21 +00:00
arm Add INCLUDE_CONFIG_FILE, and a note in comments about how to also 2009-12-16 02:17:43 +00:00
boot Move cursor position after putting a character. 2009-12-21 14:59:23 +00:00
bsm
cam Remove duplicate devstat_start_transaction_bio() call. It is already called 2009-12-18 14:41:30 +00:00
cddl Apply fix for Solaris bug 6462803: zfs snapshot -r failed because 2009-12-19 11:49:20 +00:00
compat Signal 0 is used to check the permission for current process to signal 2009-12-18 14:27:18 +00:00
conf - Create a separate section in in the MI NOTES file for PCI wireless NIC 2009-12-18 16:13:21 +00:00
contrib Merge ACPICA 20091214. 2009-12-14 22:24:04 +00:00
crypto
ddb
dev Add minimal dealy while ste(4) is waiting for the end of active DMA 2009-12-22 19:00:18 +00:00
fs Let access overriding to TTYs depend on the cdev_priv, not the vnode. 2009-12-19 18:42:12 +00:00
gdb
geom Make graid3 fallback to malloc() when component request size is bigger 2009-12-21 23:31:03 +00:00
gnu
i386 - Create a separate section in in the MI NOTES file for PCI wireless NIC 2009-12-18 16:13:21 +00:00
ia64 Add INCLUDE_CONFIG_FILE, and a note in comments about how to also 2009-12-16 02:17:43 +00:00
isa Attach dpms(4) to vgapm and make sure to restore DPMS state after 2009-12-15 19:58:23 +00:00
kern VI_OBJDIRTY vnode flag mirrors the state of OBJ_MIGHTBEDIRTY vm object 2009-12-21 12:29:38 +00:00
kgssapi
libkern
mips Add INCLUDE_CONFIG_FILE, and a note in comments about how to also 2009-12-16 02:17:43 +00:00
modules Now that ipfw is split into multiple files, we need 2009-12-17 17:44:34 +00:00
net merge code from ipfw3-head to reduce contention on the ipfw lock 2009-12-22 19:01:47 +00:00
net80211 Fix typo in comment 2009-12-08 00:54:08 +00:00
netatalk
netgraph merge code from ipfw3-head to reduce contention on the ipfw lock 2009-12-22 19:01:47 +00:00
netinet merge code from ipfw3-head to reduce contention on the ipfw lock 2009-12-22 19:01:47 +00:00
netinet6 Add missing #include <sys/ktr.h>. 2009-12-15 10:40:40 +00:00
netipsec
netipx
netnatm
netncp
netsmb
nfs
nfsclient Add a few more V_hacks to nfsclient to allow machines with a VIMAGE 2009-12-13 11:06:39 +00:00
nfsserver
nlm
opencrypto
pc98 - Create a separate section in in the MI NOTES file for PCI wireless NIC 2009-12-18 16:13:21 +00:00
pci
powerpc Remove a warning in DELAY about large delays. In kern_shutdown.c 2009-12-19 20:42:56 +00:00
rpc
security
sparc64 Add missing module dependency information. 2009-12-21 21:41:33 +00:00
sun4v Add INCLUDE_CONFIG_FILE, and a note in comments about how to also 2009-12-16 02:17:43 +00:00
sys Cosmetic fixes. 2009-12-22 09:03:59 +00:00
teken
tools
ufs Implement NFSv4 ACL support for UFS. 2009-12-21 19:39:10 +00:00
vm VI_OBJDIRTY vnode flag mirrors the state of OBJ_MIGHTBEDIRTY vm object 2009-12-21 12:29:38 +00:00
xdr
xen
Makefile