From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754192AbcEXGoc (ORCPT ); Tue, 24 May 2016 02:44:32 -0400 Received: from rudy.puc.rediris.es ([130.206.18.132]:52431 "EHLO rudy.puc.rediris.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbcEXGob (ORCPT ); Tue, 24 May 2016 02:44:31 -0400 X-Envelope-From: paubert@iram.es Date: Mon, 23 May 2016 19:17:38 +0200 From: Gabriel Paubert To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Scott Wood , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc: inline current_stack_pointer() Message-ID: <20160523171738.GA15830@visitor2.iram.es> References: <20160523084602.53F771A239A@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160523084602.53F771A239A@localhost.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spamina-Bogosity: Unsure X-Spamina-Spam-Score: 0.0 (/) X-Spamina-Spam-Report: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 1.0 DATE_IN_PAST_12_24 Date: is 12 to 24 hours before Received: date 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: ozlabs.org] -0.0 BAYES_40 BODY: Bayes spam probability is 20 to 40% [score: 0.3817] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. By the way, isn't there a GCC builtin which can perform this task, for example builtin_frame_address()? Gabriel > > Signed-off-by: Christophe Leroy > --- > arch/powerpc/include/asm/reg.h | 7 ++++++- > arch/powerpc/kernel/misc.S | 4 ---- > arch/powerpc/kernel/ppc_ksyms.c | 2 -- > 3 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h > index c1e82e9..7ce6777 100644 > --- a/arch/powerpc/include/asm/reg.h > +++ b/arch/powerpc/include/asm/reg.h > @@ -1301,7 +1301,12 @@ static inline unsigned long mfvtb (void) > > #define proc_trap() asm volatile("trap") > > -extern unsigned long current_stack_pointer(void); > +static inline unsigned long current_stack_pointer(void) > +{ > + register unsigned long *ptr asm("r1"); > + > + return *ptr; > +} > > extern unsigned long scom970_read(unsigned int address); > extern void scom970_write(unsigned int address, unsigned long value); > diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S > index 0d43219..7ce26d4 100644 > --- a/arch/powerpc/kernel/misc.S > +++ b/arch/powerpc/kernel/misc.S > @@ -114,7 +114,3 @@ _GLOBAL(longjmp) > mtlr r0 > mr r3,r4 > blr > - > -_GLOBAL(current_stack_pointer) > - PPC_LL r3,0(r1) > - blr > diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c > index 9f01e28..eb5c5dc 100644 > --- a/arch/powerpc/kernel/ppc_ksyms.c > +++ b/arch/powerpc/kernel/ppc_ksyms.c > @@ -33,5 +33,3 @@ EXPORT_SYMBOL(store_vr_state); > #ifdef CONFIG_EPAPR_PARAVIRT > EXPORT_SYMBOL(epapr_hypercall_start); > #endif > - > -EXPORT_SYMBOL(current_stack_pointer); > -- > 2.1.0 > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev