From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 D14BC4219F2 for ; Thu, 9 Jul 2026 12:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783600363; cv=none; b=tvP8GK8s44yj8v2BdkukEoV59ptcSR8gJNkRfz/bO2j6xN7uNrejCgtBlWEw5o8jC9Kgt+gIKItEfrhm3ofLnFNWEcwoLsLA3y7cUZ115LDg66KJ3jTyA3DDT98Xg23ijkJdWZzGElvKlVUPr1oOxebkVc6y6kA+EM9juRrTSHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783600363; c=relaxed/simple; bh=DcZ3UnYpyabLnZzCAjcehXTLYWoP0tfzpPK/NlfTBME=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=qhsPubPGPD5Mu9ywkUFkvhr1p7MmJBvnQT0bfqR88Ou9+uff50vlviglOJ0tam4g675bJzqSUa8REIRA9+tFIOWuCWD2Wtn+u0NtBT5ZPfPEOZcXWkAQbh/3m978+DSCkqQKGaIJosLCV8ILm1JQeEei2A6XRcCA7BRL0MX/3hc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EFRIuEf+; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EFRIuEf+" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783600358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qIaNLNm9VuAS2foEnqbP367IvDgYygGITQCqidSdvLo=; b=EFRIuEf+dcSQJ16OaGTavldWW10IO15UpndLxGXEf55y6xSwQf3h5ScjCFQAiMcMJ/zxXP j/UwrAWlunDwmtH3iVWqRH+SlJQQf9/sBfR+M/RStV6QEKsdPYQSuRJQMwzB6T6bBahgEn nxYl+L1yi7h50uuFySIcGu/xZom9VNE= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH 04/17] mm/mm_init: skip initializing shared vmemmap tail pages X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Thu, 9 Jul 2026 20:31:31 +0800 Cc: Muchun Song , Andrew Morton , Oscar Salvador , David Hildenbrand , linux-mm@kvack.org, Vlastimil Babka , Lorenzo Stoakes , Michal Hocko , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <2306829C-A66D-41F2-B5F7-1C164A7FF757@linux.dev> References: <20260702093821.2740183-1-songmuchun@bytedance.com> <20260702093821.2740183-5-songmuchun@bytedance.com> To: Mike Rapoport X-Migadu-Flow: FLOW_OUT > On Jul 9, 2026, at 18:45, Mike Rapoport wrote: >=20 > Hi Muchun, Hi, >=20 > Below are some preliminary comments, I'm planning to spend more time = on > review next week. Thanks for the early feedback! Looking forward to more review next week. >=20 > 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. >>=20 >> 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. >>=20 >> 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. >>=20 >> 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. >>=20 >> 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(-) >>=20 >> @@ -673,19 +673,21 @@ static inline void fixup_hashdist(void) >> static inline void fixup_hashdist(void) {} >> #endif /* CONFIG_NUMA */ >>=20 >> -#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) >=20 > What is isolate parameter for? I've re-examined the code, and you're right that the isolate parameter = is technically redundant for our current use case, as memmap_init_zone_range() passes = false. The rationale behind keeping it is future-proofing. The ultimate goal of = a generic HVO is to support arbitrary huge pages, not just HugeTLB. I decoupled = this as a parameter to prevent potential regressions down the road; if a developer = leverages this for other huge page types in the future, they won't inadvertently = break things by forgetting to update a hardcoded false in = init_pageblock_migratetype(), especially since memmap_init_range() natively accepts an isolate = parameter. Of course, we could also just delete this parameter for now and add it = back later if needed. I think both approaches work. Which way are you leaning? >=20 >> { >> const unsigned long end =3D pfn + nr_pages; >>=20 >> for (pfn =3D pageblock_align(pfn); pfn < end; pfn +=3D = 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 >=20 > 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. Yes, that's for the best. I was really struggling to choose a suitable = macro for this earlier, but I realized it's a difficult thing to get right. = I'm leaning toward selecting PAGES_PER_1G instead. Muchun, Thanks. >=20 >> cond_resched(); >> } >> } >=20 > --=20 > Sincerely yours, > Mike.