From: Kiryl Shutsemau <kas@kernel.org>
To: Michal Clapinski <mclapinski@google.com>
Cc: Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
David Hildenbrand <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/hugetlb: init tails before init_migratetype
Date: Mon, 22 Jun 2026 16:09:28 +0100 [thread overview]
Message-ID: <ajlO8cYdhDnbuvV3@thinkstation> (raw)
In-Reply-To: <20260622101901.223961-1-mclapinski@google.com>
On Mon, Jun 22, 2026 at 12:19:01PM +0200, Michal Clapinski wrote:
> Currently, if you enable HVO, DEFERRED_STRUCT_PAGE_INIT and VM_DEBUG
> the kernel will crash with the following stack trace
>
> get_pfnblock_bitmap_bitidx
> __set_pfnblock_flags_mask
> hugetlb_bootmem_init_migratetype
> prep_and_add_bootmem_folios
> gather_bootmem_prealloc_node
> gather_bootmem_prealloc_parallel
> padata_do_multithreaded
> gather_bootmem_prealloc
> hugetlb_init
>
> on this code
>
> VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page);
>
> This code looks inside the struct page which will be uninitialized
> for hugetlb tail pages, which will cause a false positive.
>
> So let's initialize the tail pages before this happens.
>
> Fixes: 622026e87c40 ("mm/hugetlb: remove fake head pages")
> Signed-off-by: Michal Clapinski <mclapinski@google.com>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Tested-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
One nit below.
> ---
> I think this one check is the only thing that fails, so I can probably
> just remove it instead.
Please don't. It caught a legitimate issue.
> ---
> mm/hugetlb.c | 1 +
> mm/hugetlb_vmemmap.c | 14 +++++++++-----
> mm/hugetlb_vmemmap.h | 5 +++++
> 3 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 571212b80835..de5e7c104c10 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4127,6 +4127,7 @@ static int __init hugetlb_init(void)
> }
>
> hugetlb_init_hstates();
> + hugetlb_vmemmap_init_tails();
> gather_bootmem_prealloc();
> report_hugepages();
>
> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
> index 133b46dfb09f..cf485c101926 100644
> --- a/mm/hugetlb_vmemmap.c
> +++ b/mm/hugetlb_vmemmap.c
> @@ -867,14 +867,10 @@ static const struct ctl_table hugetlb_vmemmap_sysctls[] = {
> },
> };
>
> -static int __init hugetlb_vmemmap_init(void)
> +void __init hugetlb_vmemmap_init_tails(void)
While you're touching this, please also fix up the now-stale comment in
vmemmap_get_tail() in mm/sparse-vmemmap.c, which still points at the
old function.
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2026-06-22 15:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 10:19 [PATCH] mm/hugetlb: init tails before init_migratetype Michal Clapinski
2026-06-22 15:09 ` Kiryl Shutsemau [this message]
2026-06-22 15:22 ` Muchun Song
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=ajlO8cYdhDnbuvV3@thinkstation \
--to=kas@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mclapinski@google.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--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