From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B51C606A335 for ; Fri, 4 Dec 2026 20:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oc/hnrto; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=QmxOF+fx DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=w7ZUG4Zjdh7CYhPlx+AD79yJp4e0pZFEl3ZERG4+rOU=; b=oc/hnrto0b7yIfaAaXKyAFHM/o 71aMSfl3m84ohM9Gy1XulkPKtpuH8nhia1U/02eQqlocToaslFsCy5tcZcds+pf42ZHyESNOPL18f JWdl/3jv8CFUnFaO9yyvmAU87ZL5ZFN+tdA2FT+fdNzEJY7aO61AF/CF1YPhR1C16w1cpY+5MWHEv Q2aJmAzEKXZ9jQ48w8NeJ9XI+kLwp5Dr3RVue8k54jcgqNxNEzwCzeEnjIl0evdQ2jfF6N/wG8SC3 /5eTWMcIPLQRL00fv2yqtWzlF2miuaWlJnAnljCdjMh2zvGb8JV6cbDesRDRjJ5M08q0l+ltQot9L HufdnRkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZlZ-00000001Q8R-0z1C; Fri, 04 Dec 2026 20:20:25 +0000 Received: from mail-yx2-x0a.google.com ([2607:f8b0:4864:41::a]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZku-00000001Q0G-47MO for kexec@lists.infradead.org; Fri, 04 Dec 2026 20:20:16 +0000 Received: by mail-yx2-x0a.google.com with SMTP id 00721157ae682-8b35e6f613dso3697567b3.1 for ; Fri, 04 Dec 2026 12:19:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796415583; x=1797020383; darn=lists.infradead.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=QmxOF+fxT30JxxtXtlavkA5Kokl6Cl5YS3R7tJ3FG2OUdFgBvoXqDEkzbyC2ZxbQqk Jqi4tN64IrYU+5qAjaCUJ7A69hieB6pIxRlh03jYUEaiLbxhSLA4kVQ37bgAMImhVx97 N+9Sgd5KHlk7u+wOCoc78Ut7WO28d4BeJctY8= 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=q3/CZiD0j90m5RdAb2OCWB9fHu9/9MH+uGInZXirjfqhMUal/X90BbL0ot3BEUyAOs kjloJGVvnWMRr3SkdkmxV/tF/MuRm9iIAvFbttXSfkEe95HBLL+pYXgK6PTEJW4zL8f3 0djStcyZEqPB7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p1DkbUUhaQV/9U0KW6/z6KQ7PxzEm0fbjV 9YpCZuesuXALP3qFkJgyhkMJQuxVOm1UESTVa0lCu60/HGF3xSD2YRq+Y2NXyzDA27duhe1PaUC x2+j+P4uDg+chcEhy+M+hblkie2eFRLJvlHbZ77JL4FynNdWpyfl+QXCSYXGtyYPlx0V/Tft7Cq Cljl2tYzQYNccI7ep0wvpc= 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_121945_033635_45196C36 X-CRM114-Status: GOOD ( 15.29 ) X-Spam-Score: -2.1 (--) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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