Re: [2.6 patch] i386: always use 4k stacks

Diego Calleja
2005-12-16T13:10:03Z

El Thu, 15 Dec 2005 14:00:13 -0800,
Andrew Morton <akpm@osdl.org> escribió:

> Supporting 8k stacks is a small amount of code and nobody has seen a need
> to make changes in there for quite a long time. So there's little cost to
> keeping the existing code.
>
> And the existing code is useful:

Maybe this slighty different approach is better?

Signed-off-by: Diego Calleja <diegocg@gmail.com>

Index: test/arch/i386/Kconfig.debug
===================================================================
--- test.orig/arch/i386/Kconfig.debug 2005-12-16 13:59:54.000000000 +0100
+++ test/arch/i386/Kconfig.debug 2005-12-16 14:03:27.000000000 +0100
@@ -42,15 +42,16 @@
This results in a large slowdown, but helps to find certain types
of memory corruptions.

-config 4KSTACKS
- bool "Use 4Kb for kernel stacks instead of 8Kb"
+config 8KSTACKS
+ bool "Use 8Kb for kernel stacks instead of 4Kb"
depends on DEBUG_KERNEL
help
- 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
+ If you say Y here the kernel will use a 8Kb stacksize for the
+ kernel stack attached to each process/thread. This makes harder
+ to overflow the stack, and it's used to debug possible stack
+ overflow problems. Notice that this increases the pressure
on the VM subsystem for higher order allocations. This option
- will also use IRQ stacks to compensate for the reduced stackspace.
+ will also disable IRQ stacks.

config X86_FIND_SMP_CONFIG
bool
Index: test/arch/i386/kernel/irq.c
===================================================================
--- test.orig/arch/i386/kernel/irq.c 2005-12-16 13:59:54.000000000 +0100
+++ test/arch/i386/kernel/irq.c 2005-12-16 14:01:24.000000000 +0100
@@ -33,7 +33,7 @@
}
#endif

-#ifdef CONFIG_4KSTACKS
+#ifndef CONFIG_8KSTACKS
/*
* per-CPU IRQ handling contexts (thread information and stack)
*/
@@ -55,7 +55,7 @@
{
/* high bits used in ret_from_ code */
int irq = regs->orig_eax & 0xff;
-#ifdef CONFIG_4KSTACKS
+#ifndef CONFIG_8KSTACKS
union irq_ctx *curctx, *irqctx;
u32 *isp;
#endif
@@ -76,7 +76,7 @@
}
#endif

-#ifdef CONFIG_4KSTACKS
+#ifndef CONFIG_8KSTACKS

curctx = (union irq_ctx *) current_thread_info();
irqctx = hardirq_ctx[smp_processor_id()];
@@ -112,7 +112,7 @@
return 1;
}

-#ifdef CONFIG_4KSTACKS
+#ifndef CONFIG_8KSTACKS

/*
* These should really be __section__(".bss.page_aligned") as well, but
Index: test/include/asm-i386/irq.h
===================================================================
--- test.orig/include/asm-i386/irq.h 2005-12-16 13:59:54.000000000 +0100
+++ test/include/asm-i386/irq.h 2005-12-16 14:04:05.000000000 +0100
@@ -27,7 +27,7 @@
# define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */
#endif

-#ifdef CONFIG_4KSTACKS
+#ifndef CONFIG_8KSTACKS
extern void irq_ctx_init(int cpu);
extern void irq_ctx_exit(int cpu);
# define __ARCH_HAS_DO_SOFTIRQ
Index: test/include/asm-i386/module.h
===================================================================
--- test.orig/include/asm-i386/module.h 2005-12-16 13:59:54.000000000 +0100
+++ test/include/asm-i386/module.h 2005-12-16 14:04:36.000000000 +0100
@@ -64,8 +64,8 @@
#define MODULE_REGPARM ""
#endif

-#ifdef CONFIG_4KSTACKS
-#define MODULE_STACKSIZE "4KSTACKS "
+#ifdef CONFIG_8KSTACKS
+#define MODULE_STACKSIZE "8KSTACKS "
#else
#define MODULE_STACKSIZE ""
#endif
Index: test/include/asm-i386/thread_info.h
===================================================================
--- test.orig/include/asm-i386/thread_info.h 2005-12-16 13:59:54.000000000 +0100
+++ test/include/asm-i386/thread_info.h 2005-12-16 14:04:57.000000000 +0100
@@ -53,7 +53,7 @@
#endif

#define PREEMPT_ACTIVE 0x10000000
-#ifdef CONFIG_4KSTACKS
+#ifndef CONFIG_8KSTACKS
#define THREAD_SIZE (4096)
#else
#define THREAD_SIZE (8192)