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 42B1A606A322 for ; Wed, 2 Dec 2026 10:59:06 +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=heCiivD6; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CdKk7AnR 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=JPxE3S8G5XsvRzeRTLGd+G/IODPjwtlxgHGcZBJZAps=; b=heCiivD60I68Q3InZHKtbMM32g IcPN8Ibb4xDQC7OF77ITvsOnRD3cAJXY3vPsquUwfHlaj95kraKiw8XuMflzgaBVjRztHU1gOBvNp aKreXpShFDfZB4cu2oxg4u7VABS6dfEgtAZVJY9E372QEr0M2QVJTUYNqL/Gt4OjCwntIXYEVzNno CZ4s9GfYi7A9iqFx9kAg1d/tSC6b6M9j+3DJBevef9ysWZJZz9dOKGpTcWvP0+Krbeo/9PyECLbvE wQ4CEzQccIh3YkamWOMtZqnMBxpuahLlVhIFeODw1CfMnhiYQs6xqtsduKv69Wo8TElPrw32rNEEf 7m6X1Zrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYi3F-0000000BFbt-2la9; Wed, 02 Dec 2026 10:59:05 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYi3E-0000000BFbE-1837 for kexec@lists.infradead.org; Wed, 02 Dec 2026 10:59:04 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id BFC2C4074C; Wed, 2 Dec 2026 10:59:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C05671F00896; Wed, 2 Dec 2026 10:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796209143; bh=JPxE3S8G5XsvRzeRTLGd+G/IODPjwtlxgHGcZBJZAps=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=CdKk7AnRuhFw+Ro8BeOTB6qctktnOhFCRBgsRflg2eVwGqdPLSW3nsC2N6UPRggNb l2/qZ7/8i4XSup7lyE3huLFWPkzBDGXBQpSMTBzX9JoQQ1GT0UjPFiLI/5U28s9RXH Pn1eWv90yjJQw0dw3ACCbxGAf5vd7Xcdk+OpgOOcZdlwB9LQBqFhIdRfdbSE1tTBS4 ErnU3PZShqceTZ/4hUhr598SnjRc2jsHbzSGVzC533VLM0wIIIhmIEt96nfOgvt2cH ikS6TjnEoTDaib11zneVCjkpHWhx7Evez8iuQt9ypE93P3bmqacJPvSBB9NgbIWvpA 1+Vy6VU6ckc3A== From: Pratyush Yadav To: Chris Down Cc: rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2 1/2] kho: skip bootmem setup in kho_init() if bootmem was inherited In-Reply-To: (Chris Down's message of "Tue, 01 Dec 2026 22:32:09 -0800") References: Date: Wed, 02 Dec 2026 10:59:00 +0000 Message-ID: <2vxzmrqouex7.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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 On Tue, Dec 01 2026, Chris Down wrote: > On a cold boot, kho_reserve_bootmem() reserves the bootmem areas in > memblock, and kho_init() later releases them to the page allocator as > CMA. A kernel that was handed its bootmem areas by the previous kernel > boots out of them instead. kho_init() must leave them alone. > > kho_init() tells the two cases apart by whether there is a handover > FDT. That doesn't work if kho_mem_retrieve() fails. It clears > kho_in.fdt_phys so that KHO users don't treat the boot as a KHO boot, > but the bootmem areas are still the inherited ones. kho_init() would > then run init_cma_reserved_pageblock() over memory that is in use. > > Nothing makes kho_mem_retrieve() fail at the moment, but the next > patch does. Test kho_in.bootmem_phys instead, which is what > kho_memory_init() uses to choose between retrieving the handover and > reserving new bootmem areas. > > Signed-off-by: Chris Down > --- > kernel/liveupdate/kho_core.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c > index 15fb892a4412..43ecef317cfd 100644 > --- a/kernel/liveupdate/kho_core.c > +++ b/kernel/liveupdate/kho_core.c > @@ -1928,10 +1928,16 @@ static __init int kho_init(void) > if (err) > goto err_free_fdt; > > - if (fdt) { > + if (fdt) > kho_in_debugfs_init(&kho_in.dbg, fdt); > + > + /* > + * We've booted from the inherited bootmem. That means this kernel is > + * already using it. As such, leave it alone even if the handover is > + * dropped later. Nit: I don't understand what "even if handover is dropped later" means. Doesn't the handover get dropped _before_ kho_init()? Also, perhaps "even if the handover fails" is better? > + */ > + if (kho_in.bootmem_phys) kho_memory_init_early() clears kho_in.bootmem_phys on failure. So this doesn't work. It clears it because kho_memory_init() uses to check if it should even try to retrieve preserved memory. Perhaps it should only clear fdt_phys and kho_memory_init() should check fdt_phys instead? > return 0; > - } > > for (int i = 0; i < kho_bootmem_cnt; i++) { > unsigned long base_pfn = PHYS_PFN(kho_bootmem[i].addr); -- Regards, Pratyush Yadav