tests/mem-claim: System test suite for NUMA-aware claim sets
PATCH 1/1 tests/mem-claim: System test suite for NUMA-aware claim sets
Add a comprehensive test suite for the xc_domain_claim_memory() API and the legacy xc_domain_claim_pages() API for regression testing and confirming interoperability that covers argument validation and the protection semantics of memory claims across domains and NUMA nodes.
The suite verifies claim behaviour both host-wide and per-node, and checks how host-wide and node-specific claims interact with claim and allocation requests for other domains to ensure correct claims protection and claims invariant maintenance across all code paths.
Key checks include:
- Argument validation and correct errno handling for invalid inputs.
- NUMA-aware claim sets, covering node-specific and global targets.
- Replacement semantics after allocations (global and node-scoped).
- Inter-domain protection and claim movement across NUMA nodes.
---
Dear reviewers,
this patch provides the system tests for the NUMA claims series v7:
https://lists.xen.org/archives/html/xen-devel/2026-05/msg00363.html
For reference, find an example of running it on a claims-v7 series Xen hypervisor (on a NUMA host in this case, UMA hosts skip some tests):
$ git pull [email protected]:bernhardkaindl/xen.git claims-system-test-v7 $ make -C tools/tests/mem-claim clean all $ tools/tests/mem-claim/test-claim-memory -h Usage: tools/tests/mem-claim/test-claim-memory [OPTIONS]
Options:
-l, --list List available test IDs and exit -t, --test ID Run only the specified test ID (repeatable) -v, --verbose Print per-step progress -h, --help Show this help text Available tests: A1-1 basic_node_claim A1-2 host_wide_replace_after_alloc A1-3 node_replace_after_alloc A1-4 legacy_host_wide_claim A1-5 move_claim_between_nodes A1-6 zero_claim_resets_claim A1-7 zero_claim_memory_reset A1-8 query_claim_memory_size I1-1 reject_non_present_node I1-2 reject_too_many_claims I1-3 reject_node_gt_uint8_max I1-4 reject_pages_gt_int32_max I1-5 reject_nonzero_pad I1-6 reject_zero_claim_count I1-7 null_claims_nonzero_count I1-8 zero_count_with_pointer I1-9 claim_pages_gt_free_enomem I2-1 claim_pages_causes_enomem I2-2 claim_memory_causes_enomem I2-3 claim_prima_causes_enomem
$ tools/tests/mem-claim/test-claim-memory -v
========= testcase program: tools/tests/mem-claim/test-claim-memory ==========
step 1: create primary domain
step 2: set maxmem for primary domain
step 3: create secondary domain
step 4: set maxmem for secondary domain
step 5: set basic node claim
step 6: check node claim is reflected in outstanding pages
step 7: destroy helper domain
step 8: destroy primary domain
step 9: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-1 PASSED (0.01 ms)
step 10: create primary domain
step 11: set maxmem for primary domain
step 12: create secondary domain
step 13: set maxmem for secondary domain
step 14: install initial host-wide claim
step 15: Allocate one extent to consume part of claim
step 16: reduce host-wide claim after allocation
step 17: release all claims with zero claim
step 18: destroy helper domain
step 19: destroy primary domain
step 20: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-2 PASSED (0.04 ms)
step 21: create primary domain
step 22: set maxmem for primary domain
step 23: create secondary domain
step 24: set maxmem for secondary domain
step 25: set initial node-specific replacement claim
step 26: Allocate one extent to consume part of claim
step 27: replace node claim with a new absolute target
step 28: release all claims with zero claim
step 29: destroy helper domain
step 30: destroy primary domain
step 31: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-3 PASSED (0.02 ms)
step 32: create primary domain
step 33: set maxmem for primary domain
step 34: create secondary domain
step 35: set maxmem for secondary domain
step 36: set legacy host-wide claim
step 37: claim is added the outstanding pages
step 38: allocate extents to redeem a part of claim
step 39: allocated against claim, outstanding pages reduced
step 40: destroy helper domain
step 41: destroy primary domain
step 42: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-4 PASSED (0.03 ms)
step 43: create primary domain
step 44: set maxmem for primary domain
step 45: create secondary domain
step 46: set maxmem for secondary domain
step 47: Claim most memory on source node.
step 48: claim all except 10 pages on node 1
step 49: claim all pages except 10 pages on node 1 claim=23748599 free=23748609 step 50: The claim blocks the allocation on the source node.
step 51: Move the claim to most memory on the destination node.
step 52: claim all except 10 pages on node 0
step 53: claim all pages except 10 pages on node 0 claim=23526547 free=23526557 step 54: Moved claim no longer blocks allocs on source node.
step 55: Moved claim now blocks allocs on destination node.
step 56: release all claims with zero claim
step 57: Claim released, allocs on destination node succeed.
step 58: release all claims with zero claim
step 59: destroy helper domain
step 60: destroy primary domain
step 61: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-5 PASSED (0.15 ms)
step 62: create primary domain
step 63: set maxmem for primary domain
step 64: create secondary domain
step 65: set maxmem for secondary domain
step 66: zero claim to reset outstanding to baseline
step 67: zero claim to reset outstanding to baseline
step 68: check zero claim resets outstanding to baseline
step 69: destroy helper domain
step 70: destroy primary domain
step 71: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-6 PASSED (0.01 ms)
step 72: create primary domain
step 73: set maxmem for primary domain
step 74: create secondary domain
step 75: set maxmem for secondary domain
step 76: make a claim to move outstanding away from baseline
step 77: set a zero claim to reset outstanding to baseline
step 78: check zero claim resets outstanding to baseline
step 79: destroy helper domain
step 80: destroy primary domain
step 81: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-7 PASSED (0.01 ms)
step 82: create primary domain
step 83: set maxmem for primary domain
step 84: create secondary domain
step 85: set maxmem for secondary domain
step 86: Query claim-set size with nr_entries=0 and claim_set=NULL
step 87: Fetch the claim set using the returned entry count
step 88: destroy helper domain
step 89: destroy primary domain
step 90: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::A1-8 PASSED (0.00 ms)
step 91: create primary domain
step 92: set maxmem for primary domain
step 93: create secondary domain
step 94: set maxmem for secondary domain
step 95: reject claim on a non-present NUMA node
step 96: destroy helper domain
step 97: destroy primary domain
step 98: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-1 PASSED (0.00 ms)
step 99: create primary domain
step 100: set maxmem for primary domain
step 101: create secondary domain
step 102: set maxmem for secondary domain
step 103: reject claim list larger than the supported maximum
step 104: destroy helper domain
step 105: destroy primary domain
step 106: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-2 PASSED (0.03 ms)
step 107: create primary domain
step 108: set maxmem for primary domain
step 109: create secondary domain
step 110: set maxmem for secondary domain
step 111: reject claim with node id above UINT8_MAX
step 112: destroy helper domain
step 113: destroy primary domain
step 114: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-3 PASSED (0.00 ms)
step 115: create primary domain
step 116: set maxmem for primary domain
step 117: create secondary domain
step 118: set maxmem for secondary domain
step 119: reject claim with pages larger than INT32_MAX
step 120: destroy helper domain
step 121: destroy primary domain
step 122: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-4 PASSED (0.00 ms)
step 123: create primary domain
step 124: set maxmem for primary domain
step 125: create secondary domain
step 126: set maxmem for secondary domain
step 127: reject claim with non-zero cmd
step 128: destroy helper domain
step 129: destroy primary domain
step 130: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-5 PASSED (0.00 ms)
step 131: create primary domain
step 132: set maxmem for primary domain
step 133: create secondary domain
step 134: set maxmem for secondary domain
step 135: reject xc_domain_claim_memory() with nr_claims == 0
step 136: destroy helper domain
step 137: destroy primary domain
step 138: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-6 [nr_claims=0] PASSED (0.00 ms)
step 139: create primary domain
step 140: set maxmem for primary domain
step 141: create secondary domain
step 142: set maxmem for secondary domain
step 143: reject xc_domain_claim_memory() with claims=NULL and nr_claims == 1 step 144: destroy helper domain
step 145: destroy primary domain
step 146: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-7 [nr_claims=1 claims=NULL] PASSED (0.00 ms)
step 147: create primary domain
step 148: set maxmem for primary domain
step 149: create secondary domain
step 150: set maxmem for secondary domain
step 151: reject xc_domain_claim_memory() with !nr_claims but a claims pointer step 152: destroy helper domain
step 153: destroy primary domain
step 154: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-8 [nr_claims=0 claims=valid node=1] PASSED (0.00 ms)
step 155: create primary domain
step 156: set maxmem for primary domain
step 157: create secondary domain
step 158: set maxmem for secondary domain
step 159: reject xc_domain_claim_pages() with pages > total free pages step 160: reject claim_memory() with pages > total free pages
step 161: reject claim_memory() with pages > node free pages
step 162: destroy helper domain
step 163: destroy primary domain
step 164: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I1-9 [claim=47275120 free=47275119] PASSED (0.01 ms)
step 165: create primary domain
step 166: set maxmem for primary domain
step 167: create secondary domain
step 168: set maxmem for secondary domain
step 169: dom_1: claim nearly all global memory with claim_pages
step 170: expect ENOMEM for xc_domain_claim_pages() with claims > spare page step 171: expect ENOMEM for claim_memory() with claims > spare pages
step 172: expect ENOMEM for claim_memory() with claims > spare pages
step 173: destroy helper domain
step 174: destroy primary domain
step 175: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I2-1 [claim=47274872 free=47275072] PASSED (0.01 ms)
step 176: create primary domain
step 177: set maxmem for primary domain
step 178: create secondary domain
step 179: set maxmem for secondary domain
step 180: claim all except 200 pages on host
step 181: claim all pages except 200 pages on host claim=47274825 free=47275025 step 182: expect ENOMEM for xc_domain_claim_pages() with claims > spare page step 183: expect ENOMEM for claim_memory() with claims > spare pages
step 184: expect ENOMEM for claim_memory() with claims > spare pages
step 185: destroy helper domain
step 186: destroy primary domain
step 187: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I2-2 PASSED (0.01 ms)
step 188: create primary domain
step 189: set maxmem for primary domain
step 190: create secondary domain
step 191: set maxmem for secondary domain
step 192: claim all except 200 pages on node 1
step 193: claim all pages except 200 pages on node 1 claim=23748361 free=23748561 step 194: expect ENOMEM for claim_memory() with claims > spare pages
step 195: destroy helper domain
step 196: destroy primary domain
step 197: check cleanup restored baseline claimed pages
tools/tests/mem-claim/test-claim-memory::I2-3 PASSED (0.01 ms) ================== short test summary info =================
PASSED A1-1 basic_node_claim
PASSED A1-2 host_wide_replace_after_alloc
PASSED A1-3 node_replace_after_alloc
PASSED A1-4 legacy_host_wide_claim
PASSED A1-5 move_claim_between_nodes
PASSED A1-6 zero_claim_resets_claim
PASSED A1-7 zero_claim_memory_reset
PASSED A1-8 query_claim_memory_size
PASSED I1-1 reject_non_present_node
PASSED I1-2 reject_too_many_claims
PASSED I1-3 reject_node_gt_uint8_max
PASSED I1-4 reject_pages_gt_int32_max
PASSED I1-5 reject_nonzero_pad
PASSED I1-6 reject_zero_claim_count
PASSED I1-7 null_claims_nonzero_count
PASSED I1-8 zero_count_with_pointer
PASSED I1-9 claim_pages_gt_free_enomem
PASSED I2-1 claim_pages_causes_enomem
PASSED I2-2 claim_memory_causes_enomem
PASSED I2-3 claim_prima_causes_enomem
============ 20 passed, 0 failed, 0 skipped ============
--- tools/tests/mem-claim/.gitignore | 1 + tools/tests/mem-claim/Makefile | 35 +- tools/tests/mem-claim/accounting-1.h | 456 ++++++++++ tools/tests/mem-claim/input-phase1.h | 173 ++++ tools/tests/mem-claim/input-phase2.h | 96 +++ tools/tests/mem-claim/libtestclaims.c | 980 ++++++++++++++++++++++ tools/tests/mem-claim/libtestclaims.h | 203 +++++ tools/tests/mem-claim/test-claim-memory.c | 130 +++ 8 files changed, 2067 insertions(+), 7 deletions(-) create mode 100644 tools/tests/mem-claim/accounting-1.h create mode 100644 tools/tests/mem-claim/input-phase1.h create mode 100644 tools/tests/mem-claim/input-phase2.h create mode 100644 tools/tests/mem-claim/libtestclaims.c create mode 100644 tools/tests/mem-claim/libtestclaims.h create mode 100644 tools/tests/mem-claim/test-claim-memory.c
tools/tests/mem-claim/.gitignore +1 -0
@@ -1 +1,2 @@ test-mem-claim +test-claim-memory
tools/tests/mem-claim/Makefile +28 -7
@@ -1,14 +1,34 @@ XEN_ROOT = $(CURDIR)/../../.. include $(XEN_ROOT)/tools/Rules.mk -TARGET := test-mem-claim +TARGETS := test-mem-claim test-claim-memory + +LIB_OBJ := libtestclaims.o .PHONY: all -all: $(TARGET) +all: $(TARGETS) + +# Can also be called with "make run-tests-mem-claim" from the toplevel. +.PHONY: run +run: $(TARGETS) +ifeq ($(CC),$(HOSTCC)) + set -e; \ + for test in $? ; do \ + ./$$test ; \ + done +else + $(warning HOSTCC != CC, will not run test) +endif + +# The tests in this directory need to run in a privileged domain (Dom0) +# with libxenctrl and a matching the hypervisor to test running it. +# Therefore, they don't run with the native test target for build-time tests. +.PHONY: test +test: .PHONY: clean clean: - $(RM) -- *.o $(TARGET) $(DEPS_RM) + $(RM) -- *.o $(TARGETS) $(DEPS_RM) .PHONY: distclean distclean: clean
@@ -17,11 +37,11 @@ distclean: clean .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests - $(INSTALL_PROG) $(TARGET) $(DESTDIR)$(LIBEXEC)/tests + $(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(LIBEXEC)/tests .PHONY: uninstall uninstall: - $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$(TARGET) + $(RM) -- $(patsubst %,$(DESTDIR)$(LIBEXEC)/tests/%,$(TARGETS)) CFLAGS += $(CFLAGS_xeninclude) CFLAGS += $(CFLAGS_libxenctrl)
@@ -32,7 +52,8 @@ LDFLAGS += $(APPEND_LDFLAGS) %.o: Makefile -$(TARGET): test-mem-claim.o - $(CC) -o $@ $< $(LDFLAGS) + +$(TARGETS): %: %.o $(LIB_OBJ) + $(CC) -o $@ $^ $(LDFLAGS) -include $(DEPS_INCLUDE)
tools/tests/mem-claim/accounting-1.h new file +456 -0
456 lines not on this page · raw message
tools/tests/mem-claim/input-phase1.h new file +173 -0
173 lines not on this page · raw message
tools/tests/mem-claim/input-phase2.h new file +96 -0
96 lines not on this page · raw message
tools/tests/mem-claim/libtestclaims.c new file +980 -0
980 lines not on this page · raw message
tools/tests/mem-claim/libtestclaims.h new file +203 -0
203 lines not on this page · raw message
tools/tests/mem-claim/test-claim-memory.c new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.39.5