[patch] per irq stack [was: Re: Strange interrupt behaviour]

Andrea Arcangeli (arcangeli@mbox.queen.it)
Wed, 15 Jul 1998 22:10:59 +0200 (CEST)


On Wed, 15 Jul 1998, Andrea Arcangeli wrote:

>Thanks! Anyway I noticed now (this night was really too late) that
>old_stacks can be removed since I can put the old stack pointer in the new
>stack directly instead to push the irq that indexed old_stacks[].

Here the improvement (get rid of not needed struct and using the stack
also in bh handler (even if I don' t know very well what does bh handlers
;-). It' s running now and I got no one problem so far.

--- linux/arch/i386/kernel/irq.c 1998/07/14 18:52:27 1.1
+++ linux/arch/i386/kernel/irq.c 1998/07/15 20:04:41
@@ -46,6 +46,11 @@
atomic_t nmi_counter;

/*
+ * Per interrupt stack area.
+ */
+unsigned char irq_stacks[NR_IRQS*PAGE_SIZE] __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 +730,21 @@
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];
+ register unsigned char *old_stack;
+ __asm__ __volatile__ ("movl %%esp, %0" : "=r" (old_stack));
+ __asm__ __volatile__ ("movl %0, %%esp\n\t"
+ "pushl %1" : :
+ "r" (stack), "r" (old_stack));
+}
+
+static __inline__ void restore_stack(void)
+{
+ __asm__ __volatile__ ("popl %%esp" : );
+}
+
/*
* do_IRQ handles all normal device IRQ's (the special
* SMP cross-CPU interrupts have their own specific
@@ -755,6 +775,8 @@
int cpu = smp_processor_id();

kstat.irqs[cpu][irq]++;
+
+ split_stack(irq);
irq_desc[irq].handler->handle(irq, cpu, &regs);

/*
@@ -767,6 +789,8 @@
if (bh_active & bh_mask)
do_bottom_half();
}
+
+ restore_stack();
}

int setup_x86_irq(unsigned int irq, struct irqaction * new)

Andrea[s] Arcangeli

-
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