[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090325120944.GA30873@pengutronix.de>
Date: Wed, 25 Mar 2009 13:09:44 +0100
From: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
To: Russell King - ARM Linux <linux@....linux.org.uk>
Cc: Ingo Molnar <mingo@...e.hu>,
Frederic Weisbecker <fweisbec@...il.com>,
Abhishek Sagar <sagar.abhishek@...il.com>,
Tim Bird <tim.bird@...sony.com>,
linux-arm-kernel <linux-arm-kernel@...ts.arm.linux.org.uk>,
linux kernel <linux-kernel@...r.kernel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>
Subject: Re: Anyone working on ftrace function graph support on ARM?
Hi Russell,
> > > Hmm, and it looks like the ftrace code is rather crap:
> > >
> > > ENTRY(mcount)
> > > stmdb sp!, {r0-r3, lr}
> > > ldr r0, =ftrace_trace_function
> > > ldr r2, [r0]
> > > adr r0, ftrace_stub
> > > cmp r0, r2
> > > bne trace
> > > ldr lr, [fp, #-4] @ restore lr
> > > ldmia sp!, {r0-r3, pc}
> > >
> > > trace:
> > > ldr r1, [fp, #-4] @ lr of instrumented routine
> > > mov r0, lr
> > > sub r0, r0, #MCOUNT_INSN_SIZE
> > > mov lr, pc
> > > mov pc, r2
> > > XXX calling a C function results in r0-r3,ip,lr being clobbered XXX
> > >
> > > mov lr, r1 @ restore lr
> > > XXX not necessarily, r1 might be some other random value
> > >
> > > ldmia sp!, {r0-r3, pc}
> > >
> > > In fact, to me the above code looks totally crap, because it's checking
> > > whether the caller is 'ftrace_stub'. It can never be 'ftrace_stub'
> > > because that is an assembly function:
> > >
> > > .globl ftrace_stub
> > > ftrace_stub:
> > > mov pc, lr
> > >
> > > and therefore gcc has no hand in adding a mcount call to it.
> > Hhhm. Isn't the equivalent C-Code ~ as follows:
> >
> > if (ftrace_trace_function != ftrace_stub)
> > trace(some, args);
> > return;
> > ? ftrace_trace_function is initialised to ftrace_stub at compile time
> > and is changed when a tracerfunction is registered.
>
> Correct. But my point is that there's no way for ftrace_stub to ever call
> mcount. So the check there is pointless.
Which check? ftrace_trace_function isn't the caller of mcount but a
function pointer defined in kernel/trace/ftrace.c. And if this pointer
changes, the if-condition becomes true.
> Ok - it would be nice if there was a comment to explain that.
Some comments would be nice, that's right.
> Is someone going to fix the existing ftrace before trying to build stuff
> on top of it?
Mmh, I think you misunderstood the code, so I don't see something to fix
here (at least for non-dynamic ftrace). If the next few mails show,
that it's me who didn't understand the code, I will fix the problems, of
course.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists