Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2822826imc; Wed, 13 Mar 2019 02:07:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzawSvkJWr3auWTRV2ddidEkIeVqfvevHiVsBtRZPSTJiz3BfFIYgGR4tH5BvxLck8S6uiu X-Received: by 2002:aa7:8583:: with SMTP id w3mr5491949pfn.131.1552468068722; Wed, 13 Mar 2019 02:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552468068; cv=none; d=google.com; s=arc-20160816; b=hWgNtJa/Lo4Y7Tkstpi86HayF0k2U615ZYWiOoTqOgBf3vZcaEE2Rt4S0Cad7Wz0ap GJ3AqRc5hHU+9c6uXG+FOBjfsUk9ypecvI3wvpk+IQyNsV1OIbsKo2AtEnznH+GsPYa5 ygrcdA5yt52fPfsUJ3TZtVZVyCZaSe9At/IANFEUDxd/blRypMpm7xn1jQWP9LAiorpP DiDE7u7SHL2duz0pyDkBzQlMo+4re6DbgVhJCBTsFykGjb5f3O+Aml/EBhQDbzRZ8DMR R7rRliI0St1SmApdfVtKKwcno8sKZ2pEjKsSFOHvDHGsXUXlJHyQo+nlEMomYtfB0c6c 4q9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=IoijEz6VoS+nWaaMU7l1D1g3qs+lq9pKu9xC1BONTnI=; b=ru8cyvFASiXofjdPfjC1BLJ/6m1H116WZJSwepM2/4KcDxiOZHMvSeL0zDpJIpoaNh 0R6G+jBR9T3IEhs/BjN0fKQCPR/2XZ3v+MLi1blNYA9xhuaIjDbSY8c6AajjCNtBEFkH HJLWBfhwkvWVeL5z4tb6ddOZe2iFHxCHNUFKwwzQKaCeycGeJUZ+fiZicpkmwRLeE/bd f53EkfvFbd9QZX3qhLmbia/U7OHQRCvLmQgyGNrRoE2Zt9ySAGVDuqRCSfj7CqpF20b1 ihdpL0pIC4CIkghAsNgSqfc/GAkt3jB9dfoFABr8AoaQYp3lvAzlmc22Ftt8QL3JW+36 5Q0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=VYwPvz2X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si9348322pgc.461.2019.03.13.02.07.32; Wed, 13 Mar 2019 02:07:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=VYwPvz2X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbfCMJG0 (ORCPT + 99 others); Wed, 13 Mar 2019 05:06:26 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:31682 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbfCMJGZ (ORCPT ); Wed, 13 Mar 2019 05:06:25 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44K5YV1MCZz9tyv3; Wed, 13 Mar 2019 10:06:22 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=VYwPvz2X; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id b_ev4INDNGpo; Wed, 13 Mar 2019 10:06:22 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 44K5YV04knz9tyv2; Wed, 13 Mar 2019 10:06:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1552467982; bh=IoijEz6VoS+nWaaMU7l1D1g3qs+lq9pKu9xC1BONTnI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=VYwPvz2XwhnNCS3aPMJ0N6RFw1Da5OQ3sOREb3csmha2HFej7bNieEFkQS49zdeaR Bgyo+AwRe/DzAM5ZTiSkpbwXo0qSyOIUeNWR4PBJw6/sQ4jcQPUCN8DFYed5S47zMA AAE8b4vZUFrN+jF4CcsifEhTodFOyBboVvpCxJhY= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EA9348B8F9; Wed, 13 Mar 2019 10:06:22 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id PUXw9sD4EhAz; Wed, 13 Mar 2019 10:06:22 +0100 (CET) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8C1128B8EE; Wed, 13 Mar 2019 10:06:21 +0100 (CET) Subject: Re: [PATCH 1/1] arch/powerpc: Rework local_paca to avoid LTO warnings To: Alastair D'Silva Cc: Alastair D'Silva , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , Mahesh Salgaonkar , "Naveen N. Rao" , Michal Hocko , Andrew Morton , Mike Rapoport , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20190313034208.13134-1-alastair@au1.ibm.com> From: Christophe Leroy Message-ID: Date: Wed, 13 Mar 2019 10:06:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <20190313034208.13134-1-alastair@au1.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Le 13/03/2019 à 04:42, Alastair D'Silva a écrit : > From: Alastair D'Silva > > 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 ? > > 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/ > > 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. > > Signed-off-by: Alastair D'Silva 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"); > --- > 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 > #include > > -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. > + > +static inline struct paca_struct *get_paca_no_preempt_check(void) > +{ > + register struct paca_struct *paca asm("r13"); Should be a blank line there. > + 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