Messages in this thread Patch in this message | | | Date | Wed, 15 Jul 1998 03:04:25 +0200 (CEST) | From | Andrea Arcangeli <> | Subject | Re: Strange interrupt behaviour |
| |
On Mon, 13 Jul 1998, Linus Torvalds wrote:
>Oh, having separate interrupt stacks _works_, and on some architectures it
I hacked irq.c and now seems to work on Linux too ;-).
=================================================================== RCS file: linux/arch/i386/kernel/irq.c,v retrieving revision 1.1 diff -u -r1.1 linux/arch/i386/kernel/irq.c --- linux/arch/i386/kernel/irq.c 1998/07/14 18:52:27 1.1 +++ linux/arch/i386/kernel/irq.c 1998/07/15 00:51:23 @@ -46,6 +46,12 @@ atomic_t nmi_counter; /* + * Per interrupt stack area. + */ +unsigned char irq_stacks[NR_IRQS*PAGE_SIZE] __attribute__ ((aligned (32))); +unsigned char *old_stacks[NR_IRQS] __attribute__ ((aligned (32))); + +/* * About the IO-APIC, the architecture is 'merged' into our * current irq architecture, seemlessly. (i hope). It is only * visible through 8 more hardware interrupt lines, but otherwise @@ -725,6 +731,24 @@ spin_unlock_irqrestore(&irq_controller_lock, flags); } +static __inline__ void split_stack(register unsigned int irq) +{ + register unsigned char *stack = &irq_stacks[(irq+1)*PAGE_SIZE]; + __asm__ __volatile__ ("movl %%esp, %0\n\t" + "movl %1, %%esp\n\t" + "pushl %2" : + "=m" (old_stacks[irq]) : + "r" (stack), "r" (irq)); +} + +static __inline__ void restore_stack(void) +{ + register unsigned int irq; + __asm__ __volatile__ ("popl %0" : "=r" (irq)); + __asm__ __volatile__ ("movl %0, %%esp\n\t" : : + "m" (old_stacks[irq])); +} + /* * do_IRQ handles all normal device IRQ's (the special * SMP cross-CPU interrupts have their own specific @@ -755,7 +779,10 @@ int cpu = smp_processor_id(); kstat.irqs[cpu][irq]++; + + split_stack(irq); irq_desc[irq].handler->handle(irq, cpu, ®s); + restore_stack(); /* * This should be conditional: we should really get I am writing this with the patch applyed ;-).
I am not sure if this is really what I want (I am just very happy that the kernel doesn' t crash though ;-). I want that every irq handler have a page of ram to use. I want to avoid that 16 nested interrupt could run all on the same 8kbyte kernel stack.
Andrea[s] Arcangeli
PS. Really time to sleep... (goodnight).
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html
| |