linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: Gabriel Paubert <paubert@iram.es>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Scott Wood <oss@buserror.net>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: inline current_stack_pointer()
Date: Wed, 25 May 2016 08:21:56 +1000	[thread overview]
Message-ID: <20160524222156.GA7963@fergus.ozlabs.ibm.com> (raw)
In-Reply-To: <20160523171738.GA15830@visitor2.iram.es>

On Mon, May 23, 2016 at 07:17:38PM +0200, Gabriel Paubert wrote:
> On Mon, May 23, 2016 at 10:46:02AM +0200, Christophe Leroy wrote:
> > current_stack_pointeur() is a single instruction function. it
> > It is not worth breaking the execution flow with a bl/blr for a
> > single instruction
> 
> Are you sure that the result is always the same? 
> 
> Calling an external function prevents the compiler from considering the
> caller of of current_stack_pointer a leaf function, which certainly 
> does not help the compiler, but in a leaf function the compiler is free 
> not to establish a new frame.
> 
> If the compiler decides to establishes a new frame (typically with 
> "stwu r1,-frame_size(r1)"), *r1 is the previous stack pointer, or
> the caller's stack pointer, or the current function frame pointer if
> I remember correctly the ABI definitions. 
> 
> However, if the compiler decides that it can get away without a frame
> for the function, *r1 is the stack pointer of the caller's caller.
> 
> Depending on the application, this may or may not be important.

Right.  I think I wrote the original current_stack_pointer()
implementation, and that I deliberately didn't make it an inline
so that the caller would have to establish its own stack frame,
and thus its stack pointer value would be a well-defined thing.

Paul.

  reply	other threads:[~2016-05-25  3:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23  8:46 [PATCH] powerpc: inline current_stack_pointer() Christophe Leroy
2016-05-23 17:17 ` Gabriel Paubert
2016-05-24 22:21   ` Paul Mackerras [this message]
2016-05-23 20:22 ` Segher Boessenkool
2016-05-24  5:39   ` Christophe Leroy
2016-05-24  6:08     ` Segher Boessenkool
2016-05-31 10:05 ` Anton Blanchard

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=20160524222156.GA7963@fergus.ozlabs.ibm.com \
    --to=paulus@ozlabs.org \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=oss@buserror.net \
    --cc=paubert@iram.es \
    /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).