x86-32: always use irq stacks
Subsystems (2)
PATCH 1/1 x86-32: always use irq stacks
IRQ stacks provide much better safety against unexpected stack use from interrupts, at the minimal downside of slightly higher memory usage. Enable irq stacks also for the default 8k stack to minimize the problem of stack overflows through interrupt activity.
This is what x86-64 and various other architectures already do.
arch/x86/Kconfig.debug +1 -2
@@ -128,8 +128,7 @@ config 4KSTACKS If you say Y here the kernel will use a 4Kb stacksize for the kernel stack attached to each process/thread. This facilitates running more threads on a system and also reduces the pressure - on the VM subsystem for higher order allocations. This option - will also use IRQ stacks to compensate for the reduced stackspace. + on the VM subsystem for higher order allocations. config DOUBLEFAULT default y
arch/x86/include/asm/irq.h +5 -7
@@ -19,18 +19,16 @@ static inline int irq_canonicalize(int i# define ARCH_HAS_NMI_WATCHDOG #endif -#ifdef CONFIG_4KSTACKS -extern void irq_ctx_init (int cpu); -extern void irq_ctx_exit (int cpu); -# define __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_X86_32 +extern void irq_ctx_init (int cpu); +extern void irq_ctx_exit (int cpu);#else # define irq_ctx_init (cpu) do { } while (0)# define irq_ctx_exit (cpu) do { } while (0) -# ifdef CONFIG_X86_64 -# define __ARCH_HAS_DO_SOFTIRQ -# endif #endif +#define __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_HOTPLUG_CPU #include <linux/cpumask.h> extern void fixup_irqs (void );
arch/x86/kernel/irq_32.c +0 -6
@@ -49,7 +49,6 @@ static inline int check_stack_overflow(vstatic inline void print_stack_overflow (void ) { }#endif -#ifdef CONFIG_4KSTACKS /* * per-CPU IRQ handling contexts (thread information and stack) */
@@ -187,11 +186,6 @@ asmlinkage void do_softirq(void)local_irq_restore (flags); } -#else -static inline int -execute_on_irq_stack (int overflow,struct irq_desc *desc,int irq) {return 0 ; } -#endif -bool handle_irq (unsigned irq,struct pt_regs *regs) {struct irq_desc *desc;
Documentation/x86/x86_64/kernel-stacks +3 -3
@@ -18,9 +18,9 @@ specialized stacks contain no useful dat Used for external hardware interrupts. If this is the first external hardware interrupt (i.e. not a nested hardware interrupt) then the kernel switches from the current task to the interrupt stack. Like - the split thread and interrupt stacks on i386 (with CONFIG_4KSTACKS), - this gives more room for kernel interrupt processing without having - to increase the size of every per thread stack. + the split thread and interrupt stacks on i386, this gives more room + for kernel interrupt processing without having to increase the size + of every per thread stack. The interrupt stack is also used when processing a softirq.
Quoted 7 lines · Christoph Hellwig
IRQ stacks provide much better safety against unexpected stack use from interrupts, at the minimal downside of slightly higher memory usage. Enable irq stacks also for the default 8k stack to minimize the problem of stack overflows through interrupt activity.
This is what x86-64 and various other architectures already do.
We got rid of nested interrupts, so is this really a concern anymore ?
Thanks,
tglx
Quoted 11 lines · Thomas Gleixner
Quoted 7 lines · Christoph Hellwig
IRQ stacks provide much better safety against unexpected stack use from interrupts, at the minimal downside of slightly higher memory usage. Enable irq stacks also for the default 8k stack to minimize the problem of stack overflows through interrupt activity.
This is what x86-64 and various other architectures already do.
We got rid of nested interrupts, so is this really a concern anymore ?
Yes, especially for deep storage stacks anything that can come in unexpectedly from IRQ context is quite harmful. It's a really cheap way to avoid that indeterminism.
ping? This just came up again as a side-issue in the direct reclaim thread. x86-32 really is the only one out there still having this compared to the other common architetures like x86-64, powerpc and s390.
Quoted 83 lines · Christoph Hellwig
IRQ stacks provide much better safety against unexpected stack use from interrupts, at the minimal downside of slightly higher memory usage. Enable irq stacks also for the default 8k stack to minimize the problem of stack overflows through interrupt activity.
This is what x86-64 and various other architectures already do.
Signed-off-by Christoph Hellwig <[email protected]>Index: linux-2.6/arch/x86/Kconfig.debug
===================================================================arch/x86/Kconfig.debug +1
-2@@ -128,8 +128,7 @@ config 4KSTACKS If you say Y here the kernel will use a 4Kb stacksize for the kernel stack attached to each process/thread. This facilitates running more threads on a system and also reduces the pressure - on the VM subsystem for higher order allocations. This option - will also use IRQ stacks to compensate for the reduced stackspace. + on the VM subsystem for higher order allocations. config DOUBLEFAULT default yIndex:
linux-2.6/arch/x86/include/asm/irq.h
===================================================================arch/x86/include/asm/irq.h +5
-7@@ -19,18 +19,16 @@ static inline int irq_canonicalize(int i# define ARCH_HAS_NMI_WATCHDOG #endif -#ifdef CONFIG_4KSTACKS -extern void irq_ctx_init (int cpu); -extern void irq_ctx_exit (int cpu); -# define __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_X86_32 +extern void irq_ctx_init (int cpu); +extern void irq_ctx_exit (int cpu);#else # define irq_ctx_init (cpu) do { } while (0)# define irq_ctx_exit (cpu) do { } while (0) -# ifdef CONFIG_X86_64 -# define __ARCH_HAS_DO_SOFTIRQ -# endif #endif +#define __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_HOTPLUG_CPU #include <linux/cpumask.h> extern void fixup_irqs (void );Index:
linux-2.6/arch/x86/kernel/irq_32.c
===================================================================arch/x86/kernel/irq_32.c +0
-6@@ -49,7 +49,6 @@ static inline int check_stack_overflow(vstatic inline void print_stack_overflow (void ) { }#endif -#ifdef CONFIG_4KSTACKS /* * per-CPU IRQ handling contexts (thread information and stack) */ @@ -187,11 +186,6 @@ asmlinkage void do_softirq(void)local_irq_restore (flags); } -#else -static inline int -execute_on_irq_stack (int overflow,struct irq_desc *desc,int irq) {return 0 ; } -#endif -bool handle_irq (unsigned irq,struct pt_regs *regs) {struct irq_desc *desc;Index: linux-2.6/Documentation/x86/x86_64/kernel-stacks
===================================================================Documentation/x86/x86_64/kernel-stacks +0
-0@@ -18,9 +18,9 @@ specialized stacks contain no useful dat Used for external hardware interrupts. If this is the first external hardware interrupt (i.e. not a nested hardware interrupt) then the
Documentation/x86/x86_64/kernel-stacks specialized stacks contain no useful dat · line 26
Quoted 10 lines
Documentation/x86/x86_64/kernel-stacks +3
-3kernel switches from the current task to the interrupt stack. Like - the split thread and interrupt stacks on i386 (with CONFIG_4KSTACKS), - this gives more room for kernel interrupt processing without having - to increase the size of every per thread stack. + the split thread and interrupt stacks on i386, this gives more room + for kernel interrupt processing without having to increase the size + of every per thread stack. The interrupt stack is also used when processing a softirq.
---end quoted text---
Quoted 3 lines · Christoph Hellwig
ping? This just came up again as a side-issue in the direct reclaim thread. x86-32 really is the only one out there still having this compared to the other common architetures like x86-64, powerpc and s390.
We should also make 8K stacks the default on 32-bit. I.e. remove all the Kconfig distinctions and make the stack model similar on 32-bit and 64-bit x86.
Thanks,
Ingo
Quoted 10 lines · Ingo Molnar
Quoted 3 lines · Christoph Hellwig
ping? This just came up again as a side-issue in the direct reclaim thread. x86-32 really is the only one out there still having this compared to the other common architetures like x86-64, powerpc and s390.
We should also make 8K stacks the default on 32-bit. I.e. remove all the
Kconfigdistinctions and make the stack model similar on 32-bit and 64-bit x86.
Sounds fine to me. Do you want an additional patch for that or a respin to include it in one patch?
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Ingo Molnar
Quoted 3 lines · Christoph Hellwig
ping? This just came up again as a side-issue in the direct reclaim thread. x86-32 really is the only one out there still having this compared to the other common architetures like x86-64, powerpc and s390.
Quoted 6 lines
Quoted 3 lines
We should also make 8K stacks the default on 32-bit. I.e. remove all the
Kconfigdistinctions and make the stack model similar on 32-bit and 64-bit x86.Sounds fine to me. Do you want an additional patch for that or a respin to include it in one patch?
Two patches would be fine too - gives people something more finegrained to bisect to, should there be any problems.
Thanks,
Ingo