From: Christoph Hellwig <hch@lst.de>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86-32: always use irq stacks
Date: Wed, 26 May 2010 13:09:23 +0200 [thread overview]
Message-ID: <20100526110923.GA28414@lst.de> (raw)
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 <hch@lst.de>
Index: linux-2.6/arch/x86/Kconfig.debug
===================================================================
--- linux-2.6.orig/arch/x86/Kconfig.debug 2010-05-25 18:45:43.048276085 +0200
+++ linux-2.6/arch/x86/Kconfig.debug 2010-05-25 18:45:53.603003841 +0200
@@ -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
Index: linux-2.6/arch/x86/include/asm/irq.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/irq.h 2010-05-25 18:45:43.040025143 +0200
+++ linux-2.6/arch/x86/include/asm/irq.h 2010-05-25 18:45:53.604003981 +0200
@@ -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
===================================================================
--- linux-2.6.orig/arch/x86/kernel/irq_32.c 2010-05-25 18:45:42.981006006 +0200
+++ linux-2.6/arch/x86/kernel/irq_32.c 2010-05-25 18:45:53.606003632 +0200
@@ -49,7 +49,6 @@ static inline int check_stack_overflow(v
static 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
===================================================================
--- linux-2.6.orig/Documentation/x86/x86_64/kernel-stacks 2010-05-25 18:45:55.631004120 +0200
+++ linux-2.6/Documentation/x86/x86_64/kernel-stacks 2010-05-25 18:46:21.785256528 +0200
@@ -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.
next reply other threads:[~2010-05-26 11:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 11:09 Christoph Hellwig [this message]
2010-05-26 12:47 ` [PATCH] x86-32: always use irq stacks Thomas Gleixner
2010-05-26 13:00 ` Christoph Hellwig
2010-06-16 5:16 ` Christoph Hellwig
2010-06-16 5:56 ` Ingo Molnar
2010-06-16 6:27 ` Christoph Hellwig
2010-06-16 7:32 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100526110923.GA28414@lst.de \
--to=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox