All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"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>,
	"Oleksii Kurochko" <oleksii.kurochko@gmail.com>
Subject: [PATCH 1/2] tests/paging-mempool: Misc cleanup
Date: Tue, 12 May 2026 16:55:39 +0100	[thread overview]
Message-ID: <20260512155540.1733403-2-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20260512155540.1733403-1-andrew.cooper3@citrix.com>

... ahead of extending it with a second test.

Rename run_tests() to test_paging_mempool_size() and have it return int so the
newly wrapping run_tests() can decide whether to run the next or not.

Comment the parameters to xc_domain_populate_physmap_exact() to make it
clearer what's going on, and remove the page added to the physmap when the
test is done.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 .../paging-mempool/test-paging-mempool.c      | 25 ++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/tools/tests/paging-mempool/test-paging-mempool.c b/tools/tests/paging-mempool/test-paging-mempool.c
index 1ebc13455ac2..d1207d26d3fc 100644
--- a/tools/tests/paging-mempool/test-paging-mempool.c
+++ b/tools/tests/paging-mempool/test-paging-mempool.c
@@ -15,6 +15,7 @@ static unsigned int nr_failures;
 ({                                              \
     nr_failures++;                              \
     (void)printf(fmt, ##__VA_ARGS__);           \
+    -1;                                         \
 })
 
 static xc_interface *xch;
@@ -40,7 +41,7 @@ static uint64_t default_mempool_size_bytes =
     16 << 12;
 #endif
 
-static void run_tests(void)
+static int test_paging_mempool_size(void)
 {
     xen_pfn_t physmap[] = { 0 };
     uint64_t size_bytes, old_size_bytes;
@@ -80,7 +81,8 @@ static void run_tests(void)
         return fail("  Fail: setmaxmem: : %d - %s\n",
                     errno, strerror(errno));
 
-    rc = xc_domain_populate_physmap_exact(xch, domid, 1, 0, 0, physmap);
+    rc = xc_domain_populate_physmap_exact(xch, domid, ARRAY_SIZE(physmap),
+                                          0 /* order 4k */, 0 /* flags */, physmap);
     if ( rc )
         return fail("  Fail: populate physmap: %d - %s\n",
                     errno, strerror(errno));
@@ -98,6 +100,11 @@ static void run_tests(void)
         return fail("  Fail: mempool size changed %"PRIu64" => %"PRIu64"\n",
                     old_size_bytes, size_bytes);
 
+    /* We added one 4k page.  Check we can remove it. */
+    rc = xc_domain_remove_from_physmap(xch, domid, physmap[0]);
+    if ( rc )
+        return fail("  Fail: remove from physmap: %d - %s\n",
+                    errno, strerror(errno));
 
 
     printf("Test bad set size\n");
@@ -134,6 +141,19 @@ static void run_tests(void)
     if ( size_bytes != 64 << 20 )
         return fail("  Fail: expected mempool size %u, got %"PRIu64"\n",
                     64 << 20, size_bytes);
+
+    return 0;
+}
+
+static int run_tests(void)
+{
+    int rc;
+
+    rc = test_paging_mempool_size();
+    if ( rc )
+        return rc;
+
+    return 0;
 }
 
 int main(int argc, char **argv)
@@ -143,7 +163,6 @@ int main(int argc, char **argv)
     printf("Paging mempool tests\n");
 
     xch = xc_interface_open(NULL, NULL, 0);
-
     if ( !xch )
         err(1, "xc_interface_open");
 
-- 
2.39.5



  reply	other threads:[~2026-05-12 15:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 15:55 [PATCH 0/2] tests/paging-mempool: Testing for P2M relocation Andrew Cooper
2026-05-12 15:55 ` Andrew Cooper [this message]
2026-05-12 15:55 ` [PATCH 2/2] tests/paging-mempool: Extend to test " Andrew Cooper
2026-05-13  8:06 ` [PATCH 0/2] tests/paging-mempool: Testing for " Jan Beulich
2026-05-14  7:23 ` Oleksii Kurochko

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=20260512155540.1733403-2-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=oleksii.kurochko@gmail.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.