|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v8 6/8] libxc: add xc_domain_set_memory_claims()
Add xc_domain_set_memory_claims() as the libxc wrapper for
XEN_DOMCTL_set_memory_claims.
Passing NULL for claims and zero for nr_claims releases
all claims without allocating an array buffer.
Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Assisted-by: Vibe:Mistral-Medium-3.5, Copilot:claude-opus-5-5 # review
Assisted-by: Copilot:gpt-6.2-astra, Copilot:gpt-6.2-sol # review
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@xxxxxxxxxx>
---
v8:
- Refactor the submission into smaller topic-focused patches.
- Split the get/set operations into dedicated code paths.
- Rename the operation to XEN_DOMCTL_set_memory_claims.
- Rename the wrapper to xc_domain_set_memory_claims().
- Drop the mode argument. This dedicated set wrapper uses
DECLARE_HYPERCALL_BOUNCE_IN() because the array is input-only.
- Rename the arguments, pass the array before its count, add const
where appropriate, and improve the documentation.
- Add a CHANGELOG.md entry for per-node NUMA memory claims, listing
XEN_DOMCTL_set_memory_claims/xc_domain_set_memory_claims().
---
tools/include/xenctrl.h | 10 ++++++++++
tools/libs/ctrl/xc_domain.c | 24 ++++++++++++++++++++++++
CHANGELOG.md | 4 ++++
3 files changed, 38 insertions(+)
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 6f4ea7ca62..f2ce836c9c 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2670,6 +2670,16 @@ int xc_domain_set_llc_colors(xc_interface *xch, uint32_t
domid,
const uint32_t *llc_colors,
uint32_t num_llc_colors);
+/*
+ * Atomically set a domain's host-wide and per-node memory claims before
+ * its creation finishes. The domain must have no outstanding claims.
+ * Each array entry reserves pages on one NUMA node or host-wide.
+ * Pass NULL for claims and zero for nr_claims to release all claims.
+ */
+int xc_domain_set_memory_claims(xc_interface *xch, uint32_t domid,
+ const xen_domctl_memory_claim_t *claims,
+ uint32_t nr_claims);
+
#if defined(__arm__) || defined(__aarch64__)
int xc_dt_overlay(xc_interface *xch, void *overlay_fdt,
uint32_t overlay_fdt_size, uint8_t overlay_op);
diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c
index 94cfab0fa1..35143d00db 100644
--- a/tools/libs/ctrl/xc_domain.c
+++ b/tools/libs/ctrl/xc_domain.c
@@ -2222,6 +2222,30 @@ out:
return ret;
}
+
+int xc_domain_set_memory_claims(xc_interface *xch, uint32_t domid,
+ const xen_domctl_memory_claim_t *claims,
+ uint32_t nr_claims)
+{
+ struct xen_domctl domctl = {};
+ DECLARE_HYPERCALL_BOUNCE_IN(claims, sizeof(*claims) * nr_claims);
+ int ret;
+
+ if ( xc_hypercall_bounce_pre(xch, claims) )
+ return -1;
+
+ domctl.cmd = XEN_DOMCTL_set_memory_claims;
+ domctl.domain = domid;
+ domctl.u.memory_claims.nr_claims = nr_claims;
+ set_xen_guest_handle(domctl.u.memory_claims.claims, claims);
+
+ ret = do_domctl(xch, &domctl);
+
+ xc_hypercall_bounce_post(xch, claims);
+
+ return ret;
+}
+
/*
* Local variables:
* mode: C
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f967437eda..64c0f87062 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,10 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/)
afterwards.
### Added
+ - Support for per-node NUMA memory claims, so toolstacks can reserve memory
+ on selected NUMA nodes while building a domain:
+ - XEN_DOMCTL_set_memory_claims/xc_domain_set_memory_claims() atomically
+ sets a domain's host-wide claim and per-node claims.
### Removed
- On Arm:
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |