* [PATCH] sched: Fix __schedule_bug() output when called from an interrupt
@ 2012-03-29 0:10 Stephen Boyd
2012-03-29 7:16 ` [tip:sched/urgent] " tip-bot for Stephen Boyd
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2012-03-29 0:10 UTC (permalink / raw)
To: linux-kernel; +Cc: Satyam Sharma, Ingo Molnar, Peter Zijlstra
If schedule is called from an interrupt handler __schedule_bug()
will call show_regs() with the registers saved during the
interrupt handling done in do_IRQ(). This means we'll see the
registers and the backtrace for the process that was interrupted
and not the full backtrace explaining who called schedule().
This is due to 838225b (sched: use show_regs() to improve
__schedule_bug() output, 2007-10-24) which improperly assumed
that get_irq_regs() would return the registers for the current
stack because it is being called from within an interrupt
handler. Simply remove the show_reg() code so that we dump a
backtrace for the interrupt handler that called schedule().
Cc: Satyam Sharma <satyam@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
I ran across this when I was presented with a scheduling while
atomic log with a stacktrace pointing at spin_unlock_irqrestore().
It made no sense and I had to guess what interrupt handler could
be called and poke around for someone calling schedule() in an
interrupt handler. A simple test of putting an msleep() in
an interrupt handler works better with this patch because you
can actually see the msleep() call in the backtrace.
kernel/sched/core.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3b4e8b7..b496a0b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3101,8 +3101,6 @@ EXPORT_SYMBOL(sub_preempt_count);
*/
static noinline void __schedule_bug(struct task_struct *prev)
{
- struct pt_regs *regs = get_irq_regs();
-
if (oops_in_progress)
return;
@@ -3113,11 +3111,7 @@ static noinline void __schedule_bug(struct task_struct *prev)
print_modules();
if (irqs_disabled())
print_irqtrace_events(prev);
-
- if (regs)
- show_regs(regs);
- else
- dump_stack();
+ dump_stack();
}
/*
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip:sched/urgent] sched: Fix __schedule_bug() output when called from an interrupt
2012-03-29 0:10 [PATCH] sched: Fix __schedule_bug() output when called from an interrupt Stephen Boyd
@ 2012-03-29 7:16 ` tip-bot for Stephen Boyd
2012-03-29 13:39 ` Chris Metcalf
0 siblings, 1 reply; 3+ messages in thread
From: tip-bot for Stephen Boyd @ 2012-03-29 7:16 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, peterz, cmetcalf, sboyd, satyam, tglx
Commit-ID: 6135fc1eb4b1c9ae5f535507ed59591bab51e630
Gitweb: http://git.kernel.org/tip/6135fc1eb4b1c9ae5f535507ed59591bab51e630
Author: Stephen Boyd <sboyd@codeaurora.org>
AuthorDate: Wed, 28 Mar 2012 17:10:47 -0700
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 29 Mar 2012 08:34:45 +0200
sched: Fix __schedule_bug() output when called from an interrupt
If schedule is called from an interrupt handler __schedule_bug()
will call show_regs() with the registers saved during the
interrupt handling done in do_IRQ(). This means we'll see the
registers and the backtrace for the process that was interrupted
and not the full backtrace explaining who called schedule().
This is due to 838225b ("sched: use show_regs() to improve
__schedule_bug() output", 2007-10-24) which improperly assumed
that get_irq_regs() would return the registers for the current
stack because it is being called from within an interrupt
handler. Simply remove the show_reg() code so that we dump a
backtrace for the interrupt handler that called schedule().
[ I ran across this when I was presented with a scheduling while
atomic log with a stacktrace pointing at spin_unlock_irqrestore().
It made no sense and I had to guess what interrupt handler could
be called and poke around for someone calling schedule() in an
interrupt handler. A simple test of putting an msleep() in
an interrupt handler works better with this patch because you
can actually see the msleep() call in the backtrace. ]
Also-reported-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Satyam Sharma <satyam@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1332979847-27102-1-git-send-email-sboyd@codeaurora.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/core.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9c1629c..929fd85 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3099,8 +3099,6 @@ EXPORT_SYMBOL(sub_preempt_count);
*/
static noinline void __schedule_bug(struct task_struct *prev)
{
- struct pt_regs *regs = get_irq_regs();
-
if (oops_in_progress)
return;
@@ -3111,11 +3109,7 @@ static noinline void __schedule_bug(struct task_struct *prev)
print_modules();
if (irqs_disabled())
print_irqtrace_events(prev);
-
- if (regs)
- show_regs(regs);
- else
- dump_stack();
+ dump_stack();
}
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [tip:sched/urgent] sched: Fix __schedule_bug() output when called from an interrupt
2012-03-29 7:16 ` [tip:sched/urgent] " tip-bot for Stephen Boyd
@ 2012-03-29 13:39 ` Chris Metcalf
0 siblings, 0 replies; 3+ messages in thread
From: Chris Metcalf @ 2012-03-29 13:39 UTC (permalink / raw)
To: mingo, hpa, linux-kernel, satyam, peterz, cmetcalf, tglx, sboyd
Cc: linux-tip-commits
On 3/29/2012 3:16 AM, tip-bot for Stephen Boyd wrote:
> Commit-ID: 6135fc1eb4b1c9ae5f535507ed59591bab51e630
> Gitweb: http://git.kernel.org/tip/6135fc1eb4b1c9ae5f535507ed59591bab51e630
> Author: Stephen Boyd <sboyd@codeaurora.org>
> AuthorDate: Wed, 28 Mar 2012 17:10:47 -0700
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitDate: Thu, 29 Mar 2012 08:34:45 +0200
>
> sched: Fix __schedule_bug() output when called from an interrupt
>
> If schedule is called from an interrupt handler __schedule_bug()
> will call show_regs() with the registers saved during the
> interrupt handling done in do_IRQ(). This means we'll see the
> registers and the backtrace for the process that was interrupted
> and not the full backtrace explaining who called schedule().
>
> This is due to 838225b ("sched: use show_regs() to improve
> __schedule_bug() output", 2007-10-24) which improperly assumed
> that get_irq_regs() would return the registers for the current
> stack because it is being called from within an interrupt
> handler. Simply remove the show_reg() code so that we dump a
> backtrace for the interrupt handler that called schedule().
>
> [ I ran across this when I was presented with a scheduling while
> atomic log with a stacktrace pointing at spin_unlock_irqrestore().
> It made no sense and I had to guess what interrupt handler could
> be called and poke around for someone calling schedule() in an
> interrupt handler. A simple test of putting an msleep() in
> an interrupt handler works better with this patch because you
> can actually see the msleep() call in the backtrace. ]
>
> Also-reported-by: Chris Metcalf <cmetcalf@tilera.com>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Satyam Sharma <satyam@infradead.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Link: http://lkml.kernel.org/r/1332979847-27102-1-git-send-email-sboyd@codeaurora.org
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
We have been using this same exact patch internally for a while now, and by
a curious fluke of timing, I sent email to Ingo and to Satyam Sharma
pointing out that we really should re-look at the original change just
yesterday :-)
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-29 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 0:10 [PATCH] sched: Fix __schedule_bug() output when called from an interrupt Stephen Boyd
2012-03-29 7:16 ` [tip:sched/urgent] " tip-bot for Stephen Boyd
2012-03-29 13:39 ` Chris Metcalf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.