android_kernel_xiaomi_sm8350/arch/um/os-Linux
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
..
drivers uml: convert libc layer to call read and write 2007-05-07 12:13:03 -07:00
include
skas uml: tidy IRQ code 2007-05-11 08:29:33 -07:00
sys-i386 uml: iRQ stacks 2007-05-11 08:29:34 -07:00
sys-x86_64 uml: iRQ stacks 2007-05-11 08:29:34 -07:00
aio.c uml: aIO deadlock avoidance 2007-05-07 12:13:03 -07:00
elf_aux.c [PATCH] uml: host VDSO fix 2007-03-01 14:53:38 -08:00
execvp.c [PATCH] uml: make execvp safe for our usage 2006-11-25 13:28:34 -08:00
file.c uml: rename os_{read_write}_file_k back to os_{read_write}_file 2007-05-07 12:13:03 -07:00
helper.c uml: convert libc layer to call read and write 2007-05-07 12:13:03 -07:00
irq.c uml: remove user_util.h 2007-05-07 12:13:01 -07:00
main.c uml: add missing __init declarations 2007-05-07 12:13:01 -07:00
Makefile [PATCH] uml: make execvp safe for our usage 2006-11-25 13:28:34 -08:00
mem.c uml: convert libc layer to call read and write 2007-05-07 12:13:03 -07:00
process.c uml: mark a tt-only function 2007-05-09 12:30:48 -07:00
sigio.c uml: convert libc layer to call read and write 2007-05-07 12:13:03 -07:00
signal.c uml: iRQ stacks 2007-05-11 08:29:34 -07:00
start_up.c uml: add missing __init declarations 2007-05-07 12:13:01 -07:00
time.c uml: remove user_util.h 2007-05-07 12:13:01 -07:00
tls.c [PATCH] uml: include tidying 2006-11-03 12:27:59 -08:00
trap.c uml: remove user_util.h 2007-05-07 12:13:01 -07:00
tt.c uml: remove page_size() 2007-05-07 12:13:02 -07:00
tty_log.c uml: convert libc layer to call read and write 2007-05-07 12:13:03 -07:00
tty.c
uaccess.c
umid.c [PATCH] uml: umid tidying 2007-02-11 10:51:24 -08:00
user_syms.c
util.c uml: remove task_protections 2007-05-11 08:29:33 -07:00