Re: [PATCH] memblock: fix section mismatch warning

From: David Hildenbrand
Date: Thu Feb 25 2021 - 08:49:44 EST


On 25.02.21 14:38, Arnd Bergmann wrote:
From: Arnd Bergmann <arnd@xxxxxxxx>

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.

Did I understand correctly, that with this change it will not get inlined with any version of clang? Maybe __always_inline is more appropriate then.

(I don't see why to not inline that function, but I am obviously not a compiler person :) )

--
Thanks,

David / dhildenb