From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24EAB27FD4A for ; Fri, 14 Nov 2025 16:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763136936; cv=none; b=CbTlkiEnBSCRDaqbrFV5shPeL/CxeOXYcYs4cgWnAeYTVEg/XyaeG3oAWXUXAckPm9cOi0SAAV/SpjqKHl8ifOZvxJ87JXrD2kTNNzb+GqDQyla7ITe5lquBfcOZ5aaAWaCTnBe/GDbgxnSxqi7KNASLbXuhyKIZ8v8BDnIwZpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763136936; c=relaxed/simple; bh=mS05zN0VOwxcIzYeKKKWbjayWEtwO0xQ9kdg6GbidOg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nXgZ17Ucfh44syIo1MXcTmqSViahXA+4HZMJ31tSNfCrtVlYj/a0OXrpX3rVkw7+UGOUvQPMhZbDmlGHmnG6j8SXcndyUt+BQJDAw5sViNE94WyzBoSF4GGqjzy5BhXSDYZs5Mnlan5vV9QmE/bq1QfbBz9sCDR+518tuyNPM8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UZwFnJlV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UZwFnJlV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0E27C116D0; Fri, 14 Nov 2025 16:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763136935; bh=mS05zN0VOwxcIzYeKKKWbjayWEtwO0xQ9kdg6GbidOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UZwFnJlVY28QzM9QIPLYI58Lo7h47lF3Ah6v4Eq+44AwDgv3fODBre/S6VrWs8hth BlZS3y6bx+osk95r4i8m8r7Fe/sCVNuR5NoKt8h2PJOD8e/lz76TCOtXdnlh3Q3Rth +EOVlg9JTIMGb4+o5+0Pt6mZ/qr/3lfRQ2ToalES0NHGEyDAf0ejHk72tlOaIuQ6uw e8u44IuwWr3SK8UJCCAeydFyOv90rnPB3OogbeL4dbg1R4cguV7ca3DViK6WYTdrRO PbWyboobPJKmEv7zB8f03zlqyNvbC0W9X+Aw6SNlXf5Rj3/n3sD+/B/vQ2V2CZUqiS Mon4k6NpRynJw== Date: Fri, 14 Nov 2025 18:15:27 +0200 From: Mike Rapoport To: Pasha Tatashin Cc: akpm@linux-foundation.org, bhe@redhat.com, jasonmiu@google.com, arnd@arndb.de, coxu@redhat.com, dave@vasilevsky.ca, ebiggers@google.com, graf@amazon.com, kees@kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH v1 09/13] kho: Update FDT dynamically for subtree addition/removal Message-ID: References: <20251114155358.2884014-1-pasha.tatashin@soleen.com> <20251114155358.2884014-10-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251114155358.2884014-10-pasha.tatashin@soleen.com> On Fri, Nov 14, 2025 at 10:53:54AM -0500, Pasha Tatashin wrote: > Currently, sub-FDTs were tracked in a list (kho_out.sub_fdts) and the > final FDT is constructed entirely from scratch during kho_finalize(). > > We can maintain the FDT dynamically: > 1. Initialize a valid, empty FDT in kho_init(). > 2. Use fdt_add_subnode and fdt_setprop in kho_add_subtree to > update the FDT immediately when a subsystem registers. > 3. Use fdt_del_node in kho_remove_subtree to remove entries. > > This removes the need for the intermediate sub_fdts list and the > reconstruction logic in kho_finalize(). kho_finalize() now > only needs to trigger memory map serialization. > > Signed-off-by: Pasha Tatashin > --- > kernel/liveupdate/kexec_handover.c | 144 ++++++++++++++--------------- > 1 file changed, 68 insertions(+), 76 deletions(-) > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index 8ab77cb85ca9..822da961d4c9 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -724,37 +713,67 @@ static void __init kho_reserve_scratch(void) > */ > int kho_add_subtree(const char *name, void *fdt) > { > - struct kho_sub_fdt *sub_fdt; > + phys_addr_t phys = virt_to_phys(fdt); > + void *root_fdt = kho_out.fdt; > + int err = -ENOMEM; > + int off, fdt_err; > > - sub_fdt = kmalloc(sizeof(*sub_fdt), GFP_KERNEL); > - if (!sub_fdt) > - return -ENOMEM; > + guard(mutex)(&kho_out.lock); > + > + fdt_err = fdt_open_into(root_fdt, root_fdt, PAGE_SIZE); > + if (fdt_err < 0) > + return err; > - INIT_LIST_HEAD(&sub_fdt->l); > - sub_fdt->name = name; > - sub_fdt->fdt = fdt; > + off = fdt_add_subnode(root_fdt, 0, name); fdt_err = fdt_add_subnode(); and then we don't need off > + if (off < 0) { > + if (off == -FDT_ERR_EXISTS) > + err = -EEXIST; Is it really -ENOMEM for other FDT_ERR values? > + goto out_pack; > + } > + > + err = fdt_setprop(root_fdt, off, PROP_SUB_FDT, &phys, sizeof(phys)); > + if (err < 0) > + goto out_pack; > > - guard(mutex)(&kho_out.fdts_lock); > - list_add_tail(&sub_fdt->l, &kho_out.sub_fdts); > WARN_ON_ONCE(kho_debugfs_fdt_add(&kho_out.dbg, name, fdt, false)); > > - return 0; > +out_pack: > + fdt_pack(root_fdt); > + > + return err; > } > EXPORT_SYMBOL_GPL(kho_add_subtree); -- Sincerely yours, Mike.