From: Pranjal Shrivastava <praan@google.com>
To: Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>,
Samiullah Khawaja <skhawaja@google.com>,
David Matlack <dmatlack@google.com>,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Pranjal Shrivastava <praan@google.com>
Subject: [RFC PATCH 2/4] kho: Detect preserved page types
Date: Fri, 3 Jul 2026 02:08:30 +0000 [thread overview]
Message-ID: <20260703020832.1731864-3-praan@google.com> (raw)
In-Reply-To: <20260703020832.1731864-1-praan@google.com>
Detect page types in kho_preserve_pages() by peeking into the refcount
of the second page in each block of order > 0. If the second page has
a non-zero reference count, it indicates that the block has been split.
Otherwise, treated it as a contiguous, unsplit block.
Since the page type is now part of the radix tree key, update the
unpreserve path to use the same detection logic to ensure it can
correctly locate and delete existing entries.
Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
kernel/liveupdate/kexec_handover.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index f829ffdd00f4..d6e81f72fe5d 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -918,15 +918,29 @@ static unsigned int __kho_preserve_pages_order(unsigned long start_pfn,
return order;
}
+static bool kho_is_page_split(unsigned long pfn, unsigned int order)
+{
+ /*
+ * If the refcount of the second page is non-zero, this block
+ * has been split.
+ */
+ if (order > 0 && page_ref_count(pfn_to_page(pfn + 1)) != 0)
+ return true;
+
+ return false;
+}
+
static void __kho_unpreserve(struct kho_radix_tree *tree,
unsigned long pfn, unsigned long end_pfn)
{
- unsigned int order;
-
while (pfn < end_pfn) {
- order = __kho_preserve_pages_order(pfn, end_pfn);
+ unsigned int order = __kho_preserve_pages_order(pfn, end_pfn);
+ enum kho_page_type type;
- kho_radix_del_page(tree, pfn, order, KHO_PAGE_CONTIG);
+ type = kho_is_page_split(pfn, order) ? KHO_PAGE_SPLIT :
+ KHO_PAGE_CONTIG;
+
+ kho_radix_del_page(tree, pfn, order, type);
pfn += 1 << order;
}
@@ -958,8 +972,12 @@ int kho_preserve_pages(struct page *page, unsigned long nr_pages)
while (pfn < end_pfn) {
unsigned int order = __kho_preserve_pages_order(pfn, end_pfn);
+ enum kho_page_type type;
+
+ type = kho_is_page_split(pfn, order) ? KHO_PAGE_SPLIT :
+ KHO_PAGE_CONTIG;
- err = kho_radix_add_page(tree, pfn, order, KHO_PAGE_CONTIG);
+ err = kho_radix_add_page(tree, pfn, order, type);
if (err) {
failed_pfn = pfn;
break;
--
2.55.0.rc0.799.gd6f94ed593-goog
next prev parent reply other threads:[~2026-07-03 2:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 2:08 [RFC PATCH 0/4] kho: Support preserving unsplit high-order pages Pranjal Shrivastava
2026-07-03 2:08 ` [RFC PATCH 1/4] kho: Introduce infrastructure to track preserved page types Pranjal Shrivastava
2026-07-03 2:08 ` Pranjal Shrivastava [this message]
2026-07-03 2:08 ` [RFC PATCH 3/4] kho: Implement page-aware refcount restoration Pranjal Shrivastava
2026-07-03 2:08 ` [RFC PATCH 4/4] kho: Introduce kho_split_preserved_pages() helper Pranjal Shrivastava
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=20260703020832.1731864-3-praan@google.com \
--to=praan@google.com \
--cc=dmatlack@google.com \
--cc=graf@amazon.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 \
--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