From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF74E32B106 for ; Mon, 22 Jun 2026 15:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782140976; cv=none; b=kCk5mHd6FaBrzjqrK3NfmAHvxfx5ogR+BE4sHjNC/ENbDn67IazoIVWnVXZ70l9xucHsCwdMnx6DqfPGmYAyOhA1fHzQBWWp5lF15EtkK6l7lU9BMdczc4P8L1NflJ5etSfSeIbYqv2mp6RSxDvJpEVtiHfMu9IjlF044HHjDFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782140976; c=relaxed/simple; bh=nL7AQk8NX9nMi/Mpmn/bWZDCfTfMubBSD4GY1LEGenk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LrvX8ony7JArgjLiYZ+iE5Q69I+5YZyOQwgJkVSr9+Xelb4CLUSvKuUm4Ji0otCVoXODoWnr/Xy6WP3+Dc7kdoqPLfGWqX92FO8nWpqtdF8M72upyysxrUhPFNaAoqYEFwmIIQFSftEjZiK/bbsCZGejhzT7E4BBe7+ADEeMc6Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g22VtQ2X; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g22VtQ2X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BF2D1F000E9; Mon, 22 Jun 2026 15:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782140975; bh=bxSHW1Vtws/j8N34QO2bMrYSzo6we68C9vCirxjCB0A=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=g22VtQ2XyCdUyvrd2wQm4C5MeOpGm7h4/zyi/7eTShhTNg0vkdEqPqEcNu3hpx+A0 66BEIzT4vNfrcV7a0cXBPlbZ5oyJNyiQ+XaEShHKgfK9gd6rtidB7fH1cIiC+ublOH fQuEDYICWAxdfwog0yOcpzCOC9xRKopgVCSthAdyV8BTVTpIKIoL1XikpsirO0UMva FAmsdetGjLGVv+LKbL3C8TVsZv+LsmGoreOk0UFLhpjbY/g5w2eAIaX/M/70UH85Q1 HC9lHf386SEob7YTCB2sKCjC7/8j8qUVZpZprbYt7cQWIwMFqZkLaQaOy9uqVxbmj4 zYgBZr0JBD+5A== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 79C82F40079; Mon, 22 Jun 2026 11:09:34 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 22 Jun 2026 11:09:34 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTExngy+hclOlIBXvUpHQziHjFrUpzPu0HcLMBn6PVU60vRl9Bx3SXhYedeiikVCTB mwI4XWMI1CuyCvFFIq3sPOvHUPB+grLHj8l+cuAfUVL+YEykiR8td4Hsk0COK8IyDJI5Fy V1KIpuTF//psCfMQp6cr2zL9uMAXMcm4xYxSKxsqbRrEfoPxfBXOW/PeAgbr68EwifkAfE GNSnwvx1ppu2Ol+mhAtBg98tvw5/Xk37Z8xyq2FbWQzFifyv6HZ3Zeb+PQOF7OJB9sf08f aTUUOyhJV5rYjurKuzst7J7ITItKAforxSusKXMI3daQCuew+0QXIqOtvRDv8FFjInviYr gXFesPLJDhBNBXjjq2p5LeTUUbF87uwFNZ0aQM8T+nUWr6cmRkADc1tY3fBBf0dresx7cg BdsP7PZKH0CTiE0M+ZrFSXTNL8V8XHXSXt5QD+9hHOByNGGFihrBPiVbdy9G9VrlCO8FTh JHtGFWY9NES9UCyuLvUGCv+klhdV+F7hjJFgCY02z9WdByKNIiRTIAr9hAfg4XQ9Y9M+sO 37ILD+kYW7hwv11dAfE0WdneHURitxRGjR3iHt8wN3+Ef20I6g5vV+WLMRhYEuqzTVhIu8 RJIYzxbmpX1A/hFyYQ5La7nQFGng9YzehksYnwNBIYz3gUenKfzRhom5XWEw X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 22 Jun 2026 11:09:33 -0400 (EDT) Date: Mon, 22 Jun 2026 16:09:28 +0100 From: Kiryl Shutsemau To: Michal Clapinski Cc: Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , "Vlastimil Babka (SUSE)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/hugetlb: init tails before init_migratetype Message-ID: References: <20260622101901.223961-1-mclapinski@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Reviewed-by: Kiryl Shutsemau (Meta) Tested-by: Kiryl Shutsemau (Meta) 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