Re: [PATCH] mips: irq: add statckoverflow detection

From: Sergei Shtylyov
Date: Sat Aug 21 2010 - 09:10:07 EST


Hello.

jiang.adam@xxxxxxxxx wrote:

From: Adam Jiang <jiang.adam@xxxxxxxxx>

Add stackoverflow detection to mips arch

Signed-off-by: Adam Jiang <jiang.adam@xxxxxxxxx>
[...]
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index c6345f5..6334037 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -151,6 +151,22 @@ void __init init_IRQ(void)
#endif
}
+static inline void check_stack_overflow(void)
+{
+#ifdef CONFIG_DEBUG_STACKOVERFLOW

#ifdef within function is considered bad style. Better do it this way:

#ifdef CONFIG_DEBUG_STACKOVERFLOW
static inline void check_stack_overflow(void)
{
[...]
}
#else
static inline void check_stack_overflow(void) {}
#endif

+ long sp;
+
+ asm volatile("move %0, $sp" : "=r" (sp));
+ sp = sp & (THREAD_SIZE-1);
+
+ /* check for stack overflow: is there less then 2KB free? */

Hm, 2KB seems pretty large margin...

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/