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 09E27606A322 for ; Thu, 3 Dec 2026 06:32:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pAgdmMHl; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nIp+4pZr DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Cc:To:Subject: From:Message-ID:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=IOaiKKSSnJKcoSyqWbUOL4152C/cZVHE2/Y3vD1qoLk=; b=pAgdmMHluGwnev0Z5GgLDDcMOt IMzwkpYx5YUi0hh+5u8ic5uVHEO2vLvn8VTXlTqHnnNj2VvcGFWxxIbmAGktNn+JM2pZorGQ3UXvN QtlJk5bmrh6RdAuY9qnBl4k5p39b/oVWoRMqBhsuMax8ppsI9+trYY+zEjmCUDQCMXtj8JilTZhd2 /1SBlZTKY49/7qOQBMt63bi2JSjs/NnGFYUYXM22TZgswh8xtqEoFgyScJkNTbnKgyh+AQUFRNFxi vNHyR6BqxM0DTfCszqeqw7cMou+hi/p7rOxH05NWPOi5aNfIs9MGq5503X/rnjz0RiLBn8kzWB9AG IjU5vJhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ0Mj-0000000DfK1-0tFG; Thu, 03 Dec 2026 06:32:25 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ0Mi-0000000DfJn-1y9w for kexec@lists.infradead.org; Thu, 03 Dec 2026 06:32:24 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 8388F60617; Thu, 3 Dec 2026 06:32:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0D821F00893; Thu, 3 Dec 2026 06:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796279543; bh=IOaiKKSSnJKcoSyqWbUOL4152C/cZVHE2/Y3vD1qoLk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nIp+4pZr6gWeNWKAgThfkAYol8LqVyd7xDDQ91MULH+dLSIt1beh2qluaeL6msd+u /ASBQJLWURbGmhRtdIyg9qAbxNWiCKIIH0EZkcojLMQagVA1Jgdo75UP6B57RkMyjG OVQglk+Lbd6qm5+/H7eRxvoHjbxZBf+TlG2LxsEQTtVESo2TopCmF3B4+o5SHIEnV/ S2Su5HlTXG6xCKnRH3Y971ZK0lu3x6+gWFxJXZDL+IFgpOtMqCLl5mPimW721flGjb C9IallPdaP/jz6w5vVodWiXvWMuROuFZXvgNSfP+61khox63uJEY7kaITk6dbb4nJY ComhRxIQt9ttw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/2] kho: skip bootmem setup in kho_init() if bootmem was inherited To: "Chris Down" , rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org Cc: graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, kernel-team@meta.com In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 06:32:22 +0000 X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "kexec" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] kho: err_free_bootmem in kho_init() frees active inherited bootmem - [Medium] kho: kho_init() skips CMA accounting when kho_mem_retrieve() fails -- commit 8ab45df6c0cc32b7be0a781a67fbb61c13c0156f Author: Chris Down kho: skip bootmem setup in kho_init() if bootmem was inherited This commit changes kho_init() to check kho_in.bootmem_phys instead of fdt when deciding whether to skip releasing bootmem areas to CMA, so inherited bootmem is left alone even if kho_mem_retrieve() fails and clears kho_in.fdt_phys. > diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c > index 15fb892a4412d..43ecef317cfdf 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; > =20 > - 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. > + */ > + if (kho_in.bootmem_phys) > return 0; > - } > =20 > for (int i =3D 0; i < kho_bootmem_cnt; i++) { > unsigned long base_pfn =3D PHYS_PFN(kho_bootmem[i].addr); [Severity: Medium] Should the err_free_bootmem unwind path in kho_init() also check !kho_in.bootmem_phys instead of !is_kho_boot()? kernel/liveupdate/kho_core.c:kho_init() { ... err_free_bootmem: kho_out.fdt =3D NULL; if (!is_kho_boot()) { for (int i =3D 0; i < kho_bootmem_cnt; i++) { void *start =3D __va(kho_bootmem[i].addr); void *end =3D start + kho_bootmem[i].size; free_reserved_area(start, end, -1, ""); } } ... } Because is_kho_boot() checks kho_in.fdt_phys, if kho_mem_retrieve() fails and clears kho_in.fdt_phys, a subsequent failure in kho_init() will take this branch and call free_reserved_area() on the inherited kho_bootmem regions that the kernel booted out of and already released to the buddy allocator. [Severity: Medium] Should the call to kho_account_incoming_bootmem() at the start of kho_init() also test kho_in.bootmem_phys rather than is_kho_boot()? kernel/liveupdate/kho_core.c:kho_init() { ... if (is_kho_boot()) kho_account_incoming_bootmem(); ... } Before kho_mem_retrieve() runs, free_area_init() marks the inherited kho_bootmem pageblocks as MIGRATE_CMA, and memblock_free_all() releases their free pages into the MIGRATE_CMA buddy lists. When kho_mem_retrieve() fails and clears kho_in.fdt_phys, gating kho_account_incoming_bootmem() on is_kho_boot() while returning early on kho_in.bootmem_phys leaves those pageblocks unaccounted in zone->cma_pages and totalcma_pages, causing CmaFree to exceed CmaTotal in /proc/meminfo. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796126791.gi= t.chris@chrisdown.name?part=3D1