Re: [PATCH] x86: Get bp from the IRQ regs instead of directly from the CPU

From: Soeren Sandmann
Date: Thu Oct 29 2009 - 08:46:53 EST


Ingo Molnar <mingo@xxxxxxx> writes:

> > arch/x86/kernel/cpu/perf_event.c | 10 +++++++++-
> > 1 files changed, 9 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
> > index b5801c3..39b1d0c 100644
> > --- a/arch/x86/kernel/cpu/perf_event.c
> > +++ b/arch/x86/kernel/cpu/perf_event.c
> > @@ -2177,10 +2177,18 @@ static const struct stacktrace_ops backtrace_ops = {
> > static void
> > perf_callchain_kernel(struct pt_regs *regs, struct perf_callchain_entry *entry)
> > {
> > + unsigned long bp;
> > +
> > callchain_store(entry, PERF_CONTEXT_KERNEL);
> > callchain_store(entry, regs->ip);
> >
> > - dump_trace(NULL, regs, NULL, 0, &backtrace_ops, entry);
> > +#ifdef CONFIG_FRAME_POINTER
> > + bp = regs->bp;
> > +#else
> > + bp = 0;
> > +#endif
> > +
> > + dump_trace(NULL, regs, NULL, bp, &backtrace_ops, entry);
> > }
>
> Wouldnt it be better to push this logic into dump_trace() itself? That
> way other ways of backtrace generation would be improved as well, not
> just perf events call-chains.

Yes, it would, and I wrote the patch for that below, but then
discovered that getting bp from the IRQ registers makes stacktracing
not work at all on 64 bit. As I read entry_64.S, rbp ends up being
stored in regs->bx; maybe that's related.

I'll try and track down what is going on later.


Soren