From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>,
Abhishek Sagar <sagar.abhishek@gmail.com>,
Tim Bird <tim.bird@am.sony.com>,
linux-arm-kernel <linux-arm-kernel@lists.arm.linux.org.uk>,
linux kernel <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: Anyone working on ftrace function graph support on ARM?
Date: Wed, 25 Mar 2009 11:21:15 +0000 [thread overview]
Message-ID: <20090325112115.GB31464@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20090325104505.GA27803@pengutronix.de>
On Wed, Mar 25, 2009 at 11:45:05AM +0100, Uwe Kleine-König wrote:
> Hi Russell,
>
> On Wed, Mar 25, 2009 at 09:57:51AM +0000, Russell King - ARM Linux wrote:
> > On Wed, Mar 25, 2009 at 09:54:18AM +0100, Ingo Molnar wrote:
> > > Unwinding is not realistic or desired for the function tracer - it
> > > runs in every kernel function so performance is paramount.
> >
> > Which would also include the unwinder itself as well.
> >
> > > So, if i understood you correctly, an OABI_COMPAT and FRAME_POINTERS
> > > dependency has to be added to the ARM HAVE_FUNCTION_GRAPH_TRACER
> > > Kconfig rule.
> >
> > If we have frame pointers enabled with EABI, then it looks like it will
> > work as well. So the dependency should be on FRAME_POINTERS for _every_
> > feature using the mcount code.
> >
> > 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.
> > Moreover, the _dynamic_ ftrace code does this:
> >
> > ENTRY(mcount)
> > stmdb sp!, {r0-r3, lr}
> > mov r0, lr
> > sub r0, r0, #MCOUNT_INSN_SIZE
> >
> > .globl mcount_call
> > mcount_call:
> > bl ftrace_stub
> > ldr lr, [fp, #-4] @ restore lr
> > ldmia sp!, {r0-r3, pc}
> >
> > ENTRY(ftrace_caller)
> > stmdb sp!, {r0-r3, lr}
> > ldr r1, [fp, #-4]
> > mov r0, lr
> > sub r0, r0, #MCOUNT_INSN_SIZE
> >
> > .globl ftrace_call
> > ftrace_call:
> > bl ftrace_stub
> > ldr lr, [fp, #-4] @ restore lr
> > ldmia sp!, {r0-r3, pc}
> >
> > In other words, it pushes some words onto the stack, sets r0, calls
> > an assembly function which does nothing but just returns, reloads lr,
> > restores the stack and returns. This ftrace implementation looks like
> > an exercise in slowing down execution to me with no added value.
> The idea is that the instruction at address mcount_call (and
> ftrace_call IIRC) is rewritten at run time.
> Still the code is not active currently (because CONFIG_DYNAMIC_FTRACE
> isn't selectable for ARM) and needs some care anyhow on reactivation
> because the way how dynamic ftrace works changed somehow. Didn't look
> at it up to now though.
Ok - it would be nice if there was a comment to explain that.
Is someone going to fix the existing ftrace before trying to build stuff
on top of it?
next prev parent reply other threads:[~2009-03-25 11:22 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-24 19:38 Anyone working on ftrace function graph support on ARM? Tim Bird
2009-03-24 20:25 ` Ingo Molnar
2009-03-24 20:48 ` Tim Bird
2009-03-24 20:38 ` Uwe Kleine-König
2009-03-24 21:36 ` Frederic Weisbecker
2009-03-24 21:40 ` Tim Bird
2009-03-24 21:48 ` Ingo Molnar
2009-03-24 21:57 ` Frederic Weisbecker
2009-03-24 22:14 ` Ingo Molnar
2009-03-24 22:54 ` Frederic Weisbecker
2009-03-25 8:36 ` Russell King - ARM Linux
2009-03-25 16:00 ` Steven Rostedt
2009-03-25 17:13 ` Frederic Weisbecker
2009-03-25 20:27 ` [PATCH][GIT PULL] x86, function-graph: only save return values on x86_64 Steven Rostedt
2009-03-25 20:45 ` Jaswinder Singh Rajput
2009-03-25 21:26 ` Steven Rostedt
2009-04-08 16:09 ` Ingo Molnar
2009-04-08 16:37 ` Steven Rostedt
2009-04-08 16:41 ` Ingo Molnar
2009-04-08 17:40 ` Frederic Weisbecker
2009-03-24 22:29 ` Anyone working on ftrace function graph support on ARM? Abhishek Sagar
2009-03-24 22:48 ` Frederic Weisbecker
2009-03-25 8:42 ` Russell King - ARM Linux
2009-03-25 8:54 ` Ingo Molnar
2009-03-25 9:57 ` Russell King - ARM Linux
2009-03-25 10:45 ` Uwe Kleine-König
2009-03-25 11:21 ` Russell King - ARM Linux [this message]
2009-03-25 12:09 ` Uwe Kleine-König
2009-03-25 16:41 ` Tim Bird
2009-03-25 11:41 ` Frederic Weisbecker
2009-03-25 16:34 ` Tim Bird
2009-03-25 17:05 ` Uwe Kleine-König
2009-03-25 17:17 ` Russell King - ARM Linux
2009-03-25 18:37 ` Tim Bird
2009-03-25 18:41 ` Steven Rostedt
2009-03-27 12:58 ` Catalin Marinas
2009-04-09 15:29 ` Daniel Jacobowitz
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=20090325112115.GB31464@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=fweisbec@gmail.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sagar.abhishek@gmail.com \
--cc=tim.bird@am.sony.com \
--cc=u.kleine-koenig@pengutronix.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;
as well as URLs for NNTP newsgroup(s).