linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alastair D'Silva" <alastair@au1.ibm.com>
To: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Michal Hocko <mhocko@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] arch/powerpc: Rework local_paca to avoid LTO warnings
Date: Thu, 14 Mar 2019 12:39:23 +1100	[thread overview]
Message-ID: <087c8f5e7bf9f8e77d66ef86ed5ba06905211d60.camel@au1.ibm.com> (raw)
In-Reply-To: <bd858b12-7fab-057d-0065-2ccb98cbf648@c-s.fr>

On Wed, 2019-03-13 at 10:06 +0100, Christophe Leroy wrote:
> Hello,

Thanks for reviewing :)
> 
> Le 13/03/2019 à 04:42, Alastair D'Silva a écrit :
> > From: Alastair D'Silva <alastair@d-silva.org>
> > 
> > When building an LTO kernel, the existing code generates warnings:
> >      ./arch/powerpc/include/asm/paca.h:37:30: warning: register of
> >          ‘local_paca’ used for multiple global register variables
> >       register struct paca_struct *local_paca asm("r13");
> >                                ^
> >      ./arch/powerpc/include/asm/paca.h:37:30: note: conflicts with
> >          ‘local_paca’
> 
> How do you build a LTO kernel ?

I'm using Andi Kleen's LTO tree:
https://github.com/andikleen/linux-misc/tree/lto-420-1

with a few other patches:
https://github.com/andikleen/linux-misc/pull/27

You'll need to add the following to your .config:
CONFIG_LTO_MENU=y
CONFIG_LTO=y

> 
> > This patch reworks local_paca into an inline getter & setter
> > function,
> > which addresses the warning.
> 
> This patch adds sparse warnings, see 
> https://patchwork.ozlabs.org/patch/1055875/

These warnings are bogus, they replace warnings that flagged against
spinlock.h.

> > Generated ASM from this patch is broadly similar (addresses have
> > changed and the compiler uses different GPRs in some places).
> 
> Your text might be confusion. When I read it the first time I
> thought 
> you were saying that the compiler was now using another GPR than r13.
> 

I'll see if I can improve it.

> > Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> 
> I guess the same has to be done for current, see 
> arch/powerpc/include/asm/current.h :
> 
> /*
>   * We keep `current' in r2 for speed.
>   */
> register struct task_struct *current asm ("r2");

Hmm, I didn't see problems on PPC64 as that already uses an inline
function. I'll address this in another patch for the PPC32 case.

> > ---
> >   arch/powerpc/include/asm/paca.h | 44 +++++++++++++++++++++++-----
> > -----
> >   arch/powerpc/kernel/paca.c      |  2 +-
> >   2 files changed, 32 insertions(+), 14 deletions(-)
> > 
> > diff --git a/arch/powerpc/include/asm/paca.h
> > b/arch/powerpc/include/asm/paca.h
> > index e843bc5d1a0f..9c9e2dea0f9b 100644
> > --- a/arch/powerpc/include/asm/paca.h
> > +++ b/arch/powerpc/include/asm/paca.h
> > @@ -34,19 +34,6 @@
> >   #include <asm/cpuidle.h>
> >   #include <asm/atomic.h>
> >   
> > -register struct paca_struct *local_paca asm("r13");
> > -
> > -#if defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_SMP)
> > -extern unsigned int debug_smp_processor_id(void); /* from
> > linux/smp.h */
> > -/*
> > - * Add standard checks that preemption cannot occur when using
> > get_paca():
> > - * otherwise the paca_struct it points to may be the wrong one
> > just after.
> > - */
> > -#define get_paca()	((void) debug_smp_processor_id(), local_paca)
> > -#else
> > -#define get_paca()	local_paca
> > -#endif
> > -
> >   #ifdef CONFIG_PPC_PSERIES
> >   #define get_lppaca()	(get_paca()->lppaca_ptr)
> >   #endif
> > @@ -266,6 +253,37 @@ struct paca_struct {
> >   #endif
> >   } ____cacheline_aligned;
> >   
> > +#if defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_SMP)
> > +extern unsigned int debug_smp_processor_id(void); /* from
> > linux/smp.h */
> > +#endif
> 
> Why moving this down, why not leaving at the same place as before ?
> 
> If you really need to move it, you should remove the 'extern' at the 
> same time to make checkpatch happy.

I moved it to keep it close to the usage of it.

I suppose the new implementation should be in the same place though.

> > +
> > +static inline struct paca_struct *get_paca_no_preempt_check(void)
> > +{
> > +	register struct paca_struct *paca asm("r13");
> 
> Should be a blank line there.
Whoops, I thought I ran checkpatch, but clearly, I forgot. I'll
resubmit.

> > +	return paca;
> > +}
> > +
> > +static inline struct paca_struct *get_paca(void)
> > +{
> > +#if defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_SMP)
> > +	/*
> > +	 * Add standard checks that preemption cannot occur when using
> > get_paca():
> > +	 * otherwise the paca_struct it points to may be the wrong one
> > just after.
> > +	 */
> > +	debug_smp_processor_id();
> > +#endif
> > +	return get_paca_no_preempt_check();
> > +}
> > +
> > +#define local_paca	get_paca_no_preempt_check()
> > +
> > +static inline void set_paca(struct paca_struct *new)
> > +{
> > +	register struct paca_struct *paca asm("r13");
> 
> Blank line should be added here.
> 
> > +	paca = new;
> > +}
> > +
> > +
> >   extern void copy_mm_to_paca(struct mm_struct *mm);
> >   extern struct paca_struct **paca_ptrs;
> >   extern void initialise_paca(struct paca_struct *new_paca, int
> > cpu);
> > diff --git a/arch/powerpc/kernel/paca.c
> > b/arch/powerpc/kernel/paca.c
> > index 913bfca09c4f..ae5c243f9d5a 100644
> > --- a/arch/powerpc/kernel/paca.c
> > +++ b/arch/powerpc/kernel/paca.c
> > @@ -172,7 +172,7 @@ void __init initialise_paca(struct paca_struct
> > *new_paca, int cpu)
> >   void setup_paca(struct paca_struct *new_paca)
> >   {
> >   	/* Setup r13 */
> > -	local_paca = new_paca;
> > +	set_paca(new_paca);
> >   
> >   #ifdef CONFIG_PPC_BOOK3E
> >   	/* On Book3E, initialize the TLB miss exception frames */
> > 
> 
> Christophe
> 
-- 
Alastair D'Silva
Open Source Developer
Linux Technology Centre, IBM Australia
mob: 0423 762 819


  reply	other threads:[~2019-03-14  1:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  3:42 [PATCH 1/1] arch/powerpc: Rework local_paca to avoid LTO warnings Alastair D'Silva
2019-03-13  9:06 ` Christophe Leroy
2019-03-14  1:39   ` Alastair D'Silva [this message]
2019-03-13 23:54 ` Daniel Axtens
2019-03-14  0:09   ` Andrew Donnellan
2019-03-14  3:09   ` Alastair D'Silva
2019-03-14  2:31 ` [PATCH v2] " Alastair D'Silva
2019-03-14  5:46   ` Christophe Leroy
2019-03-26  5:58   ` Nicholas Piggin
2019-03-27  4:37     ` Alastair D'Silva
2019-03-27  6:02       ` Nicholas Piggin

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=087c8f5e7bf9f8e77d66ef86ed5ba06905211d60.camel@au1.ibm.com \
    --to=alastair@au1.ibm.com \
    --cc=akpm@linux-foundation.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=mahesh@linux.vnet.ibm.com \
    --cc=mhocko@suse.com \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.org \
    --cc=rppt@linux.vnet.ibm.com \
    /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).