Re: [PATCH v3 2/2] kho: Introduce preserve/restore APIs for high-order pages

From: Mike Rapoport

Date: Thu Jul 30 2026 - 03:53:46 EST


Hi Pranjal,

> The current KHO page preservation APIs (e.g. kho_preserve_pages) assume
> that multi-page blocks are split into independent 4KB pages during
> restoration. This is incompatible with high-order non-compound pages,
> such as DMA buffers, which must be restored with tail pages having a
> zero reference count.
>
> Introduce explicit preserve and restore APIs for high-order pages,
> which preserve and restore a high-order page block as a single unit,
> applying a refcount of 1 to the head page while leaving tail pages at 0.
> Rename the existing internal helper to __kho_restore_page() and
> consolidate the common restoration code into it.
>
> Signed-off-by: Pranjal Shrivastava <praan@xxxxxxxxxx>
>
> @@ -457,10 +482,14 @@ struct page *kho_restore_pages(phys_addr_t phys, unsigned long nr_pages)
> while (pfn < end_pfn) {
> const unsigned int order =
> min(count_trailing_zeros(pfn), ilog2(end_pfn - pfn));
> - struct page *page = kho_restore_page(PFN_PHYS(pfn), false);
> + unsigned int info_order;
> + struct page *page = __kho_restore_page(PFN_PHYS(pfn), &info_order);
>
> if (!page)
> return NULL;
> +
> + kho_init_pages(page, 1UL << info_order);
> + adjust_managed_page_count(page, 1UL << info_order);

Seeing

+ adjust_managed_page_count(page, 1UL << info_order);

for the third time hinted that something is off ;-)

--
Sincerely yours,
Mike.