All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Adam Borowski <kilobyte@angband.pl>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH] memblock: fix a section mismatch when a function doesn't get inlined
Date: Mon, 13 Sep 2021 09:39:56 +0300	[thread overview]
Message-ID: <YT7yPOxTPuzY6E9z@kernel.org> (raw)
In-Reply-To: <20210912204111.10314-1-kilobyte@angband.pl>

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@angband.pl>
> ---
>  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.


           reply	other threads:[~2021-09-13  6:40 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20210912204111.10314-1-kilobyte@angband.pl>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YT7yPOxTPuzY6E9z@kernel.org \
    --to=rppt@kernel.org \
    --cc=kilobyte@angband.pl \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.