From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.136 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796415584; b=AI27LbUVYQ2zGT3htJj96GYrtEDsTRkbcZoNq6dP1T/EFYuF2UCFuiUV5xxCkuTQOT0Q jJQIFJYPPAJ0c9/GYZ3+jQ9iVyuFUS9tGecbm4+0z8R0kS20Zot/En3687bZvWXC44pmE pj7rYPWF+gYtjlpYWtlO7UTYN52pzsN329l6B3obPe5fj6fMxXP9ORUl26zXjZE4ZNQsO 6sf6dv0J+cQSZLDEGVEfY7HSEi+sooxj5FFlzifrFDL5+OVedbiEJvbX0J1wglw3Ussoi 6C664CYoTATHFXbsbqhfnnNj3xSQWoo4oJNK4i/Si4B+FMYDo4JGvVp9ChX+QhuB4Mw== 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=JccsF6QlWoCthpMQBmBVz4VqXtapu3dGsjZwcNcpPKQvXaaTquL43PTdl6xKdE0AQoFJ 58wU1d9a8GgwUdqvT8zSKmC99Vfkf+e5cc6ByE7eL7ZTfGD0iorViOQlBFX6huRVcxMYr HIiFBPZcKDCA8HlilI3aAoHOSbhJnT9vjYXvJjSHS8RTH3670+9Bqt5zf/Lw/XEPXeDOi 0tpeOCTbLYDnvctpxuVC4+5CdQqeSMOndwwzb3dQc6UpoMoew7pQfIrOEhcspcssTLQst j/Rw09M4fY6CiVCinS9djDAAKVhrOX26YNrsNI9WG8Q4yIPOOpxTPUFKFTsA+HKnYtA== 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.136 Received: from mail-yx2-f8.google.com (mail-yx2-f8.google.com [74.125.224.136]) (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 1C01F606A32D for ; Fri, 4 Dec 2026 20:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1C01F606A32D 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, unprotected) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=UJlFNX7x Received: by mail-yx2-f8.google.com with SMTP id 00721157ae682-8b35e6f613dso3697577b3.1 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=c+yjHH1VMsAWyxz8jEbQvhmai0Q0O8z0jyBzA3rSf7HiIBTiDY548kttASK3ibEzh9 66qCbOeIsPxDyQz7/pKLVshu1VdsII4DaauJhhjzYpE2NMy3TJBAiyc/a6XH7hDNxbRA 0Oda4tt0WO/8F0QyLU1wGexpmI6zYsRP8v5xyIJxo/tRfjY0Ai/jvsgHWQIDVLujeO9a C2qX4I+5OkxBHz6bKixq7pMf1hRIwvrqJg90ueyqjxw0OuNSgnKmRIZ3+KUelA0If3fU 8707m2Tcz7o+l6uMHq8yY1bp90QmWack+Q/7ubRCglIXOaIb8FsG8Yzpv3P0+LOJT//S gsSA== X-Forwarded-Encrypted: i=1; AL+hErEiKPj+//SKcYg6BHb2nD4hCyX7kqYNBC0CJJHG0gAU3K9AIM1Di8LJ3fRBC8qjBR84u2qDSySUoPI=@vger.kernel.org X-Gm-Message-State: AB4q+uFDpl897iMfPvTMqfOZlsBRDcS2vizgDqRfZYFDbaJDVYGnFtKj oYR1rlINAhfyc+UDXJ7LV9Vd99eiEglXHf8IKK4Q2Sx/KIbCkWevvypIHqcQJmpRdvQ= X-Gm-Gg: AZFdTZedXVc9iS8heSzgMsCOzysvhNkSQ2LuqekW0i94+vn/BXoe+SF2JglhQm9Crrj KsNpKzIgiBinwldkJjiey6HlIFL0+JWxK2hXeVKjldzsNRc6EA/bGIZNtkmtePJfUuChNu17won CkI+P7pm187qTUj8l9Ndcwl9PChDbhwlA2tdARz1E3LujyzWgPLddN1Nf65pM104dCZQrP9v5r+ a9Eu3g6gN7bDj4g13MRRenpp9lKO4dVh/YeEPHwaPqwVm0k20F34OSPhaGIEkS4pDFYjA5EEBrV oZScdCmQRPh5pgX26JbDUpbTM/I323uJBiQYGgdBL/1h+/ADyTHWs0ZlWvWzxEFiHbPvdAXWZQL bd1K/fRzCzq6TVHEiOC9jh1+UhvyeXBwGGisho2EWQfJH2g2SNn/01EfcMdQ2dawPzk9GqM+3Lb 9QtgSoHDBLnga6xNqT3pWgIrmIZ3/yeqtWVX76/5gcFxpNqQxbt9USCrXqJPeSA/yYwQFor4IFF c66AboVMfRuYxay0EkxqsVC5ONf4tAcGIADJgNF0KRpMoP3A13OeA5wqRypVcomVN+ZsILPdSDU YMzvLLqyou0JVWTM9KwKlx6/UDBLCDolYb5A+vsr8in5A8AEojOEF6jsGdr1LHvtivRPbI6UzZd th5uiGtSR/WFmt1yqdF6JkKxBbxVk9p3PMdgnTdOfx7qzJUP4lAOaeR5R77rtyn1bhMUbLH8mo8 zzNEokna7lyuQVWDVnfueZqYlaehW4h6I9t1WeOXER4aBb3CybELGPtkuRcTiaD3qx0V7981a8K QCa5qQHmCEb9+90p0PIdxI= 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-doc@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