From: Mike Rapoport <rppt@kernel.org>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>,
Changyuan Lyu <changyuanl@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Baoquan He <bhe@redhat.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Jason Gunthorpe <jgg@nvidia.com>, Chris Li <chrisl@kernel.org>,
Jason Miu <jasonmiu@google.com>,
linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
linux-mm@kvack.org
Subject: Re: [PATCH v2 1/2] kho: move sanity checks to kho_restore_page()
Date: Wed, 17 Sep 2025 17:31:43 +0300 [thread overview]
Message-ID: <aMrGT9IyHBFe5-nH@kernel.org> (raw)
In-Reply-To: <20250917125725.665-1-pratyush@kernel.org>
On Wed, Sep 17, 2025 at 02:56:53PM +0200, Pratyush Yadav wrote:
> While KHO exposes folio as the primitive externally, internally its
> restoration machinery operates on pages. This can be seen with
> kho_restore_folio() for example. It performs some sanity checks and
> hands it over to kho_restore_page() to do the heavy lifting of page
> restoration. After the work done by kho_restore_page(),
> kho_restore_folio() only converts the head page to folio and returns it.
> Similarly, deserialize_bitmap() operates on the head page directly to
> store the order.
>
> Move the sanity checks for valid phys and order from the public-facing
> kho_restore_folio() to the private-facing kho_restore_page(). This makes
> the boundary between page and folio clearer from KHO's perspective.
>
> While at it, drop the comment above kho_restore_page(). The comment is
> misleading now. The function stopped looking like free_reserved_page()
> since 12b9a2c05d1b4 ("kho: initialize tail pages for higher order folios
> properly"), and now looks even more different.
>
> Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
>
> Notes:
> Changes in v2:
>
> - New in v2.
>
> kernel/kexec_handover.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/kexec_handover.c b/kernel/kexec_handover.c
> index ecd1ac210dbd7..69cab82abaaef 100644
> --- a/kernel/kexec_handover.c
> +++ b/kernel/kexec_handover.c
> @@ -183,10 +183,18 @@ static int __kho_preserve_order(struct kho_mem_track *track, unsigned long pfn,
> return 0;
> }
>
> -/* almost as free_reserved_page(), just don't free the page */
> -static void kho_restore_page(struct page *page, unsigned int order)
> +static struct page *kho_restore_page(phys_addr_t phys)
> {
> - unsigned int nr_pages = (1 << order);
> + struct page *page = pfn_to_online_page(PHYS_PFN(phys));
> + unsigned int nr_pages, order;
> +
> + if (!page)
> + return NULL;
> +
> + order = page->private;
> + if (order > MAX_PAGE_ORDER)
> + return NULL;
> + nr_pages = (1 << order);
>
> /* Head page gets refcount of 1. */
> set_page_count(page, 1);
> @@ -199,6 +207,7 @@ static void kho_restore_page(struct page *page, unsigned int order)
> prep_compound_page(page, order);
>
> adjust_managed_page_count(page, nr_pages);
> + return page;
> }
>
> /**
> @@ -209,18 +218,9 @@ static void kho_restore_page(struct page *page, unsigned int order)
> */
> struct folio *kho_restore_folio(phys_addr_t phys)
> {
> - struct page *page = pfn_to_online_page(PHYS_PFN(phys));
> - unsigned long order;
> -
> - if (!page)
> - return NULL;
> -
> - order = page->private;
> - if (order > MAX_PAGE_ORDER)
> - return NULL;
> + struct page *page = kho_restore_page(phys);
>
> - kho_restore_page(page, order);
> - return page_folio(page);
> + return page ? page_folio(page) : NULL;
> }
> EXPORT_SYMBOL_GPL(kho_restore_folio);
>
> --
> 2.47.3
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2025-09-17 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-17 12:56 [PATCH v2 1/2] kho: move sanity checks to kho_restore_page() Pratyush Yadav
2025-09-17 12:56 ` [PATCH v2 2/2] kho: make sure page being restored is actually from KHO Pratyush Yadav
2025-09-17 14:38 ` Mike Rapoport
2025-09-17 14:31 ` Mike Rapoport [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aMrGT9IyHBFe5-nH@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=changyuanl@google.com \
--cc=chrisl@kernel.org \
--cc=graf@amazon.com \
--cc=jasonmiu@google.com \
--cc=jgg@nvidia.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.