]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
kho: simplify page initialization in kho_restore_page()
authorPratyush Yadav <pratyush@kernel.org>
Fri, 16 Jan 2026 11:22:15 +0000 (11:22 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 1 Feb 2026 00:16:04 +0000 (16:16 -0800)
commit8f1081892d6218d23bf8afb4246217c41f5a9b21
tree558ecda1132834cd15a5f62f1b146529d7201239
parent840fe43d371fc59ef2da6b6bb88a4d480eed9a38
kho: simplify page initialization in kho_restore_page()

When restoring a page (from kho_restore_pages()) or folio (from
kho_restore_folio()), KHO must initialize the struct page.  The
initialization differs slightly depending on if a folio is requested or a
set of 0-order pages is requested.

Conceptually, it is quite simple to understand.  When restoring 0-order
pages, each page gets a refcount of 1 and that's it.  When restoring a
folio, head page gets a refcount of 1 and tail pages get 0.

kho_restore_page() tries to combine the two separate initialization flow
into one piece of code.  While it works fine, it is more complicated to
read than it needs to be.  Make the code simpler by splitting the two
initalization paths into two separate functions.  This improves
readability by clearly showing how each type must be initialized.

Link: https://lkml.kernel.org/r/20260116112217.915803-3-pratyush@kernel.org
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Alexander Graf <graf@amazon.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/liveupdate/kexec_handover.c