public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: jia zhang <jia.zhang2008@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: tglx@linutronix.de, Ingo Molnar <mingo@elte.hu>, hpa@zytor.com
Subject: [PATCH] x86_64: fix the check point in stack_overflow_check
Date: Sun, 23 Nov 2008 09:51:41 +0800	[thread overview]
Message-ID: <4928B72D.20901@gmail.com> (raw)

stack_overflow_check() should consider the stack usage of pt_regs, and thus it could warn us in advance. Additionally, it looks a bit good that the warning time starts at INITIAL_JIFFIES.

Signed-off-by: jia zhang <jia.zhang2008@gmail.com>
---
Assume at the moment rsp get close to the check point before interrupt arrives.
When interrupt really happens, thread_info will be partly overrode.

 arch/x86/kernel/irq_64.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -29,11 +29,12 @@
 static inline void stack_overflow_check(struct pt_regs *regs)
 {
 	u64 curbase = (u64)task_stack_page(current);
-	static unsigned long warned = -60*HZ;
+	static unsigned long warned = INITIAL_JIFFIES - 60*HZ;
 
 	if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE &&
-	    regs->sp <  curbase + sizeof(struct thread_info) + 128 &&
-	    time_after(jiffies, warned + 60*HZ)) {
+			regs->sp < curbase + sizeof(struct thread_info) +
+			sizeof(struct pt_regs) + 128 &&
+			time_after(jiffies, warned + 60*HZ)) {
 		printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
 		       current->comm, curbase, regs->sp);
 		show_stack(NULL,NULL);


             reply	other threads:[~2008-11-23  1:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-23  1:51 jia zhang [this message]
2008-11-23  8:08 ` [PATCH] x86: clean up stack overflow debug check Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2008-11-22  9:10 [PATCH] x86_64: fix the check point in stack_overflow_check jia zhang

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=4928B72D.20901@gmail.com \
    --to=jia.zhang2008@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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