linux/arch
Jeff Dike c14b84949e uml: iRQ stacks
Add a separate IRQ stack.  This differs from i386 in having the entire
interrupt run on a separate stack rather than starting on the normal kernel
stack and switching over once some preparation has been done.  The underlying
mechanism, is of course, sigaltstack.

Another difference is that interrupts that happen in userspace are handled on
the normal kernel stack.  These cause a wait wakeup instead of a signal
delivery so there is no point in trying to switch stacks for these.  There's
no other stuff on the stack, so there is no extra stack consumption.

This quirk makes it possible to have the entire interrupt run on a separate
stack - process preemption (and calls to schedule()) happens on a normal
kernel stack.  If we enable CONFIG_PREEMPT, this will need to be rethought.

The IRQ stack for CPU 0 is declared in the same way as the initial kernel
stack.  IRQ stacks for other CPUs will be allocated dynamically.

An extra field was added to the thread_info structure.  When the active
thread_info is copied to the IRQ stack, the real_thread field points back to
the original stack.  This makes it easy to tell where to copy the thread_info
struct back to when the interrupt is finished.  It also serves as a marker of
a nested interrupt.  It is NULL for the first interrupt on the stack, and
non-NULL for any nested interrupts.

Care is taken to behave correctly if a second interrupt comes in when the
thread_info structure is being set up or taken down.  I could just disable
interrupts here, but I don't feel like giving up any of the performance gained
by not flipping signals on and off.

If an interrupt comes in during these critical periods, the handler can't run
because it has no idea what shape the stack is in.  So, it sets a bit for its
signal in a global mask and returns.  The outer handler will deal with this
signal itself.

Atomicity is had with xchg.  A nested interrupt that needs to bail out will
xchg its signal mask into pending_mask and repeat in case yet another
interrupt hit at the same time, until the mask stabilizes.

The outermost interrupt will set up the thread_info and xchg a zero into
pending_mask when it is done.  At this point, nested interrupts will look at
->real_thread and see that no setup needs to be done.  They can just continue
normally.

Similar care needs to be taken when exiting the outer handler.  If another
interrupt comes in while it is copying the thread_info, it will drop a bit
into pending_mask.  The outer handler will check this and if it is non-zero,
will loop, set up the stack again, and handle the interrupt.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-11 08:29:34 -07:00
..
alpha utimensat implementation 2007-05-08 11:15:18 -07:00
arm Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2007-05-09 13:05:57 -07:00
arm26 header cleaning: don't include smp_lock.h when not used 2007-05-08 11:15:07 -07:00
avr32 Merge branch 'for-linus' of git://www.atmel.no/~hskinnemoen/linux/kernel/avr32 2007-05-09 12:50:25 -07:00
blackfin rename thread_info to stack 2007-05-09 12:30:56 -07:00
cris Fix trivial typos in Kconfig* files 2007-05-09 07:12:20 +02:00
frv frv: gdb: use __maybe_unused 2007-05-11 08:29:33 -07:00
h8300 h8300 syscall update 2007-05-11 08:29:33 -07:00
i386 Revert "[PATCH] paravirt: Add startup infrastructure for paravirtualization" 2007-05-10 09:26:53 -07:00
ia64 [IA64] sa_interrupt is deprecated 2007-05-09 14:20:59 -07:00
m32r m32r: fix tme_handler to check _PAGE_PRESENT bit 2007-05-11 08:29:33 -07:00
m68k header cleaning: don't include smp_lock.h when not used 2007-05-08 11:15:07 -07:00
m68knommu Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-05-09 12:54:17 -07:00
mips Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-05-09 12:54:17 -07:00
parisc rename thread_info to stack 2007-05-09 12:30:56 -07:00
powerpc [POWERPC] Fix compile error with kexec and CONFIG_SMP=n 2007-05-10 22:17:18 +10:00
ppc Merge branch 'linux-2.6' 2007-05-10 21:08:37 +10:00
s390 [S390] update default configuration. 2007-05-10 15:46:08 +02:00
sh Merge master.kernel.org:/pub/scm/linux/kernel/git/lethal/sh-2.6 2007-05-09 13:08:20 -07:00
sh64 Simplify kallsyms_lookup() 2007-05-08 11:15:08 -07:00
sparc rename thread_info to stack 2007-05-09 12:30:56 -07:00
sparc64 Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6 2007-05-10 13:32:05 -07:00
um uml: iRQ stacks 2007-05-11 08:29:34 -07:00
v850 Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-05-09 12:54:17 -07:00
x86_64 x86_64: display more intuitive error message if kernel is not 2MB aligned 2007-05-11 08:29:32 -07:00
xtensa Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-05-09 12:54:17 -07:00