From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 214FA142E83 for ; Wed, 29 Apr 2026 03:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777431733; cv=none; b=AVydXmcMuh7evj5TtSbLzwVIik2KLnmmquTaKR+DRUl3ip/UicRgW74Bldf/AwsQKr5z65eACO53FIBGniEzFAD7s7r6fQLquNROGPUjXyDZ4wGUvtw8TZcVBSC1HI1heo3zFPNw515mlWBRf7S1WQdSrU8lmHCgvkKcSRiBQbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777431733; c=relaxed/simple; bh=mioaeRh4xxmnCzluCpiksW6vIBWKLL7Bh/1jqef5VXk=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=Sr+Gm8bh/1xGFNs1YTWonw1uOFedfU+ZuQLPKUsQrvLY7/+M2Xr0b9uj08nSK5tzv6LtBpmV8nVEcIKHb6LDSD8UkiSMIYZMpGZAEXMRod9MbcSyvVeu0L91phtv1wWl9mbgXlCVXmwWoJWbok/XJjHf2BsPlwfmjsGyn9uAPYQ= 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=oxo6NdW6; arc=none smtp.client-ip=91.218.175.184 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="oxo6NdW6" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777431728; 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=x/FM019OPNeOk2Zn+soqE+l3vbEFGXrxJeVq00i8YqA=; b=oxo6NdW6M0lAsIZYY3RtZBdCAMu7S1zP9snq5kAiD/XXeKgJgZbX42oUZ/GflFxLq+JPl9 ohJpjC/s/5lrT4PIUDrOXPb9G6oUSvl07gCyZ1ZCGW9ECdgICTJavHZ2JTifPXQBjZLCxd T90uCaJ8pdwRLu71pci2T9gcYmPFyms= 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.500.181\)) Subject: Re: [PATCH 14/49] mm/cma: validate hugetlb CMA range by zone at reserve time X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Wed, 29 Apr 2026 11:01:06 +0800 Cc: Muchun Song , Andrew Morton , David Hildenbrand , Oscar Salvador , Michael Ellerman , Madhavan Srinivasan , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Nicholas Piggin , Christophe Leroy , aneesh.kumar@linux.ibm.com, joao.m.martins@oracle.com, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <25FDC3CD-2202-4099-8E42-877A68D3E546@linux.dev> References: <20260405125240.2558577-1-songmuchun@bytedance.com> <20260405125240.2558577-15-songmuchun@bytedance.com> To: Mike Rapoport X-Migadu-Flow: FLOW_OUT > On Apr 28, 2026, at 15:30, Mike Rapoport wrote: >=20 > On Sun, Apr 05, 2026 at 08:52:05PM +0800, Muchun Song wrote: >> During hugetlb_cma_reserve() we already have access to zone = information, so we >> can validate that the reserved CMA range does not span multiple = zones. >>=20 >> Doing this check up front allows future hugetlb allocations from CMA = to assume >> zone-valid CMA areas, avoiding additional validity checks and = potential >> fallback/rollback paths, greatly simplifying the code. >>=20 >> The pfn_valid() check is removed from cma_validate_zones() because = mem_section is >> not initialized at that stage and it can trigger false warnings; keep = the >> sanity check in cma_activate_area() instead. This is preparatory work = for the >> follow-up simplification. >>=20 >> Signed-off-by: Muchun Song >> --- >> mm/cma.c | 3 ++- >> mm/hugetlb_cma.c | 3 ++- >> 2 files changed, 4 insertions(+), 2 deletions(-) >>=20 >> diff --git a/mm/cma.c b/mm/cma.c >> index 15cc0ae76c8e..dd046a23f467 100644 >> --- a/mm/cma.c >> +++ b/mm/cma.c >> @@ -125,7 +125,6 @@ bool cma_validate_zones(struct cma *cma) >> * to be in the same zone. Simplify by forcing the entire >> * CMA resv range to be in the same zone. >> */ >> - WARN_ON_ONCE(!pfn_valid(base_pfn)); >> if (pfn_range_intersects_zones(cma->nid, base_pfn, cmr->count)) { >> set_bit(CMA_ZONES_INVALID, &cma->flags); >> return false; >> @@ -164,6 +163,8 @@ static void __init cma_activate_area(struct cma = *cma) >> bitmap_set(cmr->bitmap, 0, bitmap_count); >> } >>=20 >> + WARN_ON_ONCE(!pfn_valid(cmr->base_pfn)); >> + >> for (pfn =3D early_pfn[r]; pfn < cmr->base_pfn + cmr->count; >> pfn +=3D pageblock_nr_pages) >> init_cma_reserved_pageblock(pfn_to_page(pfn)); >> diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c >> index f83ae4998990..b068e9bf6537 100644 >> --- a/mm/hugetlb_cma.c >> +++ b/mm/hugetlb_cma.c >> @@ -233,9 +233,10 @@ void __init hugetlb_cma_reserve(void) >> res =3D cma_declare_contiguous_multi(size, PAGE_SIZE << order, >> HUGETLB_PAGE_ORDER, name, >> &hugetlb_cma[nid], nid); >> - if (res) { >> + if (res || !cma_validate_zones(hugetlb_cma[nid])) { >> pr_warn("hugetlb_cma: reservation failed: err %d, node = %d", >> res, nid); >=20 > The warning here should be updated as well. Other than that Make sense. >=20 > Acked-by: Mike Rapoport (Microsoft) Thanks. >=20 >> + hugetlb_cma[nid] =3D NULL; >> continue; >> } >>=20 >> --=20 >> 2.20.1 >>=20 >=20 > --=20 > Sincerely yours, > Mike.