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 362F2400E0C for ; Thu, 9 Jul 2026 10:45:42 +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=1783593944; cv=none; b=KflM23QceLl4bznVkwb0lUapCRcuN0hZMfjqVbdZKLMuWUAVepi0feZUg2m93otLyHZG4WSAPP+15jCtF7lq+c+n+JBTZ5LXZ2Ed9qXdivbJQKIxMsHQs/CAHQ4CBCQLpUOGAsxcuMwouhvXnmSTg2TfV7tukLZa/xjBgRZo7Js= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783593944; c=relaxed/simple; bh=Wm6wUhbBmJxWhNS34pHTL0KMWE5fGPy1pDWtq+5N1F4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aVcP/isfIqibc6dtRyeLZA4/dE7I0LIHThyQZS5LFygY53YXD403pqWgl9yjKaggIZxRInClDPNh4bO4wiPBb9pCv0rbRfyTVK4VtLPMJtYy1Gpld7k8KBj6h/g9zCbNxJLImzuzGMCU8ynqVUcFOWHH5KNvbaBZWMlq9j4bELM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EGulu5Zy; 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="EGulu5Zy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5483A1F000E9; Thu, 9 Jul 2026 10:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783593942; bh=UOpYD6ZRcmuhibOLDuRYZLKQNBiTJQnRVmlbmamWuH0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=EGulu5ZyFyUvVdMAfBtWjFgP8rSSL0HpiletGPpKEn0Zuh8N4ftMXXFQ4mqZZiD5J IVJycgTh1khV6E9wsVdMvWeB95R18aEUav5FpKBGMmjbHkfGt3m6w9cKVbPk5blw44 UKYj8ghbMdkBaegXU4VhgUbin+dNH1COOq1cT+6C4JQuZfL1xER+hpAA7sc4pJqRIN kcb/Jlmaz9v+dQN+teZ6dvEKEkuIBU1V3nahtuELsHI15aHITRbAERcvVIPY4EoE3C SKkxZRXF5PJRba37woZvUK9GfmIvY2gnJe3DyjTQ9FtBKHY2sa96iT4GJ1dUhmH+0Q 6/A5Jt7Wz+org== Date: Thu, 9 Jul 2026 13:45:35 +0300 From: Mike Rapoport To: Muchun Song Cc: Andrew Morton , Oscar Salvador , David Hildenbrand , linux-mm@kvack.org, Vlastimil Babka , Lorenzo Stoakes , Michal Hocko , linux-kernel@vger.kernel.org, muchun.song@linux.dev Subject: Re: [PATCH 04/17] mm/mm_init: skip initializing shared vmemmap tail pages Message-ID: References: <20260702093821.2740183-1-songmuchun@bytedance.com> <20260702093821.2740183-5-songmuchun@bytedance.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: <20260702093821.2740183-5-songmuchun@bytedance.com> Hi Muchun, Below are some preliminary comments, I'm planning to spend more time on review next week. On Thu, Jul 02, 2026 at 05:38:08PM +0800, Muchun Song wrote: > memmap_init_range() initializes every struct page in the target range. > For compound pages with vmemmap optimization, the tail struct pages are > backed by a shared vmemmap page. > > Initializing those tail struct pages would overwrite the shared > vmemmap page contents, so users such as HugeTLB have to open-code > follow-up handling to restore the metadata afterwards. > > Use the section's compound page order to detect struct pages that fall > into the shared tail vmemmap range and skip their initialization in > memmap_init_range(). Still initialize the pageblock migratetypes for > the skipped range so the surrounding setup remains intact. > > This is a preparatory change for consolidating handling across users of > vmemmap optimization, and it also avoids redundant initialization of > shared tail vmemmap pages during early boot. > > Signed-off-by: Muchun Song > --- > include/linux/mmzone.h | 4 ++++ > mm/internal.h | 16 ++++++++++++++++ > mm/mm_init.c | 25 +++++++++++++++++++------ > 3 files changed, 39 insertions(+), 6 deletions(-) > > @@ -673,19 +673,21 @@ static inline void fixup_hashdist(void) > static inline void fixup_hashdist(void) {} > #endif /* CONFIG_NUMA */ > > -#if defined(CONFIG_ZONE_DEVICE) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) > static __meminit void pageblock_migratetype_init_range(unsigned long pfn, > - unsigned long nr_pages, int migratetype, bool atomic) > + unsigned long nr_pages, int migratetype, bool isolate, bool atomic) What is isolate parameter for? > { > const unsigned long end = pfn + nr_pages; > > for (pfn = pageblock_align(pfn); pfn < end; pfn += pageblock_nr_pages) { > - init_pageblock_migratetype(pfn_to_page(pfn), migratetype, false); > + init_pageblock_migratetype(pfn_to_page(pfn), migratetype, isolate); > +#ifdef CONFIG_SPARSEMEM > if (!atomic && IS_ALIGNED(pfn, PAGES_PER_SECTION)) > +#else > + if (!atomic && IS_ALIGNED(pfn, MAX_FOLIO_NR_PAGES)) > +#endif Let's trigger cond_resched() on some defined number of iterations or some memory size chunk, e.g PAGES_PER_128M or even PAGES_PER_1G. > cond_resched(); > } > } -- Sincerely yours, Mike.