From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796415584; b=ezIHDFsx1NjxZgAF734sl1S4GGQkGY+KJ53wtrlJM3AzvCRUHkD37QtJ8r2HyVTzNZuD 2dsFHeRqx0DvnKMvRYCD4rfOuR51ZjmvSTlDJpGH6ArL7tPGccDtLrrIdkxc/zDWwqNFZ 5oiCgQh/Ta0hqH/M0+lwUXLzr8N4/5g3ti+gFVxd7U2ka0YnudEgAl2ly9VBWX2vjunbs vPeQblHOWSOqfnP0ufr5alLpZ2QC7130iixm2gC5RbvfpOcgOOkAjthknHTEVd8Od5I4n Nn964gcFp7Z+CnYIxkEKANIZcyJ+rZKF0hnnDTfagq4mA/db9zY2R0fOfoUu7+ot8Zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796415584; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent; bh=w7ZUG4Zjdh7CYhPlx+AD79yJp4e0pZFEl3ZERG4+rOU=; b=4SzIUnMPyFxyGOdQssKY0bIzaSRgZOOJHtN6ak9Q1z9AU/PMF+Xjlqopj1sKjMW1W/Xk FeKM1zBeaskckxeRE0DCNGnhdDVh7ecRtPCAMISdaxdEZnPHxi6CML120SbeqgDyqR//k wTmBZwZEixOhfPQOIwDHC1hQyWAQ2kRQoojSTfW5CDo0/5GDtpKZ1kvsCfd7VZUNZ6n3O lYNh5k8qTuGRl5oWUS3VgZn+ANpLx4ImnhMIONXEZHz0+idch2J692o9EKgVpWMthzmD5 PWaddVkPNf/ahx4m0aMQfrdChJYM0jTcNS0cLPjBAiFxGypE6SURQMemrVvKVxMEsCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=UJlFNX7x; arc=none smtp.remote-ip=74.125.224.131 Received: from mail-yx2-f3.google.com (mail-yx2-f3.google.com [74.125.224.131]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DE8C606A332 for ; Fri, 4 Dec 2026 20:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1DE8C606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=UJlFNX7x Received: by mail-yx2-f3.google.com with SMTP id 00721157ae682-8a72cead747so3400357b3.0 for ; Fri, 04 Dec 2026 12:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796415583; x=1797020383; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:message-id :references:in-reply-to:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=w7ZUG4Zjdh7CYhPlx+AD79yJp4e0pZFEl3ZERG4+rOU=; b=UJlFNX7xFnj9mnQQz4wXZm0P0osH5nK/vGr6e+C2uFA5nH7tTKr9iZs69XG9e8fZQa Os5WAF9hOgDq6gdoewuObIBZvWe7MKMZjjxLgzIbCMuJfNaTdynED7bajr3I9IaelYWk 1GUvN8PwdjRkBg/QZm0sKXPDvpLy8a1086GYk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796415583; x=1797020383; h=user-agent:content-disposition:content-type:mime-version:message-id :references:in-reply-to:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=w7ZUG4Zjdh7CYhPlx+AD79yJp4e0pZFEl3ZERG4+rOU=; b=KdTeKSX/6FkFqCT00wtRijyLxyq7sCn+WPFKgGWTvpRsK6D59O+OOC0hb0cURK1/23 BmKwbxAeXFz5oJd5+peHPOwx6OCYYIB148jtdyz7BzCpgJNDU8sliMnG5fYOb10k5vvN 94cLTpq3O0WGn+GBWUnD6HWI/xRIWlkGdoe5Pi2fQjF237S366A2sqRpDqfDJd+xqNsd XkI12kcg6Un11+fAF/YN8jhntTCGVxZfi+3/hgH79antyg2Sg7N6Ahzo6TaFJmDvaOXI D1xaxpogxtqPD/yEE+gObrUi7PXBpjYj2qx/383pNe8orWNaqjKjim4fCpg1DOggzzYM 1uWg== X-Forwarded-Encrypted: i=1; AL+hErEl/z61tzzBBl/3kK9Ffif2CaifDYOjspsNcewQcCckAFE9F1T/xoZ+tuQ6EcItbw7o2SIWoj6pBuM=@vger.kernel.org X-Gm-Message-State: AB4q+uHaB3PrbnYsSsDH2zw+Gg6RBiXD/pMORw2mfui1uMevxBVWoha3 QfKQmKtjigabtFffdv2jAb6jiIccbrudPZMmHrTvjUvUwHv+E5qN4k0zlEWLqjmnHio= X-Gm-Gg: AZFdTZekCNm7uw4xaqIV/4PU6LERWzOI0zOJJq+RLLT5x1eEYSfjapaTnGOWw83/Jms quz3CkLuhdjE+DsiEDbxJjFf8r6qPaKUjGzx7o/y7dF+KGBcYqOHl/Oc4sPOLrtANZ4PrSLrkTw K6sIBx2hrch/09sLu+TbTTxLkDR7NRrJEMp2qSJ7nNAVNQm0RGefyJPfo8m1zChG6pZTh1/B+o9 N7YGXv/fdt0DxtynGIe6/MHG8KjmRJWxWGaiOzoUsM4EPYFDDcAP65dcPy2XoUPlxqORRchgAcb 0XLdnqHdZmyQLmfS5YvuksK4ILa09o5oxnXqVMhTnNfNCyiMWcMMK773/cWPTuk9da72ZB6G4ro g9Z+V5Sq4ldMhtoH/PUNq3r8GAKeYnZyCNgRfA/epl++nRMTaHGLDovUf7GNvk9R+shHdfrNBJb fhk+7ItJpPyGAkcGU2GvnDxyXvb4UbRx7rBRFL7fabbS7iiM5Z1b/T77xhtk3494rxfAdXM1UF7 wtbmf4VV7u00si0yHD++NfR91TqCj3rfWD6mGeAxI0ti87M69EUeiqpl1cIxCo3GPa0snz58nth sIhozS67TDpcj4J2+nDyu651Eq2kfa9ayzdNL0Af4xHZGOCFhEorlckw+mNvJ1j/iqkq/tKRwGi SsK/qzUl5z7avrr5s2hpHby7xLAJTx69XGAgQxO3G0NOtESbP7OS0WSR21vZcdCb7RC52s65GDL L68EHyKsPPw4qJLLpMLJo1fzQwCxNkal7/tNb5er/sM3pTIlodNRpWo3FyemeJfk0hEWQfRb36h ujii7V9XyMSncIOBC7fUYU= X-Received: by 2002:a05:690c:698c:b0:8b4:c1ef:7a62 with SMTP id 00721157ae682-8b660d910eamr14381187b3.49.1796415583109; Fri, 04 Dec 2026 12:19:43 -0800 (PST) Received: from [172.18.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660e12321sm13869297b3.44.2026.12.04.12.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:19:42 -0800 (PST) Date: Fri, 04 Dec 2026 12:19:40 -0800 From: Chris Down To: Suseendran Bhaskaran Cc: Andrew Morton , Mike Rapoport , Dan Williams , David Hildenbrand , Alexander Graf , Alison Schofield , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Changyuan Lyu , Dave Hansen , Dave Jiang , David Rientjes , Frank van der Linden , "H. Peter Anvin" , Ingo Molnar , Ira Weiny , Jonathan Corbet , "Liam R. Howlett" , Mark Rutland , Michal Hocko , Oscar Salvador , Pasha Tatashin , Peter Zijlstra , Pratyush Yadav , Randy Dunlap , Shuah Khan , Thomas Gleixner , Vishal Verma , Vlastimil Babka , Will Deacon , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org Subject: Re: [RFC PATCH 01/11] mm/cma: clamp multi-range search to 4G and honor memblock flags In-Reply-To: <20261202001946.1226273-2-suseendranb@google.com> References: <20261202001946.1226273-1-suseendranb@google.com> <20261202001946.1226273-2-suseendranb@google.com> Message-ID: X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) Hi Suseendran, Suseendran Bhaskaran writes: >It also passes MEMBLOCK_NONE to for_each_free_mem_range() instead of >choose_memblock_flags(). On KHO boots, hugetlb_cma_reserve() runs in >mm_core_init_early() while kho_noprsrv_only is active and before >kho_memory_init() reserves preserved pages in memblock.reserved, so >ignoring choose_memblock_flags() can place multi-range CMA areas directly >over KHO preserved memory. This looks great, and I tested and the behaviour is much better, thanks. As an aside, I'm about to post an RFC series which allocates the hugetlb_cma area the same way as boot-time HugeTLB pages, so that KHO doesn't count it when sizing bootmem. A side effect is that if the next kernel can't fit the area in a single range outside bootmem, it goes to the multi-range fallback instead of taking a range inside bootmem. So that series makes this walk easier to hit after a KHO kexec, and it can't go in without this fixed. >Fixes: c009da4258f9 ("mm, cma: support multiple contiguous ranges, if requested") >Fixes: d59f43b57480 ("memblock: add support for scratch memory") The 4 GiB part of this has since been fixed by Mike's "mm/cma: fix handling of free ranges that cross 4G for multi-range areas" [0], which is in mm-new now, so this patch no longer applies there. That also did the #ifdef CONFIG_PHYS_ADDR_T_64BIT change, so what's left is the memblock flags and the wraparound check below. With the 4 GiB part gone, c009da4258f9 is no longer what's being fixed. The flags part goes back to d59f43b57480, since the multi-range walk already used MEMBLOCK_NONE before free memory in memblock could hold preserved pages. >+ orig_start = max_t(phys_addr_t, start, SZ_4G); >+ start = ALIGN(orig_start, align); >+ if (start < orig_start || start >= end) I don't think the wraparound can happen. For ALIGN() to wrap, a free range would have to start within align of the top of phys_addr_t, and memblock memory is nowhere near there. __memblock_find_range_bottom_up() does the same round_up() without such a check, so I'd just drop it. Perhaps you could send the flags fix by itself as a separate patch as you offered in the cover letter? That would selfishly make my life a lot easier, since then I can base my series on that. Thanks! Chris [0]: https://lore.kernel.org/r/20261202113910.1412130-1-rppt@kernel.org