From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796244702; b=mRXP89KOgHyuev996qqPtGE8WY9Ng9NblEGXfQQRGzw0g3qjmaK2buBg2syi2Capqa1l EVRjlcjB74cR4ZXvJGMPEBnsjcF9WV9fVLf4O3aGftzVYgGesS6utdcVhrY5fJb90E9TU RbY9JmiJlVAEg9h5p6WHh4rI1hA4wduQJJZJai91A7h8c/us6bC28g5A2snckdYwgQw4C pFE9Y+OX1NO+rKc/0cxDiSSvWw1HAb3XCPuQvbt926NyIzd5r1bWC/PpCABD14SuYEQB2 22lUaKcRvGtCXayVCrCDQkm4mKILF4OyDtP1oKNCkxLL1eGq7tqhpuIpUkfxO1UIjJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796244702; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=RDmDgnmwUn4NAXyK/pjuj4Hyi8Cn37OCIjQydre0FYI=; b=bsT5Bm8SKqvSA5hjGoCVxfQw/U8AQ3UjnIwKE+d7e8SbfnBO7GpD/pkRgv7Kj2BwUegT 5gkwEJjfVnNz5wtrKwblIaQFg0kw6YUiRrQ4l61I/XXTDbi+XSbgDGSJ6xiSALCxpj1ls 6DMoQIcb/F5JNAIooj5gf4fEaaS4jADZz83QbTN+j1lGznA/asee6ElPKoXZDP1NEKbdw 4thGgh605TBEIMxkp+M3Q+aT2Ukpnl3m3U0CBuyDsyf81aO1SgfJhjvPHiyp5KeQggj+U ESLF8DbeL+YHB1kFZl4H8Tkd2eLOLrbtumgJXKDEFZWQfzWOOuEJzDFYuvf6qtZGmHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=AkLyDRqo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42B47606A322 for ; Wed, 2 Dec 2026 20:51:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=AkLyDRqo Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7F0F1F000C1; Wed, 2 Dec 2026 20:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796244701; bh=RDmDgnmwUn4NAXyK/pjuj4Hyi8Cn37OCIjQydre0FYI=; h=Date:To:From:In-Reply-To:References:Subject; b=AkLyDRqolwcoF7lq0gF1JKa9FiseSnK/6XMyAjEx33BFG5R+RwFt2buHFiIxbRFfh lXEXhfw1Uuys9PP+x/QTLsMwke9EOdkWFTU6zOMfwLrCAQ2FXpjHe+QxxWBWleYRf6 gZNnzWeL50vuZHP9CesAMWNyAGamPIvjh5kXdu7M= Date: Wed, 02 Dec 2026 12:51:41 -0800 To: mm-commits@vger.kernel.org,vbabka@kernel.org,mhocko@suse.com, liam@infradead.org,david@kernel.org,rppt@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261202113910.1412130-1-rppt@kernel.org> References: <20261202113910.1412130-1-rppt@kernel.org> Subject: + mm-cma-fix-handling-of-free-ranges-that-cross-4g-for-multi-range-areas.patch added to mm-new branch Message-Id: <20261202205141.A7F0F1F000C1@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/cma: fix handling of free ranges that cross 4G for multi-range areas has been added to the -mm mm-new branch. Its filename is mm-cma-fix-handling-of-free-ranges-that-cross-4g-for-multi-range-areas.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-cma-fix-handling-of-free-ranges-that-cross-4g-for-multi-range-areas.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: "Mike Rapoport (Microsoft)" Subject: mm/cma: fix handling of free ranges that cross 4G for multi-range areas Date: Wed, 02 Dec 2026 13:39:09 +0200 Multi-range CMA areas are placed only above 4G. cma_find_free_range() enforces this by skipping free ranges that start below 4G, including the ranges that cross 4G. On systems where RAM is contiguous across 4G, like QEMU arm64 virt machines with more than 3G of RAM, the largest free range of a node may cross 4G. When hugetlb_cma falls back to a multi-range area, it cannot use any part of that range and the reservation fails if the remaining ranges are too small. Use the part of such ranges above 4G instead of skipping them. Comparing a phys_addr_t with SZ_4G causes warnings on 32-bit builds, so make cma_find_free_range() a stub that returns 0. Link: https://patch.msgid.link/20261202113910.1412130-1-rppt@kernel.org Fixes: c009da4258f9 ("mm, cma: support multiple contiguous ranges, if requested") Signed-off-by: Mike Rapoport (Microsoft) Signed-off-by: Andrew Morton Reported-by: Sashiko Closes: https://sashiko.dev/bug/linux-59c2cbb5-4dcf-49a5-90c2-72f5b734d510 Reviewed-by: David Hildenbrand (Arm) Cc: Liam R. Howlett Cc: Michal Hocko Cc: Vlastimil Babka mm/cma.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/mm/cma.c~mm-cma-fix-handling-of-free-ranges-that-cross-4g-for-multi-range-areas +++ a/mm/cma.c @@ -504,6 +504,7 @@ static int __init __cma_declare_contiguo * Find the largest free range above 4G that can hold a part of a multi-range * CMA area. */ +#ifdef CONFIG_PHYS_ADDR_T_64BIT static phys_addr_t __init cma_find_free_range(phys_addr_t align, phys_addr_t size_align, int nid, phys_addr_t *basep) { @@ -511,13 +512,9 @@ static phys_addr_t __init cma_find_free_ phys_addr_t max = 0; u64 i; - /* no point searching if the system can't address above 4G */ - if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) - return 0; - for_each_free_mem_range(i, nid, MEMBLOCK_NONE, &start, &end, NULL) { - if (!upper_32_bits(start)) - continue; + if (start < SZ_4G) + start = SZ_4G; start = ALIGN(start, align); if (start >= end) @@ -532,6 +529,14 @@ static phys_addr_t __init cma_find_free_ return max; } +#else +/* no point searching if the system can't address above 4G */ +static inline phys_addr_t __init cma_find_free_range(phys_addr_t align, + phys_addr_t size_align, int nid, phys_addr_t *basep) +{ + return 0; +} +#endif /* CONFIG_PHYS_ADDR_T_64BIT */ static int __init cma_range_cmp(const void *a, const void *b) { _ Patches currently in -mm which might be from rppt@kernel.org are mm-cma-simplify-cma_declare_contiguous_multi.patch mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch mm-secretmem-disable-memfd_secret-if-secretmem_init-fails.patch mm-cma-fix-handling-of-free-ranges-that-cross-4g-for-multi-range-areas.patch hibernation-make-swsusp_page-helpers-static.patch hibernation-ensure-secretmem-pages-dont-reach-a-snapshot.patch hibernate-handle-potential-errors-in-hibernate_mapunmap_page.patch hibernation-kfence-explicitly-map-unmap-kfence-pages.patch hibernation-make-hibernation-unavailable-when-debug_pagealloc-is-on.patch