From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796209144; b=nGjnRvbIn0nzJIjoeSrWKIQUXSFXUZpgj6YkjmEY4RuyEWQmkrYIijMYlHtoK3R8Z3SY UFlceqT2vt1mLSdnzO1N7jMlMJNDzUQ081GuvG5BscBof8EUnAl66/nilopV7le6oHmGP mzeLh8bxtUFVgWwMGAXQQSiIJz7Wz6Q4mFaPkUgt+bTwktMUSQ58Un9XPrfWA9/YZ+lLI nV8yWjIxHgFdXB+BM8I4lerXNO1P3tw565J2XnwqWVfUDpAffdot2l6Vcj80lj3tlYbVr lQvnVzBW6D7hpp2hS2SgKTAqtmMzCUiDdC2QmC4ZI08NvX8j7Qq1fFyuNvsNOGOtMMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796209144; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:User-Agent:MIME-Version:Content-Type; bh=JPxE3S8G5XsvRzeRTLGd+G/IODPjwtlxgHGcZBJZAps=; b=U5MfYyklr21ZSsN98XTDgP951x6T53rbZxRuDVe+rCLGHdsUfVuUqFmCTYoSU31xJPLs l8CesCd5QKxk87uT9o157YNsHv/a1FJv/eGtWk2hch83/e4E6+EbhH+WuM4WvsceXtsOM KevDWPVocYTCF/cMGqudcpr+/6u4WyfI8rI5rq/7LBHFrDpgYyLlOri/JetJRCGpelk9n 2jqXDROWcOZPhcSV1hjuhrtPvlpg/xnjkneBP2pfcqdoMDhrpbt5oAwB1tExmxCbK3GvS 7nqBjgPpJhaCSco4oWOKJc10PX9685CEocb7uAoXQuTmwtYv0whBGYCKunMkEvYk9BA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CdKk7AnR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AC74606A31A for ; Wed, 2 Dec 2026 10:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CdKk7AnR 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-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 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