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=I8Ziin6UEnN75Y7VPznKZuqHeZEwIEd8nKUrrfYnFLVzMt7Hq3et/zIAqWAmyWcaIbrJ gJDbFkUnmOSSsa/FBuRBbmaQJDnWSrpePtz4pZGncNIJOHJE1Ts9syTBOP+053v6TDoBj C6JK5vyMjyPsRuN7aeJZ2VNrgHjlgPXPEWeENwU/Jli5bISXkP11OrrX8Noglmu0y2fCQ UMYpdyIvBNdOiUaB6BepY4OZX+Cg3VV4hf4W3Z4sUnn7YKs4w5bm+LVsmK/1WlnJr9BUD 9cASUibcWqmvB+h7rA3DOCV2I9iymhnyBWG8EHZn5rxTTjhCv3ZifJ//gzr9UaECuEw== 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=b9+CyjK0f3EQhOzmC7uOvmnYost/nWqKyIH2Zw1tLwvTEtgISzIfENpd0BNM+CTArDrt TR11gtEvsN70fEKECWtLe0td3VW6krwa5lW5nhulGmVNuBmwtj0iimr0t2NsYTbTQVRgk jxBeFxPZpps9Ge0VNDE+y5IuGeK3a1QRToWKOZOuW5wNhsDvMZN8v3dr4sH2qmLyGNUFF SLYMS1Cn+jmE9CQynQHMu6bgQciICaXx+5Bk+TiP1XIFtnRGt26yzYsccJrPfqFDbS835 o9+3YmEzZxNmSXHVTzp9CNzF8EYhVpTwJCpp1zHnYSJp7HmZ361tggthc21VlNmYzLQ== 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 1DEDF606A333 for ; Fri, 4 Dec 2026 20:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1DEDF606A333 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-8a72cead747so3400487b3.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=wxpVKnryQ38+x5jo6PnGE3yq4IWX2mYlI5YFlI3qkF+lSzbpwREMCfr5Mim4DAI3Rd zN/6poKWkjoCqkdZKougGELcPLpGYfA4UKY/VORX6EHj4QwSQ6scvwqQXWmb9sfSmoHC uZbz7yWtpJErUhrccshWXPrJLCPJee0ASNE25uPE/3yIlhxALqlrK2+Y1sQFLKpPisLF aawjBk4BlKUfu7jaEEjA0xD4GWTkpPoKI41yE1gsWlFgRO5C0MKwWnc5Cv2wNM6Qgfm0 5EfdADLQrzZ5HLDlQrD2Q5DJ798DA7r0zAIeAxzqvAg3oWDOi4JZfz6ndN1oIrL5epUS YqJw== X-Forwarded-Encrypted: i=1; AL+hErHr1wJ8xP7nDCWpK33zRGyOHIpVNY23JdzcaY1Nw4j1DwnpnpGrYpHMQ6axfyaiD8jN2TgmBLGNtGzELCo=@vger.kernel.org X-Gm-Message-State: AB4q+uEU0Q+/7M4trSEqz3SYQB0Oq+JXpsFV0/U3zgcqNetBX0Zy8eUP dSAVeU5NRc0iwW+WPaLzt2avkkvItTPiy5p2gUtVaFGkGJW25YqlIPrj7V98eHlb0LI= X-Gm-Gg: AZFdTZczCfsY5BAzQd7i/88QUpWbmS9TCYxMBlI9mDKuPsAlxR6ev2mtLFvFd+BQzmu NbadKRa+TBKuIP+U1pgdxvwewP+/IPDlfVaKwvfbNjPvzS7suH0VukwYzz/UlxoVak7HxL2z/ay YHYcl7aIMHZUNip95/A9gc545BSHyRebdKJmDAFOt1XCK/+AeKiDxX67pbIaIS7BhDgxK+9SIfU YQIHVw/cdVZAQxvMnWg6mxIZXH2Tcw0jaEXo9FY2TZLrDvvE1qcUkGXXCS50Y3Syb4zdNotJMt2 ZCd7yYn74hAvPshrtiZvJ/Fv/LqLyqozR+ar8xofbAA9wFh3AcKWv1Aa6QEtsudIRAPHhhgjvua jSscd5obLnQ6Tz20vcizSnmdoa1kfBpgXzGJMVmax3MEhOX7x94EovZ+ijhzh/LyxKr+j/QDBHj NzEpP8p9a1kvaQULSUMUm8StwCWpVt6D5OWrp5D4P9rjY67jsOJyMbJzDnbKVaOai2eAkGCmQbz LUZR/RhSi1E1R9rONr9+wkNaeEQQykcTWNy+XtNLm/yIsGqQs6Na0kE9/0TiNc5ALaEsnvkc4j7 qA7Y2FQtyQuFT+hAnU80lXyXpluAYFTUkbOQ3WgBxmIRkBw0vsEPozmclQav+Y2lw4J+8ORAu7E TPBINa2ZwEBe/vOlPkrQ0LKwEq4bwCcNaObXcllFdJMgTMEbQu4fBd+L3+MP2uI+x9jQbeJdCH0 KWqbQQE1WFKBxIVdqqqNsoPDEEwImnplIrsDtHtgMxF6pElMliv1sjECYj/TrkMAYiAWuvOic9e 7J+f4p+vD1NjpuS/S1hb1A= 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-kernel@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