linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Donet Tom <donettom@linux.ibm.com>
To: Muchun Song <songmuchun@bytedance.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Frank van der Linden <fvdl@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	muchun.song@linux.dev
Subject: Re: [PATCH] mm/sparse: fix preinited section_mem_map clobbering on failure path
Date: Wed, 1 Apr 2026 00:04:26 +0530	[thread overview]
Message-ID: <81857888-b6aa-4f04-bfd7-e9365d62669d@linux.ibm.com> (raw)
In-Reply-To: <20260331113724.2080833-1-songmuchun@bytedance.com>

Hi Muchun

On 3/31/26 5:07 PM, Muchun Song wrote:
> sparse_init_nid() is careful to leave alone every section whose vmemmap
> has already been set up by sparse_vmemmap_init_nid_early(); it only
> clears section_mem_map for the rest:
>
>          if (!preinited_vmemmap_section(ms))
>                  ms->section_mem_map = 0;
>
> A leftover line after that conditional block
>
>          ms->section_mem_map = 0;
>
> was supposed to be deleted but was missed in the failure path, causing the
> field to be overwritten for all sections when memory allocation fails,
> effectively destroying the pre-initialization check.
>
> Drop the stray assignment so that preinited sections retain their
> already valid state.
>
> Fixes: d65917c42373 ("mm/sparse: allow for alternate vmemmap section init at boot")
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>   mm/sparse.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index c2eb36bfb86d..3a14b733bf71 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -584,7 +584,6 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin,
>   		ms = __nr_to_section(pnum);
>   		if (!preinited_vmemmap_section(ms))
>   			ms->section_mem_map = 0;
> -		ms->section_mem_map = 0;


This looks correct to me.

I have a couple of questions:

1. As I understand, section_mem_map initially stores the nid
    during early boot, and later it stores a pointer to an
    array of struct page. In sparse_init_nid(), the struct page
    array is stored in section_mem_map via
    sparse_init_early_section(). If
    __populate_section_memmap() fails, we are  clearing the nid
    stored in section_mem_map right?

2. Another question: if sparse_init_nid() fails for some
    sections, there is no retry mechanism to add them again,
    correct?

3. when ms->section_mem_map is set to 0
    for a pre-initialized section, does it only affect the
    pre-initialization check, or could it lead to other issues?


- Donet

>   	}
>   }
>   


  reply	other threads:[~2026-03-31 18:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 11:37 Muchun Song
2026-03-31 18:34 ` Donet Tom [this message]
2026-04-01  2:28   ` Muchun Song
2026-04-02  6:42     ` Donet Tom
2026-03-31 20:10 ` Andrew Morton
2026-03-31 21:06   ` David Hildenbrand (Arm)
2026-04-01  2:37   ` Muchun Song
2026-03-31 20:42 ` David Hildenbrand (Arm)
2026-04-01  2:41   ` Muchun Song
2026-04-01  7:25     ` David Hildenbrand (Arm)
2026-04-01  7:28       ` Muchun Song
2026-04-02  7:37       ` Donet Tom
2026-04-02  7:56         ` David Hildenbrand (Arm)
2026-04-02 12:12           ` Donet Tom

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=81857888-b6aa-4f04-bfd7-e9365d62669d@linux.ibm.com \
    --to=donettom@linux.ibm.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=fvdl@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=rppt@kernel.org \
    --cc=songmuchun@bytedance.com \
    --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