linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Sang-Heon Jeon <ekffu200098@gmail.com>,
	akpm@linux-foundation.org, ljs@kernel.org,
	Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, mhocko@suse.com
Cc: linux-mm@kvack.org
Subject: Re: [PATCH] mm/sparse: remove unnecessary NULL check before allocating mem_section
Date: Tue, 21 Apr 2026 16:49:06 +0200	[thread overview]
Message-ID: <fa41faf3-2d8d-4c45-9a1d-d67c71db1698@kernel.org> (raw)
In-Reply-To: <20260419144225.2875654-1-ekffu200098@gmail.com>

On 4/19/26 16:42, Sang-Heon Jeon wrote:
> Commit 850ed20539a4 ("mm: move array mem_section init code out
> of memory_present()") moved mem_section allocation logic
> into memblocks_present().
> 
> Before that move, memory_present() could be called multiple times, so
> unlikely() matched the common case, where most calls found mem_section
> already allocated.
> 
> After that move, memblocks_present() is called exactly once from
> sparse_init(). Under CONFIG_SPARSEMEM_EXTREME, mem_section is always
> NULL when it is called.
> 
> So remove unnecessary NULL check before allocating mem_section. No
> functional change.
> 
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> Hello, 
> 
> While looking into boot information, I found a minor enhancement point.
> If I misunderstood anything, please feel free to let me know.
> 
> Thank you for taking valuable time to review this work.
> 
> Best Regards,
> Sang-Heon Jeon
> ---
>  mm/sparse.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index effdac6b0ab1..e13f9f5fa090 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -201,13 +201,11 @@ static void __init memblocks_present(void)
>  	int i, nid;
>  
>  #ifdef CONFIG_SPARSEMEM_EXTREME
> -	if (unlikely(!mem_section)) {
> -		unsigned long size, align;
> +	unsigned long size, align;
>  
> -		size = sizeof(struct mem_section *) * NR_SECTION_ROOTS;
> -		align = 1 << (INTERNODE_CACHE_SHIFT);
> -		mem_section = memblock_alloc_or_panic(size, align);
> -	}
> +	size = sizeof(struct mem_section *) * NR_SECTION_ROOTS;
> +	align = 1 << (INTERNODE_CACHE_SHIFT);
> +	mem_section = memblock_alloc_or_panic(size, align);

Given that there is no other code that assigns mem_section

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


      parent reply	other threads:[~2026-04-21 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-19 14:42 Sang-Heon Jeon
2026-04-20  6:49 ` Mike Rapoport
2026-04-20 12:55   ` Sang-Heon Jeon
2026-04-20 11:36 ` Donet Tom
2026-04-21 14:49 ` David Hildenbrand (Arm) [this message]

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=fa41faf3-2d8d-4c45-9a1d-d67c71db1698@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=ekffu200098@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox