aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-11 01:22:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 11:29:34 -0400
commitc14b84949e127560084c7c56b365931c71c60768 (patch)
tree88bce4993779078856612b6a32f65f14ab379d85 /include/asm-um
parent2ea5bc5e5bb51492f189bba44045e0de7decf4a0 (diff)
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>
Diffstat (limited to 'include/asm-um')
-rw-r--r--include/asm-um/thread_info.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/asm-um/thread_info.h b/include/asm-um/thread_info.h
index 261e2f4528f6..18a13ba74605 100644
--- a/include/asm-um/thread_info.h
+++ b/include/asm-um/thread_info.h
@@ -22,6 +22,7 @@ struct thread_info {
22 0-0xBFFFFFFF for user 22 0-0xBFFFFFFF for user
23 0-0xFFFFFFFF for kernel */ 23 0-0xFFFFFFFF for kernel */
24 struct restart_block restart_block; 24 struct restart_block restart_block;
25 struct thread_info *real_thread; /* Points to non-IRQ stack */
25}; 26};
26 27
27#define INIT_THREAD_INFO(tsk) \ 28#define INIT_THREAD_INFO(tsk) \
@@ -35,6 +36,7 @@ struct thread_info {
35 .restart_block = { \ 36 .restart_block = { \
36 .fn = do_no_restart_syscall, \ 37 .fn = do_no_restart_syscall, \
37 }, \ 38 }, \
39 .real_thread = NULL, \
38} 40}
39 41
40#define init_thread_info (init_thread_union.thread_info) 42#define init_thread_info (init_thread_union.thread_info)