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 9B03A606A32D for ; Thu, 3 Dec 2026 13:00:08 +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=BCe3oO+t; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WW4LzWR/ 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:Date:References:In-Reply-To:Subject:Cc:To:From: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=y76DtkQU87RW5Jm0rtuSdsXudhZc62fvADer6XJZK3A=; b=BCe3oO+t0dAuIqPtsHawJHi9kk utRzrGmjfQVNPzPCcVVMGOHETopHi7ruru8KFytaWtEio3v5l6K4p5QFWAGR20Oau09xJBibSDF9H 5k4GM1HKBbKj4M/kejZtmLkeRWsMvnGuIvzoDRECSeg2JhsR4rivHUcPGqJvNYAEkPUNOoiYThOKH cy8bCs/XHFMGlqVnk72CVo0phVNmR+d0JneoyLP0HyhgJHd8w/j8mJPbenoSgUskTbkXIUNJGsf5Z GvFeCPgMcssecU9QSurDQxbuVqsvRqh7G/b+HaI3pVu8RyyT78EYZ6L1cfrxvNXBQFPXOxMDrjSAp gDmHJ1Wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ6Pw-0000000EeRm-0Xww; Thu, 03 Dec 2026 13:00:08 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ6Pr-0000000EeQv-0z4R for kexec@lists.infradead.org; Thu, 03 Dec 2026 13:00:03 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 026DF4052E; Thu, 3 Dec 2026 13:00:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2794A1F000C1; Thu, 3 Dec 2026 12:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796302801; bh=y76DtkQU87RW5Jm0rtuSdsXudhZc62fvADer6XJZK3A=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=WW4LzWR/MAsUbvZAaJD9RFqSZ9D72Y/buRMdAq1DsxvTKF1ZAtk7E+7i76AfSGViu 2k21Q/moHa5aqTblw2oj5zrAjaHr9d9OVSMd98Er9BxT9yJIaEBu6TLGKbz4SAn3Bx ZqT1YUNLTyPUQvQBksMyPCeW/i8FKlAGzhjbQS66Jsg6piJ+JoaHJAXzCgK+Y6Jkhx NSpPSp1JR0v5P3Eq4s24y9tWt2DiB5U/ejxEuqoslLcNB4WYCS/1VbAKqJHMiVjeTF w9juN9wtKwiwceGbON2KkquZ7H2iuwIK4BdS6epJ+EBe4gaWFsBdIceEc/vfxF6Cju vh1K7jDzF/9fQ== From: Pratyush Yadav To: Chris Down Cc: Samiullah Khawaja , Pratyush Yadav , Tarun Sahu , Pasha Tatashin , Mike Rapoport , Alexander Graf , "Andersen, Tycho" , Anthony Yznaga , Baolu Lu , David Hildenbrand , David Matlack , "Heyne, Maximillian" , James Gowans , Jason Gunthorpe , Pankaj Gupta , Praveen Kumar , Sagi Shahar , Vipin Sharma , Vishal Annapurve , "Woodhouse, David" , Luca Boccassi , Jork Loeser , Chenghao Duan , Zhu Yanjun , Sourabh Jain , linux-mm@kvack.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: KHO bootmem without pre-reservation In-Reply-To: (Chris Down's message of "Wed, 02 Dec 2026 12:26:59 -0800") References: <20261124205808.4097419-1-pasha.tatashin@soleen.com> Date: Thu, 03 Dec 2026 12:59:53 +0000 Message-ID: <2vxzmrqmtt86.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain 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.4 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 Chris, On Wed, Dec 02 2026, Chris Down wrote: > Hi Samiullah, Pratyush, Tarun, > > At Meta, the size of the bootmem reservation is currently the main thing > stopping us from enabling KHO more widely, so I'd like to spend some time Why? What exactly breaks due to bootmem size? Did you try with Mike's sizing fixes? > on reducing it. Before I start, I want to make sure that I don't duplicate > or get in the way of what's already planned or in motion. > > Here is my understanding of the situation as it is right now. Please let me > know if I have anything muddled! > > - On 21 Sep [0] there was discussion about dropping the pre-reserved > areas and relying on dynamically extended bootmem instead, perhaps with > a small bootstrap region. Samiullah wrote up the initial ideas. > - On 19 Oct [1] there was discussion about the report about CMA pinning, > and Tarun's work with David on migrating movable pages into CMA. > - Mike's sizing fixes are now in the liveupdate tree, and the notes in > this thread say that the bootmem layout is still expected to change. > > I have a few questions: > > 1. Samiullah, is the design doc public, or could you share it? I couldn't > find a link to it on the list. I also saw there's a mention of a Google > Doc attached to the calendar invite, but I didn't find a link to that, > only to the Meet link itself. I don't know if the design doc is public, but I can share a brain dump of the ideas we discussed. The main idea is to use kho_discover_noprsrv() as the primary source of early boot memory. So we probably keep a very small bootmem size to bootstrap, and then try to discover unpreserved blocks of memory at boot. The algorithm currently works with 1G blocks of memory since the main user is hugetlb 1G pages. But the 1G is a pure hueristic and we can tune it to something that works better, or perhaps even search at a smaller block size if larger blocks don't provide enough memory. I think it is a promising idea, but the main concern I have with this approach is reliability. The number of blocks the discovery algorithm can find depends on the placement of preservations. If the preservations are fragmented enough, you might not end up with enough memory to boot at all. You are unlikely to run into these situations in testing. In production, I am worried that a few machines in a large fleet will fail live update, and it will be quite annoying operationally. You could further optimize things by computing these unpreserved blocks from the previous kernel. This also lets you make sure there is enough memory for the next kernel to actually boot. It is slightly better than failing the live update _after_ kexec. If we can solve the reliability problem, I think it is the way to go. I explored another option that is much simpler but has some big tradeoffs. We could simply turn off bootmem-only mode right after memblock is allowed to resize. The cost you pay is that now all preservations are in memblock so all reservations need to do more work. You also run into the risk of memblock array not being able to fit in available bootmem. If you only do large preservations primarily, like 1G, this idea isn't too bad. With a large number of 4k allocations though, the performance really starts to drop. For the VM use case we have today, I think that is fine because most of the memory is in 1G pages anyway. But other use cases that need 4k pages might suffer. > > 2. Is anyone working on an implementation at the moment? If not, I'm > happy to take this on. Not that I'm aware of. > > 3. Is the main open problem still how to guarantee that the next kernel > can boot when the preserved memory is badly fragmented, or has the > thinking moved on since LPC? Yes, that is the main problem in my mind. > > 4. Would smaller reductions to the current scheme be welcome in the > meantime? I haven't measured anything yet, so please tell me if I'm > missing something. :-) Yes, if the changes are simple enough. Here's one thing to try. Currently there is a single global bootmem allocation. This means on NUMA systems, one unlucky node gets the allocation. This node has more CMA memory than others, and is more likely to run into memory pressure. We could spread the global bootmem evenly across nodes to reduce this a bit. I haven't ever looked at the actual numbers, so I suppose the first thing would be to measure if it is even worth doing. > > Either way, I can measure on top of Mike's fixes and test with our > workloads, and I'm glad to pick up whichever pieces are useful. I think you should try Mike's fixes. They reduce bootmem size a lot. You can also tune down bootmem_scale, but that's a heuristic because you have to guess how much memory future kernels would need. > > I'd also like to propose that as a topic for the next call if that sounds > good? Is that scheduled yet, by the way? > > Thanks, > > Chris > > [0]: https://lore.kernel.org/r/20260925143000.2729890-1-pasha.tatashin@soleen.com > [1]: https://lore.kernel.org/r/20261025143601.2564170-1-pasha.tatashin@soleen.com -- Regards, Pratyush Yadav