mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>
To: Mukesh Pilaniya <mpilaniy@redhat.com>,
	Mike Rapoport <rppt@kernel.org>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	Alexander Graf <graf@amazon.com>,
	Samiullah Khawaja <skhawaja@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: kexec@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kho: fix restore order for NUMA-split preservations
Date: Fri, 6 Nov 2026 10:17:41 +0100	[thread overview]
Message-ID: <9c162e77-df9b-4d91-ac3b-17a3b1a3da8a@gmail.com> (raw)
In-Reply-To: <20261105-kho-numa-v1-1-e807879644cc@redhat.com>

On 11/5/26 2:21 PM, Mukesh Pilaniya wrote:
> kho_preserve_pages() uses __kho_preserve_pages_order() to reduce the
> order of a preservation so that it does not span multiple NUMA nodes.
> kho_restore_pages() does not use that helper; it recomputes the order
> from the pfn alignment and the remaining length only.
> 
> When a preservation was split at a NUMA boundary, restore picks a larger
> order than preserve did and jumps over the next key. Those pages never
> get restored: they stay memblock-reserved and keep the KHOP magic in
> page->private, while kho_restore_pages() returns success for the pages
> that were restored. The consumer has no way to notice that part of its
> buffer was not restored.
> 
> Fix this by reading the order from the key being restored. The order is
> already stored in page->private by kho_preserved_memory_reserve() and is
> validated by kho_restore_page(). Advance by that order instead of
> recomputing it. This also keeps restore independent of the incoming
> kernel's NUMA topology.
> 
> Example: QEMU is started with two NUMA nodes:
> 
>   node0: [0x40000000, 0xC0400000)   2052 MiB
>   node1: [0xC0400000, 0x1C0000000)  4092 MiB
> 
> The module preserves [0xC0000000, 0xC0800000) (8 MiB, 2048 pages). The
> range is 8 MiB aligned and the node boundary sits exactly 4 MiB into it, so
> preserve emits two order-10 keys, the first at 0xC0000000 and the second at
> 0xC0400000. Restore computes order 11 for the first page, restores the
> first key and jumps straight to the end of the range, skipping the second
> key.
> 
> Fixes: 91e74fa8b1bc ("kho: make sure preservations do not span multiple NUMA nodes")
> Signed-off-by: Mukesh Pilaniya <mpilaniy@redhat.com>
> ---
>  kernel/liveupdate/kexec_handover.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> index 6f1f55fe3181..7d30ad9cc512 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c
> @@ -511,7 +511,8 @@ static void kho_init_folio(struct page *page, unsigned int order)
>  		prep_compound_page(page, order);
>  }
>  
> -static struct page *kho_restore_page(phys_addr_t phys, bool is_folio)
> +static struct page *kho_restore_page(phys_addr_t phys, bool is_folio,
> +				     unsigned int *order)
>  {
>  	struct page *page = pfn_to_online_page(PHYS_PFN(phys));
>  	unsigned long nr_pages;
> @@ -530,6 +531,9 @@ static struct page *kho_restore_page(phys_addr_t phys, bool is_folio)
>  		return NULL;
>  	nr_pages = (1 << info.order);
>  
> +	if (order)
> +		*order = info.order;
> +
>  	/* Clear private to make sure later restores on this page error out. */
>  	page->private = 0;
>  
> @@ -550,7 +554,7 @@ static struct page *kho_restore_page(phys_addr_t phys, bool is_folio)
>   */
>  struct folio *kho_restore_folio(phys_addr_t phys)
>  {
> -	struct page *page = kho_restore_page(phys, true);
> +	struct page *page = kho_restore_page(phys, true, NULL);
>  
>  	return page ? page_folio(page) : NULL;
>  }
> @@ -573,13 +577,13 @@ struct page *kho_restore_pages(phys_addr_t phys, unsigned long nr_pages)
>  	unsigned long pfn = start_pfn;
>  
>  	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 order;
> +		struct page *page;
>  
> +		page = kho_restore_page(PFN_PHYS(pfn), false, &order);
>  		if (!page)
>  			return NULL;
> -		pfn += 1 << order;
> +		pfn += 1UL << order;
>  	}
>  
>  	return pfn_to_page(start_pfn);
> 

LGTM:

Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>

-- 
cheers,
jose a. p-a

      reply	other threads:[~2026-11-06  9:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 13:21 Mukesh Pilaniya
2026-11-06  9:17 ` Jose A. Perez de Azpillaga [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=9c162e77-df9b-4d91-ac3b-17a3b1a3da8a@gmail.com \
    --to=azpijr@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=graf@amazon.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mpilaniy@redhat.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=skhawaja@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®