freebsd-dev/sys/amd64/include
Matthew Dillon f96ad4c223 STAGE-1 of 3 commit - allow (but do not require) interrupts to remain
enabled in critical sections and streamline critical_enter() and
critical_exit().

This commit allows an architecture to leave interrupts enabled inside
critical sections if it so wishes.  Architectures that do not wish to do
this are not effected by this change.

This commit implements the feature for the I386 architecture and provides
a sysctl, debug.critical_mode, which defaults to 1 (use the feature).  For
now you can turn the sysctl on and off at any time in order to test the
architectural changes or track down bugs.

This commit is just the first stage.  Some areas of the code, specifically
the MACHINE_CRITICAL_ENTER #ifdef'd code, is strictly temporary and will
be cleaned up in the STAGE-2 commit when the critical_*() functions are
moved entirely into MD files.

The following changes have been made:

	* critical_enter() and critical_exit() for I386 now simply increment
	  and decrement curthread->td_critnest.  They no longer disable
	  hard interrupts.  When critical_exit() decrements the counter to
	  0 it effectively calls a routine to deal with whatever interrupts
	  were deferred during the time the code was operating in a critical
	  section.

	  Other architectures are unaffected.

	* fork_exit() has been conditionalized to remove MD assumptions for
	  the new code.  Old code will still use the old MD assumptions
	  in regards to hard interrupt disablement.  In STAGE-2 this will
	  be turned into a subroutine call into MD code rather then hardcoded
	  in MI code.

	  The new code places the burden of entering the critical section
	  in the trampoline code where it belongs.

	* I386: interrupts are now enabled while we are in a critical section.
	  The interrupt vector code has been adjusted to deal with the fact.
	  If it detects that we are in a critical section it currently defers
	  the interrupt by adding the appropriate bit to an interrupt mask.

	* In order to accomplish the deferral, icu_lock is required.  This
	  is i386-specific.  Thus icu_lock can only be obtained by mainline
	  i386 code while interrupts are hard disabled.  This change has been
	  made.

	* Because interrupts may or may not be hard disabled during a
	  context switch, cpu_switch() can no longer simply assume that
	  PSL_I will be in a consistent state.  Therefore, it now saves and
	  restores eflags.

	* FAST INTERRUPT PROVISION.  Fast interrupts are currently deferred.
	  The intention is to eventually allow them to operate either while
	  we are in a critical section or, if we are able to restrict the
	  use of sched_lock, while we are not holding the sched_lock.

	* ICU and APIC vector assembly for I386 cleaned up.  The ICU code
	  has been cleaned up to match the APIC code in regards to format
	  and macro availability.  Additionally, the code has been adjusted
	  to deal with deferred interrupts.

	* Deferred interrupts use a per-cpu boolean int_pending, and
	  masks ipending, spending, and fpending.  Being per-cpu variables
	  it is not currently necessary to lock; bus cycles modifying them.

	  Note that the same mechanism will enable preemption to be
	  incorporated as a true software interrupt without having to
	  further hack up the critical nesting code.

	* Note: the old critical_enter() code in kern/kern_switch.c is
	  currently #ifdef to be compatible with both the old and new
	  methodology.  In STAGE-2 it will be moved entirely to MD code.

Performance issues:

	One of the purposes of this commit is to enhance critical section
	performance, specifically to greatly reduce bus overhead to allow
	the critical section code to be used to protect per-cpu caches.
	These caches, such as Jeff's slab allocator work, can potentially
	operate very quickly making the effective savings of the new
	critical section code's performance very significant.

	The second purpose of this commit is to allow architectures to
	enable certain interrupts while in a critical section.  Specifically,
	the intention is to eventually allow certain FAST interrupts to
	operate rather then defer.

	The third purpose of this commit is to begin to clean up the
	critical_enter()/critical_exit()/cpu_critical_enter()/
	cpu_critical_exit() API which currently has serious cross pollution
	in MI code (in fork_exit() and ast() for example).

	The fourth purpose of this commit is to provide a framework that
	allows kernel-preempting software interrupts to be implemented
	cleanly.  This is currently used for two forward interrupts in I386.
	Other architectures will have the choice of using this infrastructure
	or building the functionality directly into critical_enter()/
	critical_exit().

	Finally, this commit is designed to greatly improve the flexibility
	of various architectures to manage critical section handling,
	software interrupts, preemption, and other highly integrated
	architecture-specific details.
2002-02-26 17:06:21 +00:00
..
pc Fixed to draw mouse cursor. The syscons driver for PC98 uses different 2001-12-14 15:27:15 +00:00
_inttypes.h o Add new header <sys/stdint.h>. 2001-11-02 18:05:43 +00:00
apicreg.h Introduce a standard name for the lock protecting an interrupt controller 2001-12-20 23:48:31 +00:00
asm.h Fixed the profiling version ALTENTRY(). Again. The previous version 2000-01-25 09:01:55 +00:00
asmacros.h Overhaul the per-CPU support a bit: 2001-12-11 23:33:44 +00:00
atomic.h Garbage-collect the "LOCORE" version of MPLOCKED. 2002-02-11 03:41:59 +00:00
bus_amd64.h Add stubs for bus_space_unmap() and bus_space_free(). They are needed to 2002-02-18 13:43:19 +00:00
bus_at386.h Add stubs for bus_space_unmap() and bus_space_free(). They are needed to 2002-02-18 13:43:19 +00:00
bus_dma.h - Moved the bus_dma declarations from bus_{at386,pc98}.h into bus_dma.h. 2001-10-06 16:27:21 +00:00
bus_memio.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
bus_pio.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
bus.h - Moved the bus_dma declarations from bus_{at386,pc98}.h into bus_dma.h. 2001-10-06 16:27:21 +00:00
clock.h Reenable RTC interrupts after wakeup. Some laptops have a problem 2001-09-04 16:02:06 +00:00
cpu.h Overhaul the per-CPU support a bit: 2001-12-11 23:33:44 +00:00
cpufunc.h STAGE-1 of 3 commit - allow (but do not require) interrupts to remain 2002-02-26 17:06:21 +00:00
cputypes.h First shot at identifying the Pentum 4 acording to our reading of the 2000-09-29 04:38:35 +00:00
db_machdep.h Fill out some gaps in ia64 DDB support. This involves generalising DDB's 2001-09-15 11:06:07 +00:00
elf.h Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loader 2001-10-10 23:06:54 +00:00
exec.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
float.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
floatingpoint.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
fpu.h KSE Milestone 2 2001-09-12 08:38:13 +00:00
frame.h Interrupt frames don't include the saved cpl anymore since cpl is dead. 2000-10-06 01:57:28 +00:00
ieeefp.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
in_cksum.h This is the first snapshot of the FreeBSD/ia64 kernel. This kernel will 2000-09-29 13:46:07 +00:00
legacyvar.h Get out the roto-rooter and clean up the abuse of nexus ivars by the 2000-09-28 00:37:32 +00:00
md_var.h Apparently during the KSE M2 commit bzero() on the i386 was changed so that 2002-02-08 19:16:47 +00:00
mptable.h STAGE-1 of 3 commit - allow (but do not require) interrupts to remain 2002-02-26 17:06:21 +00:00
mutex.h Modify the critical section API as follows: 2001-12-18 00:27:18 +00:00
npx.h KSE Milestone 2 2001-09-12 08:38:13 +00:00
pcb_ext.h Split the per-process Local Descriptor Table out of the PCB and into 2001-10-25 00:53:43 +00:00
pcb.h STAGE-1 of 3 commit - allow (but do not require) interrupts to remain 2002-02-26 17:06:21 +00:00
pci_cfgreg.h Detect a certain type of PCIBIOS brain damage. For some reason, 2001-08-21 03:10:55 +00:00
pcpu.h Overhaul the per-CPU support a bit: 2001-12-11 23:33:44 +00:00
pmap.h Work-in-progress commit syncing up pmap cleanups that I have been working 2002-02-25 23:49:51 +00:00
proc.h Overhaul the per-CPU support a bit: 2001-12-11 23:33:44 +00:00
profile.h Finish revs.1.23 and 1.24 so that MCOUNT_ENTER really actually compiles 2002-01-31 13:49:55 +00:00
psl.h Allow bit 21 of EFLAGS register (PSL_ID) be changed in the use-mode without 2001-11-15 23:01:29 +00:00
ptrace.h Zap 'ptrace(PT_READ_U, ...)' and 'ptrace(PT_WRITE_U, ...)' since they 2001-08-08 05:25:15 +00:00
reg.h [partially forced commit due to pilot error in earlier commit attempt] 2001-10-21 22:16:48 +00:00
reloc.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
resource.h * Implement bus_set/get/delete_resource for pci. 1999-10-14 21:38:33 +00:00
segments.h Add a missing open paren to a macro that's been broken (and apparently 2001-12-04 00:35:28 +00:00
setjmp.h Work around a bug by adding struct tags. gcc-2.95 apparently gets the 2000-10-06 11:53:32 +00:00
sigframe.h Use struct __ucontext in prototypes and associated functions instead of 2002-02-17 17:40:34 +00:00
signal.h Use struct __ucontext in prototypes and associated functions instead of 2002-02-17 17:40:34 +00:00
smp.h Work-in-progress commit syncing up pmap cleanups that I have been working 2002-02-25 23:49:51 +00:00
specialreg.h Activate SSE/SIMD. This is the extra context switching support that 2001-07-12 06:32:51 +00:00
sysarch.h Make the style a little bit more consistant by removing parameter 2002-02-03 11:21:22 +00:00
trap.h Activate SSE/SIMD. This is the extra context switching support that 2001-07-12 06:32:51 +00:00
tss.h Declare or #define per-cpu globals in <machine/globals.h> in all cases. 2000-10-27 08:30:59 +00:00
ucontext.h Use a spare slot in the machine context for a flags word to indicate 2002-01-10 02:32:30 +00:00
varargs.h $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
vmparam.h Make sysv-style shared memory tuneable params fully runtime adjustable 2000-03-30 07:17:05 +00:00