All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: xen-devel@lists.xenproject.org
Cc: Alejandro Vallejo <alejandro.vallejo@cloud.com>,
	Bernhard Kaindl <bernhard.kaindl@cloud.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 09/11] tools/xc: Add `node` argument to xc_domain_claim_pages()
Date: Fri, 14 Mar 2025 17:25:00 +0000	[thread overview]
Message-ID: <20250314172502.53498-10-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20250314172502.53498-1-alejandro.vallejo@cloud.com>

Add a node argument to make an exact-node claim. NUMA_NO_NODE means to
make a regular any-node claim.

No functional change.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
 tools/include/xenctrl.h       |  1 +
 tools/libs/ctrl/xc_domain.c   | 13 ++++++++++++-
 tools/libs/guest/xg_dom_x86.c |  8 +++++---
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 495598123133..2b63992e1246 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -1322,6 +1322,7 @@ int xc_domain_populate_physmap_exact(xc_interface *xch,
 
 int xc_domain_claim_pages(xc_interface *xch,
                                uint32_t domid,
+                               unsigned int node,
                                unsigned long nr_pages);
 
 int xc_domain_memory_exchange_pages(xc_interface *xch,
diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c
index 2ddc3f4f426d..f2c6eda875dc 100644
--- a/tools/libs/ctrl/xc_domain.c
+++ b/tools/libs/ctrl/xc_domain.c
@@ -20,6 +20,7 @@
  */
 
 #include "xc_private.h"
+#include "xenguest.h"
 #include <xen/memory.h>
 #include <xen/hvm/hvm_op.h>
 
@@ -1072,13 +1073,23 @@ int xc_domain_remove_from_physmap(xc_interface *xch,
 
 int xc_domain_claim_pages(xc_interface *xch,
                                uint32_t domid,
+                               unsigned int node,
                                unsigned long nr_pages)
 {
     int err;
+    unsigned int mem_flags = 0;
+
+    if ( node != XC_NUMA_NO_NODE )
+    {
+        if ( node >= 0xFF )
+            return -EINVAL;
+        mem_flags = XENMEMF_exact_node(node);
+    }
+
     struct xen_memory_reservation reservation = {
         .nr_extents   = nr_pages,
         .extent_order = 0,
-        .mem_flags    = 0, /* no flags */
+        .mem_flags    = mem_flags,
         .domid        = domid
     };
 
diff --git a/tools/libs/guest/xg_dom_x86.c b/tools/libs/guest/xg_dom_x86.c
index cba01384ae75..ac05106a8c1c 100644
--- a/tools/libs/guest/xg_dom_x86.c
+++ b/tools/libs/guest/xg_dom_x86.c
@@ -1199,6 +1199,7 @@ static int meminit_pv(struct xc_dom_image *dom)
     if ( dom->claim_enabled )
     {
         rc = xc_domain_claim_pages(dom->xch, dom->guest_domid,
+                                   XC_NUMA_NO_NODE,
                                    dom->total_pages);
         if ( rc )
             return rc;
@@ -1327,7 +1328,8 @@ static int meminit_pv(struct xc_dom_image *dom)
 
     /* Ensure no unclaimed pages are left unused.
      * OK to call if hadn't done the earlier claim call. */
-    xc_domain_claim_pages(dom->xch, dom->guest_domid, 0 /* cancel claim */);
+    xc_domain_claim_pages(dom->xch, dom->guest_domid, XC_NUMA_NO_NODE,
+                          0 /* cancel claim */);
 
     return rc;
 }
@@ -1442,7 +1444,7 @@ static int meminit_hvm(struct xc_dom_image *dom)
      * allocated is pointless.
      */
     if ( claim_enabled ) {
-        rc = xc_domain_claim_pages(xch, domid,
+        rc = xc_domain_claim_pages(xch, domid, XC_NUMA_NO_NODE,
                                    target_pages - dom->vga_hole_size);
         if ( rc != 0 )
         {
@@ -1642,7 +1644,7 @@ static int meminit_hvm(struct xc_dom_image *dom)
  out:
 
     /* ensure no unclaimed pages are left unused */
-    xc_domain_claim_pages(xch, domid, 0 /* cancels the claim */);
+    xc_domain_claim_pages(xch, domid, XC_NUMA_NO_NODE, 0 /* cancel claim */);
 
     return rc;
 }
-- 
2.48.1



  parent reply	other threads:[~2025-03-14 17:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 17:24 [PATCH 00/11] Add support for exact-node memory claims Alejandro Vallejo
2025-03-14 17:24 ` [PATCH 01/11] xen/memory: Mask XENMEMF_node() to 8 bits Alejandro Vallejo
2025-03-17 16:33   ` Jan Beulich
2025-03-18 16:10     ` Alejandro Vallejo
2025-03-14 17:24 ` [PATCH 02/11] xen/page_alloc: Remove `claim` from domain_set_outstanding_pages() Alejandro Vallejo
2025-06-05 16:42   ` Roger Pau Monné
2025-06-10 12:23     ` Jan Beulich
2025-06-10 12:52       ` Roger Pau Monné
2025-06-10 17:51       ` Alejandro Vallejo
2025-06-10 12:37   ` Jan Beulich
2025-03-14 17:24 ` [PATCH 03/11] xen/page_alloc: Add static per-node counts of free pages Alejandro Vallejo
2025-06-05 16:46   ` Roger Pau Monné
2025-06-11 13:35   ` Jan Beulich
2025-03-14 17:24 ` [PATCH 04/11] xen: Add node argument to domain_{adjust_tot_pages,set_outstanding_pages}() Alejandro Vallejo
2025-06-06  7:57   ` Roger Pau Monné
2025-06-11 13:43   ` Jan Beulich
2025-03-14 17:24 ` [PATCH 05/11] xen: Create per-node outstanding claims Alejandro Vallejo
2025-06-06  8:14   ` Roger Pau Monné
2025-06-06  8:36   ` Roger Pau Monné
2025-03-14 17:24 ` [PATCH 06/11] xen/page_alloc: Hook per-node claims to alloc_heap_pages() Alejandro Vallejo
2025-06-06  8:22   ` Roger Pau Monné
2025-03-14 17:24 ` [PATCH 07/11] xen/page_alloc: Set node affinity when claiming pages from an exact node Alejandro Vallejo
2025-06-06  8:34   ` Roger Pau Monné
2025-06-11 13:51   ` Jan Beulich
2025-03-14 17:24 ` [PATCH 08/11] xen/memory: Enable parsing NUMA node argument in XENMEM_claim_pages Alejandro Vallejo
2025-06-06  8:51   ` Roger Pau Monné
2025-03-14 17:25 ` Alejandro Vallejo [this message]
2025-06-06  9:02   ` [PATCH 09/11] tools/xc: Add `node` argument to xc_domain_claim_pages() Roger Pau Monné
2025-03-14 17:25 ` [PATCH 10/11] tools/xl: Expose a "claim_on_node" setting in xl.cfg Alejandro Vallejo
2025-06-06  9:00   ` Roger Pau Monné
2025-03-14 17:25 ` [PATCH 11/11] docs/man: Document the new claim_on_node option Alejandro Vallejo
2025-06-06  9:03   ` Roger Pau Monné

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=20250314172502.53498-10-alejandro.vallejo@cloud.com \
    --to=alejandro.vallejo@cloud.com \
    --cc=anthony.perard@vates.tech \
    --cc=bernhard.kaindl@cloud.com \
    --cc=jgross@suse.com \
    --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.