From: Bernhard Kaindl <bernhard.kaindl@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: "Bernhard Kaindl" <bernhard.kaindl@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH 0/2] xen/mm: Fix off-by-one for tail merge in reserve_offlined_page()
Date: Thu, 28 May 2026 15:55:53 +0100 [thread overview]
Message-ID: <cover.1779980089.git.bernhard.kaindl@citrix.com> (raw)
After offlining pages, reserve_offlined_page() returns healthy
spans of pages from the buddy it isolated the offlined pages
back to the free lists.
Naturally, it attempts to grow larger buddies, but due to an
off-by-one, this fails at the tail end of the span of pages.
Patch 1 adds a native regression test that reproduces the problem.
Patch 2 fixes the off-by-one error and updates the regression test.
Consider an order-2 buddy (4 pages) with the following layout:
+---------------+---------------+---------------+---------------+
| head page tail page 1, tail page 2 tail page 3 |
| PFN_ORDER(pg) marked as to |
| == 2 be offlined |
+---------------+---------------+---------------+---------------+
The expected result after removing tail page 1 and returning the
remaining healthy pages to the free list would be:
+---------------+ +---------------+---------------+
| single page | offlined page | head page tail page |
| PFN_ORDER(pg) | not returned | PFN_ORDER(pg) |
| == 0 | to the heap | == 1 |
+---------------+ +---------------+---------------+
A trivial off-by-one error in the growth loop stops the growth loop
early before the tail end of the original buddy and we end up with:
+---------------+ +---------------+---------------+
| single page | offlined page | single page | single page |
| PFN_ORDER(pg) | not returned | PFN_ORDER(pg) | PFN_ORDER(pg) |
| == 0 | to the heap | == 0 | == 0 |
+---------------+ +---------------+---------------+
This series is based on the native test environment v3 for NUMA claims
https://lists.xen.org/archives/html/xen-devel/2026-05/msg01163.html
In turn, it is based on the NUMA claim sets v7 series:
https://lists.xen.org/archives/html/xen-devel/2026-05/msg00363.html
You can pull this series with all dependencies for review and test:
$ git pull git@gitlab.com:bernhardkaindl/xen.git offline-merge-tail-v1
$ make -C tools/tests/native TARGETS=offline-merge-tail test
Fixes: e4865c2315 ('Page offline support in Xen side')
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@citrix.com>
Bernhard Kaindl (2):
tools/tests/native: Test merging the tail after an offlined page
xen/mm: Fix off-by-one stopping tail merge in reserve_offlined_page
tools/tests/native/offline-merge-tail.c | 87 +++++++++++++++++++++++++
xen/common/page_alloc.c | 4 +-
2 files changed, 90 insertions(+), 1 deletion(-)
create mode 100644 tools/tests/native/offline-merge-tail.c
--
2.39.5
next reply other threads:[~2026-05-28 14:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 14:55 Bernhard Kaindl [this message]
2026-05-28 14:55 ` [PATCH 1/2] tools/tests/native: Test merging the tail after an offlined page Bernhard Kaindl
2026-05-28 14:55 ` [PATCH 2/2] xen/mm: Fix off-by-one stopping tail merge in reserve_offlined_page Bernhard Kaindl
2026-06-02 14:43 ` Jan Beulich
2026-06-03 14:25 ` Bernhard Kaindl
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=cover.1779980089.git.bernhard.kaindl@citrix.com \
--to=bernhard.kaindl@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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.