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 B8DED384CF8 for ; Tue, 12 May 2026 06:46:42 +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=1778568402; cv=none; b=Kr4Hl5DqNugMMUlmesm2e5U9r/2onkhwEdrmWYjMjx+bFB+pq9fM8BiwBfoShSyvw0JgE2ZC56Gj6kApHaXiq77bCZCP6zzU/Sht0jzuhb8KpBB0qwUHMMgk6/9cRsZuKeOOgBxXFaWfwoX5P2T6fICxxa6FqvhZepHs9HiR6zA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778568402; c=relaxed/simple; bh=9lo3a8HNQUQfSXTkObC7PN3s4BMtQs5GlB1W7QFzB7g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Je+c9kvGAb8jaMfNy+iQlgn9srsYxL+SwSi6+p8b8LDMEQk/WX6zCMJnuVuEGHDl9PVgSh9/gHy5BU2lwGra03aoMQrfeWVvLvFAY6a/TmxROocl98CS+ViXKJVaG1quheVdn3pnzrGP06XyVk3vkjj/+2JBG6u4tj+nA3NTQ6Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iq4WyErZ; 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="iq4WyErZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BD99C2BCB8; Tue, 12 May 2026 06:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778568402; bh=9lo3a8HNQUQfSXTkObC7PN3s4BMtQs5GlB1W7QFzB7g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iq4WyErZxLPa5eoiE6vV9GoH+CAJnCkGrApLT+EmefaDjXY/+2mDAOR7SPbNRKOSX DJAN1+v+XyLPXBDgwYfvsVN7qnZ3HoGKeFY7UKmQAav6t29Unz2ZDP8Djl25+dsovY Aax9awSrj1xfSIKYIH2onurNuLSiP+GeF98D63cA50VnbAYy7x7GTjkr7CSQTTuDwr pxwa6tzNkqebXStif+d+CflDW8A18wjD141aoQYoExJQ0uLgZHh7uW5U1UhJF/WT1t V9iESmawjhAQU/kVhViAuNkUm8I3bRmYilndNwTl4dh7aR+ECGgFJr/S8b+7EWpcxT oxkBD/BCsWz7Q== Date: Tue, 12 May 2026 09:46:34 +0300 From: Mike Rapoport To: Pratyush Yadav Cc: Pasha Tatashin , Alexander Graf , Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Jason Miu , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/12] kho: store incoming radix tree in kho_in Message-ID: References: <20260429133928.850721-1-pratyush@kernel.org> <20260429133928.850721-3-pratyush@kernel.org> <2vxz4ikddi6y.fsf@kernel.org> 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: <2vxz4ikddi6y.fsf@kernel.org> On Mon, May 11, 2026 at 06:28:21PM +0200, Pratyush Yadav wrote: > On Mon, May 11 2026, Mike Rapoport wrote: > > > On Wed, Apr 29, 2026 at 03:39:04PM +0200, Pratyush Yadav wrote: > >> From: "Pratyush Yadav (Google)" > >> > >> This allows other functions to also use the radix tree. While at it, > >> also use kho_get_mem_map_phys() instead of duplicating the code to get > >> the radix tree root from the FDT. > >> > >> Signed-off-by: Pratyush Yadav (Google) > >> --- > >> kernel/liveupdate/kexec_handover.c | 27 ++++++++------------------- > >> 1 file changed, 8 insertions(+), 19 deletions(-) > >> > >> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > >> index ba568d34c5b4..5758dc6fab5d 100644 > >> --- a/kernel/liveupdate/kexec_handover.c > >> +++ b/kernel/liveupdate/kexec_handover.c > >> @@ -1294,6 +1294,7 @@ struct kho_in { > >> char previous_release[__NEW_UTS_LEN + 1]; > >> u32 kexec_count; > >> struct kho_debugfs dbg; > >> + struct kho_radix_tree radix_tree; > >> }; > >> > >> static struct kho_in kho_in = { > >> @@ -1373,24 +1374,10 @@ EXPORT_SYMBOL_GPL(kho_retrieve_subtree); > >> > >> static int __init kho_mem_retrieve(const void *fdt) > >> { > >> - struct kho_radix_tree tree; > >> - const phys_addr_t *mem; > >> - int len; > >> - > >> - /* Retrieve the KHO radix tree from passed-in FDT. */ > >> - mem = fdt_getprop(fdt, 0, KHO_FDT_MEMORY_MAP_PROP_NAME, &len); > >> - > >> - if (!mem || len != sizeof(*mem)) { > >> - pr_err("failed to get preserved KHO memory tree\n"); > >> - return -ENOENT; > >> - } > >> - > >> - if (!*mem) > >> - return -EINVAL; > >> - > >> - tree.root = phys_to_virt(*mem); > >> - mutex_init(&tree.lock); > >> - return kho_radix_walk_tree(&tree, kho_preserved_memory_reserve); > >> + kho_in.radix_tree.root = phys_to_virt(kho_get_mem_map_phys(fdt)); > > > > Do we really want to remove an explicit check for 0 and get a WARN() in > > kho_radix_walk_tree()? > > If mem_map_phys is 0 then kho_populate() never sets kho_in.scratch_phys > and thus kho_mem_retrieve() never gets called. So here it will never be > 0, and if it is, a WARN() is certainly warranted. > > Perhaps I should add a comment since this isn't so obvious? Yes, please. After a few weeks it will be completely obscure. > > > >> + mutex_init(&kho_in.radix_tree.lock); > >> + return kho_radix_walk_tree(&kho_in.radix_tree, > >> + kho_preserved_memory_reserve); > >> } > >> > >> static __init int kho_out_fdt_setup(void) > >> @@ -1597,8 +1584,10 @@ void __init kho_memory_init(void) > >> if (kho_in.scratch_phys) { > >> kho_scratch = phys_to_virt(kho_in.scratch_phys); > >> > >> - if (kho_mem_retrieve(kho_get_fdt())) > >> + if (kho_mem_retrieve(kho_get_fdt())) { > >> kho_in.fdt_phys = 0; > >> + kho_in.radix_tree.root = NULL; > > > > I'd make kho_mem_retrieve() void and put these there. > > Sure, will do. > > > > >> + } > >> } else { > >> kho_reserve_scratch(); > >> } > >> -- > >> 2.54.0.545.g6539524ca2-goog > >> > > -- > Regards, > Pratyush Yadav -- Sincerely yours, Mike.