2012-08-13 09:05:28

by Liu, Chuansheng

[permalink] [raw]
Subject: [PATCH] x86_dump_trace: avoiding endless " <IRQ> " is printed

From: liu chuansheng <[email protected]>
Subject: [PATCH] x86_dump_trace: avoiding endless " <IRQ> " is printed

Found the case that endless " <IRQ> " printing in dump_trace,
and no real meaningful stack traces are output, so there should
one rare case that possibly context->previous_esp = context or
other cases.

The endless " <IRQ> " is as below:
...
[ 82.215244,0] <IRQ>
[ 82.215399,0] <IRQ>
[ 82.215554,0] <IRQ>
[ 82.215710,0] <IRQ>
[ 82.215865,0] <IRQ>
[ 82.216022,0] <IRQ>
[ 82.216178,0] <IRQ>
[ 82.216333,0] <IRQ>
[ 82.216488,0] <IRQ>
[ 82.216643,0] <IRQ>
[ 82.216798,0] <IRQ>
[ 82.216953,0] <IRQ>
...

This patch aim is:
1/ Limiting the " <IRQ> " outputing, currently the max IRQ contexts
is 2(softirq+harirq combination);
2/ When the max IRQ contexts 2 is reached, print the context content
to confirm;

Signed-off-by: liu chuansheng <[email protected]>
---
arch/x86/kernel/dumpstack_32.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 1038a41..5387429 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -22,6 +22,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
const struct stacktrace_ops *ops, void *data)
{
int graph = 0;
+ int dump_irq = 0;

if (!task)
task = current;
@@ -47,8 +48,18 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
stack = (unsigned long *)context->previous_esp;
if (!stack)
break;
+
+ if (unlikely(dump_irq > 2)) {
+ printk(KERN_WARNING "break multi-IRQ print,"
+ "context=%08lx, stack=%08lx\n",
+ (unsigned long)context,
+ (unsigned long)stack);
+ break;
+ }
+
if (ops->stack(data, "IRQ") < 0)
break;
+ dump_irq++;
touch_nmi_watchdog();
}
}
--
1.7.0.4


2012-08-16 01:05:05

by Liu, Chuansheng

[permalink] [raw]
Subject: RE: [PATCH] x86_dump_trace: avoiding endless " <IRQ> " is printed


> The endless " <IRQ> " is as below:
> ...
> [ 82.215244,0] <IRQ>
> [ 82.215399,0] <IRQ>
> [ 82.215554,0] <IRQ>
> [ 82.215710,0] <IRQ>
> [ 82.215865,0] <IRQ>
> [ 82.216022,0] <IRQ>
> [ 82.216178,0] <IRQ>
> [ 82.216333,0] <IRQ>
> [ 82.216488,0] <IRQ>
> [ 82.216643,0] <IRQ>
> [ 82.216798,0] <IRQ>
> [ 82.216953,0] <IRQ>
> ...
>
Anyone can give some help for the above logs? It is the real case we meet on our x86_32 platform.
I checked the code, the tons of " <IRQ> " should be printed from the below code in dumpstack_32.c:
[if (ops->stack(data, "IRQ") < 0)] will print " <IRQ> ", as for the endless printing, it should be for(;;) is not
broken, so I guess in this case context->previous_esp == context.

But from code review, previous_esp is just set at hardirq. No possible this case happening.
Who can give help? Thanks.

void dump_trace(struct task_struct *task, struct pt_regs *regs,
unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data)
{
for (;;) {
struct thread_info *context;

context = (struct thread_info *)
((unsigned long)stack & (~(THREAD_SIZE - 1)));
bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);

stack = (unsigned long *)context->previous_esp;
if (!stack)
break;
if (ops->stack(data, "IRQ") < 0) == > Here printing the " <IRQ> "
break;
touch_nmi_watchdog();
}
}