public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>, David Chinner <dgc@sgi.com>,
	Zan Lynx <zlynx@acm.org>, Adrian Bunk <bunk@stusta.de>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [1/6] make stack size configurable (was: Re: [-mm patch] i386: enable 4k stacks by default)
Date: Mon, 30 Apr 2007 10:40:47 -0700	[thread overview]
Message-ID: <20070430174047.GD19966@holomorphy.com> (raw)
In-Reply-To: <20070430173819.GC19966@holomorphy.com>

On Mon, Apr 30, 2007 at 10:38:19AM -0700, William Lee Irwin III wrote:
> Here's what I did for i386 for someone concerned about blowing the stack.

Make more stack sizes configurable, adding options for deeper stacks.
This is largely for differential diagnosis in cases where stack overflows
are suspected of silently corrupting memory or causing other problems not
detected immediately.

Signed-off-by: William Irwin <wli@holomorphy.com>


Index: stack-paranoia/arch/i386/Kconfig.debug
===================================================================
--- stack-paranoia.orig/arch/i386/Kconfig.debug	2007-04-30 10:26:15.863869853 -0700
+++ stack-paranoia/arch/i386/Kconfig.debug	2007-04-30 10:31:43.878562345 -0700
@@ -56,6 +56,10 @@
 	  portion of the kernel code won't be covered by a 2MB TLB anymore.
 	  If in doubt, say "N".
 
+choice
+	prompt "Stack size"
+	default 8KSTACKS
+
 config 4KSTACKS
 	bool "Use 4Kb for kernel stacks instead of 8Kb"
 	depends on DEBUG_KERNEL
@@ -66,6 +70,37 @@
 	  on the VM subsystem for higher order allocations. This option
 	  will also use IRQ stacks to compensate for the reduced stackspace.
 
+config 8KSTACKS
+	bool "Use 8KB for kernel stacks"
+	help
+	  If you say Y here, the kernel will use its standard stacksize.
+
+config 16KSTACKS
+	bool "Use 16KB for kernel stacks"
+	help
+	  If you say Y here, the kernel will use a 16KB stacksize.
+	  This impedes running more threads on a system and also increases
+	  the pressure on the VM subsystem for higher order allocations.
+	  This option will also use IRQ stacks to for additional safety.
+
+config 32KSTACKS
+	bool "Use 32KB for kernel stacks"
+	help
+	  If you say Y here, the kernel will use a 32KB stacksize.
+	  This impedes running more threads on a system and also increases
+	  the pressure on the VM subsystem for higher order allocations.
+	  This option will also use IRQ stacks to for additional safety.
+
+config 64KSTACKS
+	bool "Use 64KB for kernel stacks"
+	help
+	  If you say Y here, the kernel will use a 64KB stacksize.
+	  This impedes running more threads on a system and also increases
+	  the pressure on the VM subsystem for higher order allocations.
+	  This option will also use IRQ stacks to for additional safety.
+
+endchoice
+
 config X86_FIND_SMP_CONFIG
 	bool
 	depends on X86_LOCAL_APIC || X86_VOYAGER
Index: stack-paranoia/include/asm-i386/module.h
===================================================================
--- stack-paranoia.orig/include/asm-i386/module.h	2007-04-30 10:26:31.992788987 -0700
+++ stack-paranoia/include/asm-i386/module.h	2007-04-30 10:31:43.882562573 -0700
@@ -64,8 +64,14 @@
 
 #ifdef CONFIG_4KSTACKS
 #define MODULE_STACKSIZE "4KSTACKS "
-#else
-#define MODULE_STACKSIZE ""
+#elif defined(CONFIG_8KSTACKS)
+#define MODULE_STACKSIZE "8KSTACKS "
+#elif defined(CONFIG_16KSTACKS)
+#define MODULE_STACKSIZE "16KSTACKS "
+#elif defined(CONFIG_32KSTACKS)
+#define MODULE_STACKSIZE "32KSTACKS "
+#elif defined(CONFIG_64KSTACKS)
+#define MODULE_STACKSIZE "64KSTACKS "
 #endif
 
 #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
Index: stack-paranoia/include/asm-i386/thread_info.h
===================================================================
--- stack-paranoia.orig/include/asm-i386/thread_info.h	2007-04-30 10:26:32.104795370 -0700
+++ stack-paranoia/include/asm-i386/thread_info.h	2007-04-30 10:31:43.882562573 -0700
@@ -54,9 +54,17 @@
 
 #define PREEMPT_ACTIVE		0x10000000
 #ifdef CONFIG_4KSTACKS
-#define THREAD_SIZE            (4096)
-#else
+#define THREAD_SIZE		(4096)
+#elif defined(CONFIG_8KSTACKS)
 #define THREAD_SIZE		(8192)
+#elif defined(CONFIG_16KSTACKS)
+#define THREAD_SIZE		(16384)
+#elif defined(CONFIG_32KSTACKS)
+#define THREAD_SIZE		(32768)
+#elif defined(CONFIG_64KSTACKS)
+#define THREAD_SIZE		(65536)
+#else
+#error stack size unconfigured
 #endif
 
 #define STACK_WARN             (THREAD_SIZE/8)

  reply	other threads:[~2007-04-30 17:43 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-28 19:19 [-mm patch] i386: enable 4k stacks by default Adrian Bunk
2007-04-28 21:18 ` Zan Lynx
2007-04-30  3:58   ` David Chinner
2007-04-30  8:17     ` Alan Cox
2007-04-30 10:26       ` Andi Kleen
2007-04-30 10:48         ` Christoph Hellwig
2007-04-30 12:13           ` Andi Kleen
2007-04-30 17:38             ` William Lee Irwin III
2007-04-30 17:40               ` William Lee Irwin III [this message]
2007-04-30 18:10                 ` [1/6] make stack size configurable (was: Re: [-mm patch] i386: enable 4k stacks by default) Christoph Hellwig
2007-04-30 18:13                   ` William Lee Irwin III
2007-04-30 18:25                 ` Adrian Bunk
2007-04-30 18:32                   ` William Lee Irwin III
2007-04-30 17:43               ` [2/6] add config option to vmalloc stacks " William Lee Irwin III
2007-04-30 18:11                 ` Christoph Hellwig
2007-04-30 18:25                   ` Jan Engelhardt
2007-04-30 19:09                   ` William Lee Irwin III
2007-04-30 19:15                     ` Christoph Hellwig
2007-04-30 19:23                       ` Bill Irwin
2007-04-30 22:04                       ` Bill Irwin
2007-05-01 22:36                       ` Matt Mackall
2007-05-01 22:51                         ` Bill Irwin
2007-05-01 23:07                           ` Alan Cox
2007-05-01 23:23                             ` Bill Irwin
2007-05-01 23:15                           ` Matt Mackall
2007-05-01 23:27                             ` Bill Irwin
2007-05-04  5:35                 ` Joseph Fannin
2007-05-04  7:43                   ` Bill Irwin
2007-04-30 17:44               ` [3/6] make IRQ stacks independently configurable " William Lee Irwin III
2007-04-30 18:11                 ` Christoph Hellwig
2007-04-30 18:14                   ` William Lee Irwin III
2007-04-30 17:45               ` [4/6] go BUG on vmallocspace in __pa() " William Lee Irwin III
2007-04-30 18:52                 ` Andi Kleen
2007-04-30 18:58                   ` William Lee Irwin III
2007-04-30 19:20                   ` Alan Cox
2007-04-30 19:26                     ` Bill Irwin
2007-05-02 22:31                 ` [4/6] go BUG on vmallocspace in __pa() Jeremy Fitzhardinge
2007-05-02 22:48                   ` Bill Irwin
2007-04-30 17:46               ` [5/6] dynamically allocate IRQ stacks (was: Re: [-mm patch] i386: enable 4k stacks by default) William Lee Irwin III
2007-04-30 19:49                 ` Zwane Mwaikambo
2007-04-30 20:03                   ` Bill Irwin
2007-04-30 20:07                   ` Andi Kleen
2007-04-30 17:47               ` [6/6] arrange for a guard page on cpu 0's IRQ stack " William Lee Irwin III
2007-04-30 18:22               ` [-mm patch] i386: enable 4k stacks by default Jan Engelhardt
2007-04-30 18:35                 ` William Lee Irwin III
2007-04-30 18:51               ` Andi Kleen
2007-04-30  8:55   ` Neil Brown
2007-04-30  8:59     ` Christoph Hellwig
2007-04-30 11:30       ` Jens Axboe
2007-04-30 23:24         ` Neil Brown
2007-05-01  8:01           ` Jens Axboe

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=20070430174047.GD19966@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andi@firstfloor.org \
    --cc=bunk@stusta.de \
    --cc=dgc@sgi.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zlynx@acm.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