linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memblock: fix section mismatch warning
@ 2021-02-25 13:38 Arnd Bergmann
  2021-02-25 13:47 ` David Hildenbrand
  2021-02-25 20:59 ` Mike Rapoport
  0 siblings, 2 replies; 7+ messages in thread
From: Arnd Bergmann @ 2021-02-25 13:38 UTC (permalink / raw)
  To: Mike Rapoport, Nathan Chancellor, Nick Desaulniers, Faiyaz Mohammed
  Cc: Arnd Bergmann, Andrew Morton, Baoquan He, Thomas Bogendoerfer,
	David Hildenbrand, Aslan Bakirov, linux-mm, linux-kernel,
	clang-built-linux

From: Arnd Bergmann <arnd@arndb.de>

The inlining logic in clang-13 is rewritten to often not inline
some functions that were inlined by all earlier compilers.

In case of the memblock interfaces, this exposed a harmless bug
of a missing __init annotation:

WARNING: modpost: vmlinux.o(.text+0x507c0a): Section mismatch in reference from the function memblock_bottom_up() to the variable .meminit.data:memblock
The function memblock_bottom_up() references
the variable __meminitdata memblock.
This is often because memblock_bottom_up lacks a __meminitdata
annotation or the annotation of memblock is wrong.

Interestingly, these annotations were present originally, but got removed
with the explanation that the __init annotation prevents the function
from getting inlined. I checked this again and found that while this
is the case with clang, gcc (version 7 through 10, did not test others)
does inline the functions regardless.

As the previous change was apparently intended to help the clang
builds, reverting it to help the newer clang versions seems appropriate
as well. gcc builds don't seem to care either way.

Fixes: 5bdba520c1b3 ("mm: memblock: drop __init from memblock functions to make it inline")
Reference: 2cfb3665e864 ("include/linux/memblock.h: add __init to memblock_set_bottom_up()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/memblock.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index c88bc24e31aa..d13e3cd938b4 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -460,7 +460,7 @@ static inline void memblock_free_late(phys_addr_t base, phys_addr_t size)
 /*
  * Set the allocation direction to bottom-up or top-down.
  */
-static inline void memblock_set_bottom_up(bool enable)
+static inline __init void memblock_set_bottom_up(bool enable)
 {
 	memblock.bottom_up = enable;
 }
@@ -470,7 +470,7 @@ static inline void memblock_set_bottom_up(bool enable)
  * if this is true, that said, memblock will allocate memory
  * in bottom-up direction.
  */
-static inline bool memblock_bottom_up(void)
+static inline __init bool memblock_bottom_up(void)
 {
 	return memblock.bottom_up;
 }
-- 
2.29.2



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

end of thread, other threads:[~2021-02-25 20:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 13:38 [PATCH] memblock: fix section mismatch warning Arnd Bergmann
2021-02-25 13:47 ` David Hildenbrand
2021-02-25 14:06   ` Arnd Bergmann
2021-02-25 14:58     ` David Hildenbrand
2021-02-25 15:07     ` Mike Rapoport
2021-02-25 16:12       ` Arnd Bergmann
2021-02-25 20:59 ` Mike Rapoport

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).