From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Wei Yang <richard.weiyang@gmail.com>,
rppt@kernel.org, akpm@linux-foundation.org, yajun.deng@linux.dev
Cc: linux-mm@kvack.org, stable@vger.kernel.org
Subject: Re: [Patch v2 2/3] mm/memblock: repeat setting reserved region nid if array is doubled
Date: Tue, 18 Mar 2025 16:25:23 +0530 [thread overview]
Message-ID: <0bce0252-dd32-4cef-99f7-2222add43e2c@arm.com> (raw)
In-Reply-To: <20250318071948.23854-3-richard.weiyang@gmail.com>
On 3/18/25 12:49, Wei Yang wrote:
> Commit 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()") introduce
> a way to set nid to all reserved region.
>
> But there is a corner case it will leave some region with invalid nid.
> When memblock_set_node() doubles the array of memblock.reserved, it may
> lead to a new reserved region before current position. The new region
> will be left with an invalid node id.
But is it really possible for the memblock array to double during
memmap_init_reserved_pages() ? Just wondering - could you please
give some example scenarios.
>
> Repeat the process when detecting it.
>
> Fixes: 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()")
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Mike Rapoport <rppt@kernel.org>
> CC: Yajun Deng <yajun.deng@linux.dev>
> CC: <stable@vger.kernel.org>
>
> ---
> v2: move check out side of the loop
> ---
> mm/memblock.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 85442f1b7f14..0bae7547d2db 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2179,11 +2179,14 @@ static void __init memmap_init_reserved_pages(void)
> struct memblock_region *region;
> phys_addr_t start, end;
> int nid;
> + unsigned long max_reserved;
>
> /*
> * set nid on all reserved pages and also treat struct
> * pages for the NOMAP regions as PageReserved
> */
> +repeat:
> + max_reserved = memblock.reserved.max;
> for_each_mem_region(region) {
> nid = memblock_get_region_node(region);
> start = region->base;
> @@ -2194,6 +2197,13 @@ static void __init memmap_init_reserved_pages(void)
>
> memblock_set_node(start, region->size, &memblock.reserved, nid);
> }
> + /*
> + * 'max' is changed means memblock.reserved has been doubled its
> + * array, which may result a new reserved region before current
> + * 'start'. Now we should repeat the procedure to set its node id.
> + */
> + if (max_reserved != memblock.reserved.max)
> + goto repeat;
>
> /*
> * initialize struct pages for reserved regions that don't have
next prev parent reply other threads:[~2025-03-18 10:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 7:19 [Patch v2 0/3] memblock: some fix for memmap_init_reserved_pages() Wei Yang
2025-03-18 7:19 ` [Patch v2 1/3] mm/memblock: pass size instead of end to memblock_set_node() Wei Yang
2025-03-18 10:29 ` Anshuman Khandual
2025-03-18 7:19 ` [Patch v2 2/3] mm/memblock: repeat setting reserved region nid if array is doubled Wei Yang
2025-03-18 10:55 ` Anshuman Khandual [this message]
2025-03-19 8:12 ` Wei Yang
2025-03-18 7:19 ` [Patch v2 3/3] memblock tests: add test for memblock_set_node Wei Yang
2025-04-07 2:58 ` [Patch v2 0/3] memblock: some fix for memmap_init_reserved_pages() Wei Yang
2025-04-07 6:34 ` Mike Rapoport
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=0bce0252-dd32-4cef-99f7-2222add43e2c@arm.com \
--to=anshuman.khandual@arm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=richard.weiyang@gmail.com \
--cc=rppt@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yajun.deng@linux.dev \
/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