linux-mips
[Top] [All Lists]

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

To: jiang.adam@gmail.com
Subject: Re: [PATCH] mips: irq: add statckoverflow detection
From: Sergei Shtylyov <sshtylyov@mvista.com>
Date: Sat, 21 Aug 2010 17:08:23 +0400
Cc: ralf@linux-mips.org, dmitri.vorobiev@movial.com, wuzhangjin@gmail.com, ddaney@caviumnetworks.com, peterz@infradead.org, fweisbec@gmail.com, tj@kernel.org, tglx@linutronix.de, mingo@elte.hu, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
In-reply-to: <1282372293-30211-1-git-send-email-jiang.adam@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1282372293-30211-1-git-send-email-jiang.adam@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)
Hello.

jiang.adam@gmail.com wrote:

From: Adam Jiang <jiang.adam@gmail.com>

Add stackoverflow detection to mips arch

Signed-off-by: Adam Jiang <jiang.adam@gmail.com>
[...]
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

<Prev in Thread] Current Thread [Next in Thread>