opnsense-src/sys
John Baldwin 47ad691f87 Fix an issue with critical sections and SMP rendezvous handlers.
Specifically, a critical_exit() call that drops the nesting level to zero
has a brief window where the pending preemption flag is set and the
nesting level is set to zero.  This is done purposefully to avoid races
where a preemption scheduled by an interrupt could be lost otherwise (see
revision 144777).  However, this does mean that if an interrupt fires
during this window and enters and exits a critical section, it may preempt
from the interrupt context.  This is generally fine as the interrupt code
is careful to arrange critical sections so that they are not exited until
it is safe to preempt (e.g. interrupts EOI'd and masked if necessary).

However, the SMP rendezvous IPI handler does not quite follow this rule,
and in general a rendezvous can never be preempted.  Rendezvous handlers
are also not permitted to schedule threads to execute, so they will not
typically trigger preemptions.  SMP rendezvous handlers may use
spinlocks (carefully) such as the rm_cleanIPI() handler used in rmlocks,
but using a spinlock also enters and exits a critical section.  If the
interrupted top-half code is in the brief window of critical_exit() where
the nesting level is zero but a preemption is pending, then releasing the
spinlock can trigger a preemption.  Because we know that SMP rendezvous
handlers can never schedule a thread, we know that a critical_exit() in
an SMP rendezvous handler will only preempt in this edge case.  We also
know that the top-half thread will happily handle the deferred preemption
once the SMP rendezvous has completed, so the preemption will not be lost.

This makes it safe to employ a workaround where we use a nested critical
section in the SMP rendezvous code itself around rendezvous action
routines to prevent any preemptions during an SMP rendezvous.  The
workaround intentionally avoids checking for a deferred preemption
when leaving the critical section on the assumption that if there is a
pending preemption it will be handled by the interrupted top-half code.

Submitted by:	mlaier (variation specific to rm_cleanIPI())
Obtained from:	Isilon
MFC after:	1 week
2011-05-24 13:36:41 +00:00
..
amd64 Update CPUID bits to reflect AMD Bulldozer and Intel Sandy Bridge features. 2011-05-17 22:36:16 +00:00
arm Move the ZERO_REGION_SIZE to a machine-dependent file, as on many 2011-05-13 19:35:01 +00:00
boot Disconnect sun4v architecture from the three. 2011-05-14 01:53:38 +00:00
bsm Add ECAPMODE, "Not permitted in capability mode", a new kernel errno 2011-03-01 13:14:28 +00:00
cam scsi_cd: silence READ_TOC errors in CDIOREADTOCHEADER ioctl 2011-05-07 10:06:43 +00:00
cddl Fix the zfs file system so that it uses the lock 2011-05-22 21:04:32 +00:00
compat Commit the missing linux_videdev2_compat.h (lost somewhere between 2011-05-04 13:09:20 +00:00
conf Remove an outdated comment as requested by Bruce Evans in a private email to 2011-05-24 09:01:56 +00:00
contrib Make pf compile without INET support by adding #ifdef INETs and 2011-04-27 19:34:01 +00:00
crypto Fix a bug in the result of manual assembly. 2011-03-02 14:56:58 +00:00
ddb Trim some additional unnecessary <linker_set.h> includes. 2011-04-28 17:59:33 +00:00
dev Use the new per-series antenna and TPC definitions when setting ctl8->11. 2011-05-24 05:49:02 +00:00
fs Set the MNT_NFS4ACLS flag for an NFSv4 client mount 2011-05-23 22:31:42 +00:00
gdb Modify kdb_trap() so that it re-calls the dbbe_trap function as long as 2011-02-18 22:25:11 +00:00
geom Remove unused variable. 2011-05-24 06:46:07 +00:00
gnu Fix typo in unused function name 2011-05-22 09:58:48 +00:00
i386 Merge part of r221322 from largeSMP project: 2011-05-18 16:07:30 +00:00
ia64 Prefer switching the memory stack from user to kernel *before* switching 2011-05-14 14:55:15 +00:00
isa Move VT switching hack for suspend/resume from bus drivers to syscons.c 2011-05-09 18:46:49 +00:00
kern Fix an issue with critical sections and SMP rendezvous handlers. 2011-05-24 13:36:41 +00:00
kgssapi
libkern Fix typos - remove duplicate "is". 2011-02-23 09:22:33 +00:00
mips Merge r221846 from largeSMP project branch: 2011-05-23 23:35:50 +00:00
modules Fix a typo, it is MPDU not MDPU. 2011-05-21 16:34:53 +00:00
net Rework netisr policy mechanism so that per-protocol dispatch policies can 2011-05-24 12:34:19 +00:00
net80211 Fix typo, it is MPDU not MDPU. 2011-05-21 16:41:41 +00:00
netatalk
netgraph usb: fix a missed use of use_generic in r222051 2011-05-18 11:38:36 +00:00
netinet An inpcb lock is no longer required in in_pcbref() since the move to 2011-05-24 13:08:59 +00:00
netinet6 Move from passing a wildcard boolean to a general set up lookup flags into 2011-05-23 15:23:18 +00:00
netipsec Release SP's refcount in key_get_spdbyid(). 2011-05-09 13:16:21 +00:00
netipx
netnatm
netncp
netsmb Change some variables from int to size_t. This is more accurate since 2011-01-08 23:06:54 +00:00
nfs Change the sysctl naming for the old and new NFS clients 2011-05-15 20:52:43 +00:00
nfsclient Eliminate duplicate #include's. 2011-05-22 18:11:41 +00:00
nfsserver Add a lock flags argument to the VFS_FHTOVP() file system 2011-05-22 01:07:54 +00:00
nlm Add a lock flags argument to the VFS_FHTOVP() file system 2011-05-22 01:07:54 +00:00
ofed - Catch up to falloc() changes. 2011-04-26 07:30:52 +00:00
opencrypto After the r219999 is merged to stable/8, rename fallocf(9) to falloc(9) 2011-04-01 13:28:34 +00:00
pc98 Move VT switching hack for suspend/resume from bus drivers to syscons.c 2011-05-09 18:46:49 +00:00
pci Do a sweep of the tree replacing calls to pci_find_extcap() with calls to 2011-03-23 13:10:15 +00:00
powerpc Add RTC support for the LV1 clock on the PS3. The hypervisor won't let us 2011-05-24 02:19:45 +00:00
rpc This patch is believed to fix a problem in the kernel rpc for 2011-04-27 18:19:26 +00:00
security - Add a FEATURE for capsicum (security_capabilities). 2011-03-04 09:03:54 +00:00
sparc64 Recognize the eeprom device found in Fujitsu PRIMEPOWER650 and 900. 2011-05-15 13:25:26 +00:00
sys Merge r221901 from largeSMP project branch: 2011-05-22 21:31:36 +00:00
teken Add proper build infrastructure for teken. 2011-05-09 16:27:39 +00:00
tools GNU awk does not output escaped newlines in multi-line printc statements. This 2011-03-31 21:33:33 +00:00
ufs Fix the ufs/ffs file system so that it uses the lock 2011-05-22 20:39:07 +00:00
vm Correct an error in r222163. Unless UMA_MD_SMALL_ALLOC is defined, 2011-05-22 17:46:16 +00:00
x86 Implement boot-time TSC synchronization test for SMP. This test is executed 2011-05-09 17:34:00 +00:00
xdr
xen Fix a few more SYSCTL_PROC() that were missing a CTLFLAG type specifier. 2011-01-19 00:57:58 +00:00
Makefile Disconnect sun4v architecture from the three. 2011-05-14 01:53:38 +00:00