aboutsummaryrefslogtreecommitdiff
path: root/arch/um/os-Linux/skas
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-01-18 17:42:49 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-18 19:20:20 -0800
commit1d7173baf286c8b720f97f119ec92be43076ebde (patch)
tree4d562c25063c73a690fe1777fa86c3f48dfbbf13 /arch/um/os-Linux/skas
parent09ee011eb322c2072ec184a88763c250a5485d8b (diff)
[PATCH] uml: implement soft interrupts
This patch implements soft interrupts. Interrupt enabling and disabling no longer map to sigprocmask. Rather, a flag is set indicating whether interrupts may be handled. If a signal comes in and interrupts are marked as OK, then it is handled normally. If interrupts are marked as off, then the signal handler simply returns after noting that a signal needs handling. When interrupts are enabled later on, this pending signals flag is checked, and the IRQ handlers are called at that point. The point of this is to reduce the cost of local_irq_save et al, since they are very much more common than the signals that they are enabling and disabling. Soft interrupts produce a speed-up of ~25% on a kernel build. Subtleties - UML uses sigsetjmp/siglongjmp to switch contexts. sigsetjmp has been wrapped in a save_flags-like macro which remembers the interrupt state at setjmp time, and restores it when it is longjmp-ed back to. The enable_signals function has to loop because the IRQ handler disables interrupts before returning. enable_signals has to return with signals enabled, and signals may come in between the disabling and the return to enable_signals. So, it loops for as long as there are pending signals, ensuring that signals are enabled when it finally returns, and that there are no pending signals that need to be dealt with. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/skas')
-rw-r--r--arch/um/os-Linux/skas/process.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index b959b2618b7..120a21c5883 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -34,6 +34,7 @@
#include "mem.h"
#include "uml-config.h"
#include "process.h"
+#include "longjmp.h"
int is_skas_winch(int pid, int fd, void *data)
{
@@ -433,6 +434,7 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
{
unsigned long flags;
sigjmp_buf switch_buf, fork_buf;
+ int enable;
*switch_buf_ptr = &switch_buf;
*fork_buf_ptr = &fork_buf;
@@ -447,7 +449,7 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
*/
flags = get_signals();
block_signals();
- if(sigsetjmp(fork_buf, 1) == 0)
+ if(UML_SIGSETJMP(&fork_buf, enable) == 0)
new_thread_proc(stack, handler);
remove_sigstack();
@@ -458,20 +460,22 @@ void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
void thread_wait(void *sw, void *fb)
{
sigjmp_buf buf, **switch_buf = sw, *fork_buf;
+ int enable;
*switch_buf = &buf;
fork_buf = fb;
- if(sigsetjmp(buf, 1) == 0)
+ if(UML_SIGSETJMP(&buf, enable) == 0)
siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK);
}
void switch_threads(void *me, void *next)
{
sigjmp_buf my_buf, **me_ptr = me, *next_buf = next;
+ int enable;
*me_ptr = &my_buf;
- if(sigsetjmp(my_buf, 1) == 0)
- siglongjmp(*next_buf, 1);
+ if(UML_SIGSETJMP(&my_buf, enable) == 0)
+ UML_SIGLONGJMP(next_buf, 1);
}
static sigjmp_buf initial_jmpbuf;
@@ -484,14 +488,14 @@ static sigjmp_buf *cb_back;
int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
{
sigjmp_buf **switch_buf = switch_buf_ptr;
- int n;
+ int n, enable;
set_handler(SIGWINCH, (__sighandler_t) sig_handler,
SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM,
SIGVTALRM, -1);
*fork_buf_ptr = &initial_jmpbuf;
- n = sigsetjmp(initial_jmpbuf, 1);
+ n = UML_SIGSETJMP(&initial_jmpbuf, enable);
switch(n){
case INIT_JMP_NEW_THREAD:
new_thread_proc((void *) stack, new_thread_handler);
@@ -501,7 +505,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
break;
case INIT_JMP_CALLBACK:
(*cb_proc)(cb_arg);
- siglongjmp(*cb_back, 1);
+ UML_SIGLONGJMP(cb_back, 1);
break;
case INIT_JMP_HALT:
kmalloc_ok = 0;
@@ -512,20 +516,21 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
default:
panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
}
- siglongjmp(**switch_buf, 1);
+ UML_SIGLONGJMP(*switch_buf, 1);
}
void initial_thread_cb_skas(void (*proc)(void *), void *arg)
{
sigjmp_buf here;
+ int enable;
cb_proc = proc;
cb_arg = arg;
cb_back = &here;
block_signals();
- if(sigsetjmp(here, 1) == 0)
- siglongjmp(initial_jmpbuf, INIT_JMP_CALLBACK);
+ if(UML_SIGSETJMP(&here, enable) == 0)
+ UML_SIGLONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK);
unblock_signals();
cb_proc = NULL;
@@ -536,13 +541,13 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
void halt_skas(void)
{
block_signals();
- siglongjmp(initial_jmpbuf, INIT_JMP_HALT);
+ UML_SIGLONGJMP(&initial_jmpbuf, INIT_JMP_HALT);
}
void reboot_skas(void)
{
block_signals();
- siglongjmp(initial_jmpbuf, INIT_JMP_REBOOT);
+ UML_SIGLONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT);
}
void switch_mm_skas(struct mm_id *mm_idp)