Hi Adam, On Sun, Sep 12, 2021 at 10:41:11PM +0200, Adam Borowski wrote: > WARNING: modpost: vmlinux.o(.text.unlikely+0xab6): Section mismatch in > reference from the function memblock_phys_alloc() to the function > .init.text:memblock_phys_alloc_range() > The function memblock_phys_alloc() references > the function __init memblock_phys_alloc_range(). > This is often because memblock_phys_alloc lacks a __init > annotation or the annotation of memblock_phys_alloc_range is wrong. There is a bunch of other wrappers in include/linux/memblock.h that most probably would cause the same warning. Can add the patch below and build the kernel with the config that prevents inlining of memblock_phys_alloc to see what the compiler thinks about other wrappers? I believe they all would produce the same warning. diff --git a/mm/memblock.c b/mm/memblock.c index 28a813d9e955..6351c5754bb0 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2089,6 +2089,32 @@ void __init memblock_free_all(void) totalram_pages_add(pages); } +void __init memblock_test_inlining(void) +{ + void *addr; + + addr = memblock_alloc_raw(PAGE_SIZE, PAGE_SIZE); + if (!addr) + return; + memblock_free(__pa(addr), PAGE_SIZE); + + addr = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, + MEMBLOCK_ALLOC_ACCESSIBLE); + if (!addr) + return; + memblock_free(__pa(addr), PAGE_SIZE); + + addr = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); + if (!addr) + return; + memblock_free(__pa(addr), PAGE_SIZE); + + addr = memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, NUMA_NO_NODE); + if (!addr) + return; + memblock_free(__pa(addr), PAGE_SIZE); +} + #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) static int memblock_debug_show(struct seq_file *m, void *private) > Simplest way is to just ensure it is inlined. > > Signed-off-by: Adam Borowski <kilobyte@xxxxxxxxxx> > --- > Found when running riscv64 randconfigs, but doesn't appear to be arch > specific. > > 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 b066024c62e3..dfdd7c50c27d 100644 > --- a/include/linux/memblock.h > +++ b/include/linux/memblock.h > @@ -387,8 +387,8 @@ phys_addr_t memblock_alloc_range_nid(phys_addr_t size, > phys_addr_t end, int nid, bool exact_nid); > phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); > > -static inline phys_addr_t memblock_phys_alloc(phys_addr_t size, > - phys_addr_t align) > +static __always_inline phys_addr_t memblock_phys_alloc(phys_addr_t size, > + phys_addr_t align) > { > return memblock_phys_alloc_range(size, align, 0, > MEMBLOCK_ALLOC_ACCESSIBLE); > -- > 2.33.0 > -- Sincerely yours, Mike.