All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Ingo Molnar" <mingo@elte.hu>, "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>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Abhishek Sagar" <sagar.abhishek@gmail.com>,
	"Russell King" <rmk@arm.linux.org.uk>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: Anyone working on ftrace function graph support on ARM?
Date: Wed, 25 Mar 2009 18:13:59 +0100	[thread overview]
Message-ID: <20090325171357.GB5932@nowhere> (raw)
In-Reply-To: <alpine.DEB.2.00.0903251153500.5675@gandalf.stny.rr.com>

On Wed, Mar 25, 2009 at 12:00:24PM -0400, Steven Rostedt wrote:
> 
> On Tue, 24 Mar 2009, Frederic Weisbecker wrote:
> 
> > On Tue, Mar 24, 2009 at 10:48:46PM +0100, Ingo Molnar wrote:
> > > 
> > > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > > 
> > > > Well it's a very naive listing, there are sometimes some problems. 
> > > > For example on x86-64, I had to save even some non-scratch 
> > > > registers before calling the return hook, I still don't know why.
> > > 
> > > btw., which are those registers?
> > > 
> > > 	Ingo
> > 
> > 
> > I would expect to only save rax,rdi,rsi,rdx,rcx,r8,r9 which
> > are used for parameters.
> > And I had some crashes until I append r10 and r11 which actually are
> > scratch if I'm not wrong, but since they are scratch and are not used for
> > arguments, I thought they didn't need to be saved.
> > 
> > Well, I think there were some code flow cases I was missing.
> > 
> > 
> > The complete code is:
> > 
> > 	movq %rax, (%rsp)
> > 	movq %rcx, 8(%rsp)
> > 	movq %rdx, 16(%rsp)
> > 	movq %rsi, 24(%rsp)
> > 	movq %rdi, 32(%rsp)
> > 	movq %r8, 40(%rsp)
> > 	movq %r9, 48(%rsp)
> > 	movq %r10, 56(%rsp)
> > 	movq %r11, 64(%rsp)
> > 
> > 	call ftrace_return_to_handler
> > 
> > 	movq %rax, 72(%rsp) <-- get original return value
> > 	movq 64(%rsp), %r11
> > 	movq 56(%rsp), %r10
> > 	movq 48(%rsp), %r9
> > 	movq 40(%rsp), %r8
> > 	movq 32(%rsp), %rdi
> > 	movq 24(%rsp), %rsi
> > 	movq 16(%rsp), %rdx
> > 	movq 8(%rsp), %rcx
> > 	movq (%rsp), %rax
> > 	addq $72, %rsp
> 
> This bothers me. In PowerPC 64, all I have is:
> 
> _GLOBAL(return_to_handler)
> 	/* need to save return values */
> 	std	r4,  -24(r1)
> 	std	r3,  -16(r1)
> 	std	r31, -8(r1)
> 	mr	r31, r1
> 	stdu	r1, -112(r1)
> 
> 	bl	.ftrace_return_to_handler
> 	nop
> 
> 	/* return value has real return address */
> 	mtlr	r3
> 
> 	ld	r1, 0(r1)
> 	ld	r4,  -24(r1)
> 	ld	r3,  -16(r1)
> 	ld	r31, -8(r1)
> 
> 	/* Jump back to real return address */
> 	blr
> 
> All I save is the return values (and I'm paranoid with that, by saving 
> both r3 and r4 and not just r3) as well as saving the stack. There should 
> be no reason to save any other registers.
> 
> This is not the same as mcount. mcount varies differently from arch to 
> arch. But this is the return of a function. This is not a mcount call, and 
> really has nothing to do with mcount.
> 
> If you think about it, the return is coming back from a function that 
> should have already saved all the registers that it modifies. The caller 
> of that function (the one we will return to) should have saved any 
> registers that are allowed to be modified by the callee.
> 
> When we call our ftrace_return_to_handler function it too will save any 
> register that it must for callees and restore it on return.
> 
> Perhaps the issue you had with x86_64 was that you did not set up the 
> stack frame properly? And by saving all those registers, it just happen to 
> do it for you?


I don't know. It seems to me that the stack frame is well set.
This is weird.

 
> -- Steve
> 


  reply	other threads:[~2009-03-25 17:14 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 [this message]
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
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=20090325171357.GB5932@nowhere \
    --to=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=rmk@arm.linux.org.uk \
    --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 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.