All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] arch/powerpc: Rework local_paca to avoid LTO warnings
@ 2019-03-13  3:42 ` Alastair D'Silva
  0 siblings, 0 replies; 22+ messages in thread
From: Alastair D'Silva @ 2019-03-13  3:42 UTC (permalink / raw)
  Cc: Alastair D'Silva, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Nicholas Piggin, Mahesh Salgaonkar,
	Naveen N. Rao, Christophe Leroy, Michal Hocko, Andrew Morton,
	Mike Rapoport, linuxppc-dev, linux-kernel

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’

This patch reworks local_paca into an inline getter & setter function,
which addresses the warning.

Generated ASM from this patch is broadly similar (addresses have
changed and the compiler uses different GPRs in some places).

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
 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
+
+static inline struct paca_struct *get_paca_no_preempt_check(void)
+{
+	register struct paca_struct *paca asm("r13");
+	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");
+	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 */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-03-27  6:03 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13  3:42 [PATCH 1/1] arch/powerpc: Rework local_paca to avoid LTO warnings Alastair D'Silva
2019-03-13  3:42 ` Alastair D'Silva
2019-03-13  9:06 ` Christophe Leroy
2019-03-13  9:06   ` Christophe Leroy
2019-03-14  1:39   ` Alastair D'Silva
2019-03-14  1:39     ` Alastair D'Silva
2019-03-13 23:54 ` Daniel Axtens
2019-03-13 23:54   ` Daniel Axtens
2019-03-14  0:09   ` Andrew Donnellan
2019-03-14  0:09     ` Andrew Donnellan
2019-03-14  3:09   ` Alastair D'Silva
2019-03-14  3:09     ` Alastair D'Silva
2019-03-14  2:31 ` [PATCH v2] " Alastair D'Silva
2019-03-14  2:31   ` Alastair D'Silva
2019-03-14  5:46   ` Christophe Leroy
2019-03-14  5:46     ` Christophe Leroy
2019-03-26  5:58   ` Nicholas Piggin
2019-03-26  5:58     ` Nicholas Piggin
2019-03-27  4:37     ` Alastair D'Silva
2019-03-27  4:37       ` Alastair D'Silva
2019-03-27  6:02       ` Nicholas Piggin
2019-03-27  6:02         ` Nicholas Piggin

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.