From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 2/2] x86: Make the x86-64 stacktrace code safely callable from scheduler
Date: Thu, 12 May 2011 22:32:06 +0200 [thread overview]
Message-ID: <1305232326-9804-3-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1305232326-9804-1-git-send-email-fweisbec@gmail.com>
Avoid potential scheduler recursion and deadlock from the
stacktrace code by avoiding rescheduling when we re-enable
preemption.
This robustifies some scheduler trace events like sched switch
when they are used to produce callchains in perf or ftrace.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
arch/x86/kernel/dumpstack_64.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index e71c98d..8e4f1d0 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -143,13 +143,16 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data)
{
- const unsigned cpu = get_cpu();
- unsigned long *irq_stack_end =
- (unsigned long *)per_cpu(irq_stack_ptr, cpu);
+ unsigned long *irq_stack_end;
unsigned used = 0;
struct thread_info *tinfo;
int graph = 0;
unsigned long dummy;
+ int cpu;
+
+ preempt_disable();
+
+ cpu = smp_processor_id();
if (!task)
task = current;
@@ -168,6 +171,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
* exceptions
*/
tinfo = task_thread_info(task);
+ irq_stack_end = (unsigned long *)__get_cpu_var(irq_stack_ptr);
for (;;) {
char *id;
unsigned long *estack_end;
@@ -219,7 +223,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
* This handles the process stack:
*/
bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
- put_cpu();
+
+ /* We want stacktrace to be computable anywhere, even in the scheduler */
+ preempt_enable_no_resched();
}
EXPORT_SYMBOL(dump_trace);
--
1.7.3.2
next prev parent reply other threads:[~2011-05-12 20:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-12 20:32 [GIT PULL] x86 stacktrace updates Frederic Weisbecker
2011-05-12 20:32 ` [PATCH 1/2] x86: Remove warning and warning_symbol from struct stacktrace_ops Frederic Weisbecker
2011-07-14 11:01 ` Mel Gorman
2011-07-14 13:50 ` Frederic Weisbecker
2011-05-12 20:32 ` Frederic Weisbecker [this message]
2011-05-12 20:40 ` [PATCH 2/2] x86: Make the x86-64 stacktrace code safely callable from scheduler Frederic Weisbecker
2011-05-12 21:28 ` Ingo Molnar
2011-05-12 21:43 ` Frederic Weisbecker
2011-05-12 21:55 ` Ingo Molnar
2011-05-13 10:48 ` Steven Rostedt
2011-05-13 12:48 ` Frederic Weisbecker
2011-05-13 13:19 ` Peter Zijlstra
2011-05-13 13:29 ` Frederic Weisbecker
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=1305232326-9804-3-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--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