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 E617F33FE3A for ; Fri, 14 Nov 2025 17:33:38 +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=1763141619; cv=none; b=WYW5/DilAB+uCl3c/WvbcB0Eqc65jZl8eIKFSWrkG8ySMug2Mnu+z7Obgk8zaZvGIZelX9V5UFhx9YJF6peOX6Ko2Vx8+3dSChWpi4YZfHYnvwbGcZxULu1lsGhVJeSkBqWVxx6BT+EWWsXTDgA+BkNpBA7gsjzBDxVnq3b/HM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763141619; c=relaxed/simple; bh=xiOmpAH22LBPrHl3S2bglBGW7v5HJxbVPsI9S3i0sCU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=YJ9xJzTS/hC7vOy8ZiqE9AinWYz2u356NaMXCzSP3nBHtQyv8UUSsmHGsml4E6ItVu+AN8EotTMW8e/HHYnI7iCMGOQEA66j/JKJse+x2UoiohBDaqVp7A9h8yQCmr2tMQYx460UXknzYiKxUAsB0yOB1GE//rkGpPkGTEjjXpg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WO8IcdGX; 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="WO8IcdGX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87DDAC4CEF1; Fri, 14 Nov 2025 17:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763141618; bh=xiOmpAH22LBPrHl3S2bglBGW7v5HJxbVPsI9S3i0sCU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=WO8IcdGXQ0Tc67QzXNWENs/BXaSCO+3Ot1YABbffhiA/Howp0f1asS2WJ2hTHFol6 2+0mylwMssClZNggRszcaeyQA3lzVdacjpZ26hZ444vOwuWIa0gHSefxSNYM2rxkyW G12fyasFzCVdPS0pAW6JmCaLYYbiC2S7KRUcjMdZEapajKk9XBkyznNBsKu5U4AHZD BQ0WxH4g1bB1fOO8CX67HpxY6wzgifK0xiGcHzg5kqfX6b8xI7HsRZONHAv4STd0A2 W6TnzvubponvquD2Ryd/MeCJlamvEFPworipOdoXNEXWFg+pXCw8xM2oGaQ/NBkdt6 gfLooe6TTju1w== From: Pratyush Yadav To: Pasha Tatashin Cc: akpm@linux-foundation.org, bhe@redhat.com, rppt@kernel.org, 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 11/13] kho: Allow memory preservation state updates after finalization In-Reply-To: <20251114155358.2884014-12-pasha.tatashin@soleen.com> (Pasha Tatashin's message of "Fri, 14 Nov 2025 10:53:56 -0500") References: <20251114155358.2884014-1-pasha.tatashin@soleen.com> <20251114155358.2884014-12-pasha.tatashin@soleen.com> Date: Fri, 14 Nov 2025 18:33:35 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, Nov 14 2025, Pasha Tatashin wrote: > Currently, kho_preserve_* and kho_unpreserve_* return -EBUSY if > KHO is finalized. This enforces a rigid "freeze" on the KHO memory > state. > > With the introduction of re-entrant finalization, this restriction is > no longer necessary. Users should be allowed to modify the preservation > set (e.g., adding new pages or freeing old ones) even after an initial > finalization. > > The intended workflow for updates is now: > 1. Modify state (preserve/unpreserve). > 2. Call kho_finalize() again to refresh the serialized metadata. > > Remove the kho_out.finalized checks to enable this dynamic behavior. > > Signed-off-by: Pasha Tatashin > --- > kernel/liveupdate/kexec_handover.c | 13 ------------- > 1 file changed, 13 deletions(-) > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index 27ef20565a5f..87e9b488237d 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -183,10 +183,6 @@ static int __kho_preserve_order(struct kho_mem_track *track, unsigned long pfn, > const unsigned long pfn_high = pfn >> order; > > might_sleep(); > - > - if (kho_out.finalized) > - return -EBUSY; > - > physxa = xa_load(&track->orders, order); > if (!physxa) { > int err; > @@ -815,9 +811,6 @@ int kho_unpreserve_folio(struct folio *folio) This can be void now. This would make consumers a bit simpler, since right now, the memfd preservation logic does a WARN_ON() if this function fails. That can be dropped now that the function can never fail. Same for kho_unpreserve_pages() and kho_unpreserve_vmalloc(). > const unsigned int order = folio_order(folio); > struct kho_mem_track *track = &kho_out.track; > > - if (kho_out.finalized) > - return -EBUSY; > - > __kho_unpreserve_order(track, pfn, order); > return 0; > } > @@ -885,9 +878,6 @@ int kho_unpreserve_pages(struct page *page, unsigned int nr_pages) > const unsigned long start_pfn = page_to_pfn(page); > const unsigned long end_pfn = start_pfn + nr_pages; > > - if (kho_out.finalized) > - return -EBUSY; > - > __kho_unpreserve(track, start_pfn, end_pfn); > > return 0; > @@ -1066,9 +1056,6 @@ EXPORT_SYMBOL_GPL(kho_preserve_vmalloc); > */ > int kho_unpreserve_vmalloc(struct kho_vmalloc *preservation) > { > - if (kho_out.finalized) > - return -EBUSY; > - > kho_vmalloc_free_chunks(preservation); > > return 0; -- Regards, Pratyush Yadav