diff options
author | jia zhang <jia.zhang2008@gmail.com> | 2008-11-22 20:51:41 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-23 02:57:42 -0500 |
commit | 3aeb95d5b7839708a8d8e11aa274ee4d0d4042cc (patch) | |
tree | d9bdb97ddbcb914f019cd6db2a5f035f34a3fb4c /arch/x86/kernel/irq_64.c | |
parent | ca9eed76133c00e7f4b1eeb4c1a6cb800cd2654c (diff) |
x86_64: fix the check in stack_overflow_check
Impact: make stack overflow debug check and printout narrower
stack_overflow_check() should consider the stack usage of pt_regs, and
thus it could warn us in advance. Additionally, it looks better for
the warning time to start at INITIAL_JIFFIES.
Assuming that rsp gets close to the check point before interrupt
arrives: when interrupt really happens, thread_info will be partly
overrode.
Signed-off-by: jia zhang <jia.zhang2008@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/irq_64.c')
-rw-r--r-- | arch/x86/kernel/irq_64.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c index 60eb84eb77a..b842fc82be1 100644 --- a/arch/x86/kernel/irq_64.c +++ b/arch/x86/kernel/irq_64.c | |||
@@ -29,11 +29,12 @@ | |||
29 | static inline void stack_overflow_check(struct pt_regs *regs) | 29 | static inline void stack_overflow_check(struct pt_regs *regs) |
30 | { | 30 | { |
31 | u64 curbase = (u64)task_stack_page(current); | 31 | u64 curbase = (u64)task_stack_page(current); |
32 | static unsigned long warned = -60*HZ; | 32 | static unsigned long warned = INITIAL_JIFFIES - 60*HZ; |
33 | 33 | ||
34 | if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE && | 34 | if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE && |
35 | regs->sp < curbase + sizeof(struct thread_info) + 128 && | 35 | regs->sp < curbase + sizeof(struct thread_info) + |
36 | time_after(jiffies, warned + 60*HZ)) { | 36 | sizeof(struct pt_regs) + 128 && |
37 | time_after(jiffies, warned + 60*HZ)) { | ||
37 | printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n", | 38 | printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n", |
38 | current->comm, curbase, regs->sp); | 39 | current->comm, curbase, regs->sp); |
39 | show_stack(NULL,NULL); | 40 | show_stack(NULL,NULL); |