* [PATCH] mm/sparse: Check the return value of first_present_section_nr()
@ 2023-06-19 4:44 Liam Ni
2023-06-19 8:41 ` David Hildenbrand
0 siblings, 1 reply; 2+ messages in thread
From: Liam Ni @ 2023-06-19 4:44 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, rppt, Liam Ni
first_present_section_nr() may return -1,
which means there is no present section in system,or other errors,
so we cause panic here.
Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
---
mm/sparse.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/sparse.c b/mm/sparse.c
index b8d5d58fe240..175727e10deb 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -564,6 +564,8 @@ void __init sparse_init(void)
memblocks_present();
pnum_begin = first_present_section_nr();
+ if (pnum_begin == -1)
+ panic("There is no present section in system\n");
nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
/* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/sparse: Check the return value of first_present_section_nr()
2023-06-19 4:44 [PATCH] mm/sparse: Check the return value of first_present_section_nr() Liam Ni
@ 2023-06-19 8:41 ` David Hildenbrand
0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2023-06-19 8:41 UTC (permalink / raw)
To: Liam Ni, akpm; +Cc: linux-mm, linux-kernel, rppt
On 19.06.23 06:44, Liam Ni wrote:
> first_present_section_nr() may return -1,
> which means there is no present section in system,or other errors,
> so we cause panic here.
>
> Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
> ---
> mm/sparse.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index b8d5d58fe240..175727e10deb 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -564,6 +564,8 @@ void __init sparse_init(void)
> memblocks_present();
>
> pnum_begin = first_present_section_nr();
> + if (pnum_begin == -1)
> + panic("There is no present section in system\n");
> nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
>
> /* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */
That would mean that __section_mark_present() was never called, implying
memory_present() / memblocks_present() was never called.
... but sparse_init() calles memblocks_present() itself.
So what's left would be, that there is absolutely no memory in the
system such that memblocks_present() couldn't mark anything present ...
which sound pretty much impossible, unless the arch setup code is deeply
flawed such that everything else would be broken as well.
Don't think this will ever trigger, and, therefore, this is not really
required.
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-19 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 4:44 [PATCH] mm/sparse: Check the return value of first_present_section_nr() Liam Ni
2023-06-19 8:41 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox