From: Mike Rapoport <rppt@kernel.org>
To: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: linux-mm@kvack.org, Bibo Mao <maobibo@loongson.cn>,
linux-mips@vger.kernel.org, Paul Burton <paulburton@kernel.org>,
Li Xuefeng <lixuefeng@loongson.cn>,
Yang Tiezhu <yangtiezhu@loongson.cn>,
Gao Juxin <gaojuxin@loongson.cn>,
Huacai Chen <chenhuacai@loongson.cn>,
Huang Pei <huangpei@loongson.cn>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-kernel@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev>
Subject: Re: memblock_reserve for unadded region (was: [PATCH] MIPS: loongson64: fix boot failure)
Date: Tue, 16 Jan 2024 10:39:04 +0200 [thread overview]
Message-ID: <ZaZAqMwuql9Y5Gra@kernel.org> (raw)
In-Reply-To: <731134fd-4b3d-418c-84ee-80646bffcc01@flygoat.com>
On Mon, Jan 15, 2024 at 02:08:21PM +0000, Jiaxun Yang wrote:
> Hi mm folks,
>
> Just a quick question, what is the expected behavior of memblock_reserve
> a region that is not added to memblock with memblock_add?
>
> I'm unable to find any documentation about memblock_reserve in comments and
> boot-time-mm, but as per my understanding to the code, this should be a
> legit usage?
Yes, memblock allows reserving memory that was not added to memblock with
memblock_add().
> In practical we run into uninitialized nid of reserved block problem, should
> we fix it
> in our usage, or on memblock side?
Apparently it's a bug in memblock :(
If you revert 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()")
does the issue disappear?
> Thanks
>
> 在 2023/12/25 09:30, Huang Pei 写道:
> > Since commit 61167ad5fecd("mm: pass nid to reserve_bootmem_region()),
> > loongson64 booting failed with CONFIG_DEFERRED_STRUCT_PAGE_INIT like
> > this:
> > ----------------------------------------------------------------------
> > Call Trace:
> > [<ffffffff8235d088>] reserve_bootmem_region+0xa8/0x184
> > [<ffffffff82333940>] memblock_free_all+0x104/0x2a8
> > [<ffffffff8231d8e4>] mem_init+0x84/0x94
> > [<ffffffff82330958>] mm_core_init+0xf8/0x308
> > [<ffffffff82318c38>] start_kernel+0x43c/0x86c
> >
> > Code: 10400028 2402fff0 de420000 <dc432880> 0203182b 14600022
> > 64420070 00003025 24040003
> >
> > ---[ end trace 0000000000000000 ]---
> > Kernel panic - not syncing: Attempted to kill the idle task!
> > ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
> > ----------------------------------------------------------------------
> >
> > The root cause is no memory region "0x0-0x1fffff" paired with
> > memory-reserved region "0x0-0x1fffff" and "0x0-0xfff", with "memblock
> > =debug":
> >
> > ----------------------------------------------------------------------
> > memory[0x0] [0x0000000000200000-0x000000000effffff],
> > 0x000000000ee00000 bytes on node 0 flags: 0x0 !!!!here
> > memory[0x1] [0x0000000090000000-0x00000000fdffffff],
> > 0x000000006e000000 bytes on node 0 flags: 0x0
> > memory[0x2] [0x0000000100000000-0x000000027fffffff],
> > 0x0000000180000000 bytes on node 0 flags: 0x0
> > memory[0x3] [0x0000100000000000-0x000010000fffffff],
> > 0x0000000010000000 bytes on node 1 flags: 0x0
> > memory[0x4] [0x0000100090000000-0x000010027fffffff],
> > 0x00000001f0000000 bytes on node 1 flags: 0x0
> > reserved.cnt = 0x1f
> > reserved[0x0] [0x0000000000000000-0x000000000190c80a],
> > 0x000000000190c80b bytes flags: 0x0 !!!!oops 0x0-0x1fffff not in memory[0]
> > reserved[0x1] [0x000000000190c810-0x000000000190eea3],
> > 0x0000000000002694 bytes flags: 0x0
> > ----------------------------------------------------------------------
> >
> > It caused memory-reserved region "0x0-0x1fffff" without valid node id
> > in "memblock_get_region_node" from "memmap_init_reserved_pages", lead to
> > "reserve_bootmem_region-> init_reserved_page -> early_pfn_to_nid()"
> > accessing "node_data" out of bound.
> >
> > To fix this bug, we should remove unnecessary memory block reservation.
> >
> > +. no need to reserve 0x0-0x1fffff below kernel loading address, since
> > it is not registered by "memblock_add_node"
> >
> > +. no need to reserve 0x0-0xfff for exception handling if it is not
> > registered by "memblock_add" either.
> >
> > Fixes: commit 61167ad5fecd("mm: pass nid to reserve_bootmem_region())
> > Signed-off-by: Huang Pei <huangpei@loongson.cn>
> > ---
> > arch/mips/kernel/traps.c | 3 ++-
> > arch/mips/loongson64/numa.c | 2 --
> > 2 files changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> > index 246c6a6b0261..9b632b4c10c3 100644
> > --- a/arch/mips/kernel/traps.c
> > +++ b/arch/mips/kernel/traps.c
> > @@ -2007,7 +2007,8 @@ unsigned long vi_handlers[64];
> > void reserve_exception_space(phys_addr_t addr, unsigned long size)
> > {
> > - memblock_reserve(addr, size);
> > + if(memblock_is_region_memory(addr, size))
> > + memblock_reserve(addr, size);
> > }
> > void __init *set_except_vector(int n, void *addr)
> > diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
> > index 8f61e93c0c5b..0f516dde81da 100644
> > --- a/arch/mips/loongson64/numa.c
> > +++ b/arch/mips/loongson64/numa.c
> > @@ -130,8 +130,6 @@ static void __init node_mem_init(unsigned int node)
> > memblock_reserve((node_addrspace_offset | 0xfe000000),
> > 32 << 20);
> > - /* Reserve pfn range 0~node[0]->node_start_pfn */
> > - memblock_reserve(0, PAGE_SIZE * start_pfn);
> > }
> > }
>
> --
> ---
> Jiaxun Yang
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2024-01-16 8:39 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-25 9:30 [PATCH] MIPS: loongson64: fix boot failure Huang Pei
2024-01-09 21:40 ` Thomas Bogendoerfer
2024-01-13 9:55 ` [PATCH V2]: " Huang Pei
2024-01-13 9:55 ` [PATCH 1/3] MIPS: adjust exception vector space revervation Huang Pei
2024-01-13 9:55 ` [PATCH 2/3] MIPS: loongson64: fix booting failure Huang Pei
2024-01-13 9:55 ` [PATCH 3/3] Revert "MIPS: Loongson64: Handle more memory types passed from firmware" Huang Pei
2024-01-13 11:59 ` Jiaxun Yang
2024-01-14 8:53 ` Huang Pei
2024-01-14 11:58 ` Jiaxun Yang
2024-01-15 1:25 ` Huang Pei
2024-01-15 14:14 ` Jiaxun Yang
2024-01-16 3:10 ` Huang Pei
2024-01-18 12:39 ` [PATCH V3]: MIPS: loongson64: fix booting failure Huang Pei
2024-01-18 12:39 ` [PATCH 1/2] MIPS: reserve exception vector space ONLY ONCE Huang Pei
2024-01-18 12:39 ` [PATCH 2/2] MIPS: loongson64: set nid for reserved memblock region Huang Pei
2024-01-19 4:02 ` [PATCH V4]: MIPS: loongson64: fix boot failure Huang Pei
2024-01-19 4:02 ` [PATCH 1/2] MIPS: reserve exception vector space ONLY ONCE Huang Pei
2024-01-19 15:23 ` Sergei Shtylyov
2024-01-19 16:15 ` Thomas Bogendoerfer
2024-01-21 7:13 ` Huang Pei
2024-01-19 4:02 ` [PATCH 2/2] MIPS: loongson64: set nid for reserved memblock region Huang Pei
2024-01-19 10:05 ` Jiaxun Yang
2024-01-21 2:14 ` Huang Pei
2024-01-21 10:35 ` Jiaxun Yang
2024-01-22 8:08 ` [PATCH V6]: MIPS: loongson64: fix boot failure Huang Pei
2024-01-22 8:08 ` [PATCH 1/2] MIPS: reserve exception vector space ONLY ONCE Huang Pei
2024-01-22 8:08 ` [PATCH 2/2] MIPS: loongson64: set nid for reserved memblock region Huang Pei
2024-01-22 8:20 ` Sergey Shtylyov
2024-01-23 1:47 ` [PATCH 1/2] MIPS: reserve exception vector space ONLY ONCE Huang Pei
2024-01-23 1:47 ` [PATCH 2/2] MIPS: loongson64: set nid for reserved memblock region Huang Pei
2024-01-26 10:12 ` Thomas Bogendoerfer
2024-01-26 14:24 ` Huacai Chen
2024-01-26 17:24 ` Thomas Bogendoerfer
2024-01-27 9:12 ` [PATCH] " Huang Pei
2024-01-27 9:12 ` Huang Pei
2024-01-27 10:04 ` Thomas Bogendoerfer
2024-01-28 4:42 ` Huang Pei
2024-01-26 10:12 ` [PATCH 1/2] MIPS: reserve exception vector space ONLY ONCE Thomas Bogendoerfer
2024-01-15 14:08 ` memblock_reserve for unadded region (was: [PATCH] MIPS: loongson64: fix boot failure) Jiaxun Yang
2024-01-16 3:27 ` Huang Pei
2024-01-16 8:39 ` Mike Rapoport [this message]
2024-01-16 12:23 ` Huang Pei
2024-01-17 2:20 ` Yajun Deng
2024-01-17 3:01 ` Huang Pei
2024-01-17 3:17 ` Yajun Deng
2024-01-17 3:59 ` Huang Pei
2024-01-17 6:46 ` Mike Rapoport
2024-01-17 7:45 ` Huang Pei
2024-01-17 11:08 ` Mike Rapoport
2024-01-18 2:26 ` Huang Pei
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=ZaZAqMwuql9Y5Gra@kernel.org \
--to=rppt@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=gaojuxin@loongson.cn \
--cc=huangpei@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lixuefeng@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=paulburton@kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=yajun.deng@linux.dev \
--cc=yangtiezhu@loongson.cn \
/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.