Skip to content

xen: Add NUMA-aware memory claims for domains

Bernhard Kaindl xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest10 patches 24 repliesIn review

Changes in v4 from the cover letter

- The logic for adjusting claimed pages on allocation has been completely reworked to align with recent upstream changes. (Roger Pau Monné)

- The check for node memory availability has been replaced with a corrected implementation. (Marcus Granado, Roger Pau Monné, Bernhard Kaindl)

- The new hypercall API patch has been refactored and split into separate patches for the DOMCTL, Flask policy, and libxenctrl implementation.

- Added initial tests and Sphinx documentation for the new API.

- With improvements and rebasing on upstream changes, this series has changed very much. Reviewing it as a whole is recommended over an incremental review.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10xen/page_alloc: Extract code for consuming claims into inline functionxen/common/page_alloc.c+31 -253 replies
2/10xen/page_alloc: Optimize getting per-NUMA-node free page countsxen/common/page_alloc.c+31 -53 replies
3/10xen/page_alloc: Implement NUMA-node-specific claimsxen/common/domain.c xen/common/memory.c xen/common/page_alloc.c +2 more+140 -185 replies
4/10xen/page_alloc: Consolidate per-node counters into avail[] arrayxen/common/page_alloc.c+21 -120 replies
5/10xen/domain: Add DOMCTL handler for claiming memory with NUMA awarenessxen/common/domain.c xen/common/domctl.c xen/include/public/domctl.h +1 more+78 -010 replies
6/10xsm/flask: Add XEN_DOMCTL_claim_memory to flasktools/flask/policy/modules/dom0.te tools/flask/policy/modules/xen.if xen/xsm/flask/hooks.c +1 more+7 -01 reply
7/10tools/lib/ctrl/xc: Add xc_domain_claim_memory() to libxenctrltools/include/xenctrl.h tools/libs/ctrl/xc_domain.c+31 -00 replies
8/10tools/ocaml/libs/xc: add OCaml domain_claim_memory bindingtools/ocaml/libs/xc/xenctrl.ml tools/ocaml/libs/xc/xenctrl.mli tools/ocaml/libs/xc/xenctrl_stubs.c+65 -00 replies
9/10tools/tests: Update the claims test to test claim_memory hypercalltools/tests/mem-claim/test-mem-claim.c+254 -230 replies
10/10docs/guest-guide: document the memory claim hypercalls.readthedocs.yaml docs/conf.py docs/guest-guide/dom/DOMCTL_claim_memory-classes.mmd +10 more+485 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/10] xen: Add NUMA-aware memory claims for domains

This series introduces NUMA-aware memory claims. Xen allocates the claimed memory only for allocations from domains with a claim for this memory.

The new hypercall API is designed to support staking claims on multiple NUMA nodes for a domain. It provides a foundation that can be extended to support multi-node claims without changing the hypercall API.

Patch Structure:

 1. xen/page_alloc:  Extract claim consumption on allocation into static inline
 2. xen/page_alloc:  Add per-node free page counts; make counters unsigned long
 3. xen/page_alloc:  Add the implementation of NUMA-node-specific claims
 4. xen/page_alloc:  Consolidate per-node counters into avail[node][maxzone+x]
                     Is optional: transparent, no functional change, not needed
 5. xen/domain:      Add the XEN_DOMCTL_claim_memory hypercall handler
 6. xsm/flask:       Add a Flask security policy for the new hypercall
 7. libs/ctrl/xc:    Add the libxenctrl API xc_domain_claim_memory()
 8. ocaml/libx/xc:   Add the OCaml binding for xc_domain_claim_memory()
 9. tools/tests:     Add testing per-node claims and claims protection

10. doc/guest-guide: Add comprehensive API documentation

The updated guest-guide is deployed here for reviewing the created output:
https://bernhardk-xen-review.readthedocs.io/v4.22-claims.v4/guest-guide/

Changes in v4:

- The logic for adjusting claimed pages on allocation has been completely reworked to align with recent upstream changes. (Roger Pau Monné)

- The check for node memory availability has been replaced with a corrected implementation. (Marcus Granado, Roger Pau Monné, Bernhard Kaindl)

- The new hypercall API patch has been refactored and split into separate patches for the DOMCTL, Flask policy, and libxenctrl implementation.

- Added initial tests and Sphinx documentation for the new API.

- With improvements and rebasing on upstream changes, this series has changed very much. Reviewing it as a whole is recommended over an incremental review.

Credits:

- Alejandro Vallejo developed the initial version
- Roger Pau Monné updated the implementation and upstreamed key improvements
- Marcus Granado contributed analysis and suggestions during development
- Bernhard Kaindl developed the new domctl API, extended tests and documentation and developed the refactored handler for consuming claims on allocation.

Comments and feedback welcome.

Bernhard Kaindl (10):
xen/page_alloc: Extract code for consuming claims into inline function xen/page_alloc: Optimize getting per-NUMA-node free page counts xen/page_alloc: Implement NUMA-node-specific claims xen/page_alloc: Consolidate per-node counters into avail[] array xen/domain: Add DOMCTL handler for claiming memory with NUMA awareness xsm/flask: Add XEN_DOMCTL_claim_memory to flask tools/lib/ctrl/xc: Add xc_domain_claim_memory() to libxenctrl tools/ocaml/libs/xc: add OCaml domain_claim_memory binding tools/tests: Update the claims test to test claim_memory hypercall docs/guest-guide: document the memory claim hypercalls

 .readthedocs.yaml                             |  13 +-
 docs/conf.py                                  |   6 +-
 .../dom/DOMCTL_claim_memory-classes.mmd       |  51 ++++
 .../dom/DOMCTL_claim_memory-seqdia.mmd        |  23 ++
 .../dom/DOMCTL_claim_memory-workflow.mmd      |  23 ++
 docs/guest-guide/dom/DOMCTL_claim_memory.rst  | 125 ++++++++
 docs/guest-guide/dom/index.rst                |  14 +
 docs/guest-guide/index.rst                    |  23 ++
 docs/guest-guide/mem/XENMEM_claim_pages.rst   |  68 +++++
 docs/guest-guide/mem/index.rst                |  12 +
 docs/hypervisor-guide/index.rst               |   5 +
 docs/hypervisor-guide/mm/claims.rst           | 114 +++++++
 docs/hypervisor-guide/mm/index.rst            |  10 +
 tools/flask/policy/modules/dom0.te            |   1 +
 tools/flask/policy/modules/xen.if             |   1 +
 tools/include/xenctrl.h                       |   4 +
 tools/libs/ctrl/xc_domain.c                   |  27 ++
 tools/ocaml/libs/xc/xenctrl.ml                |  11 +
 tools/ocaml/libs/xc/xenctrl.mli               |  11 +
 tools/ocaml/libs/xc/xenctrl_stubs.c           |  43 +++
 tools/tests/mem-claim/test-mem-claim.c        | 277 ++++++++++++++++--
 xen/common/domain.c                           |  32 +-
 xen/common/domctl.c                           |   9 +
 xen/common/memory.c                           |   3 +-
 xen/common/page_alloc.c                       | 254 +++++++++++++---
 xen/include/public/domctl.h                   |  38 +++
 xen/include/xen/domain.h                      |   2 +
 xen/include/xen/mm.h                          |   4 +-
 xen/include/xen/sched.h                       |   1 +
 xen/xsm/flask/hooks.c                         |   3 +
 xen/xsm/flask/policy/access_vectors           |   2 +
 31 files changed, 1134 insertions(+), 76 deletions(-)
 create mode 100644 docs/guest-guide/dom/DOMCTL_claim_memory-classes.mmd
 create mode 100644 docs/guest-guide/dom/DOMCTL_claim_memory-seqdia.mmd
 create mode 100644 docs/guest-guide/dom/DOMCTL_claim_memory-workflow.mmd
 create mode 100644 docs/guest-guide/dom/DOMCTL_claim_memory.rst
 create mode 100644 docs/guest-guide/dom/index.rst
 create mode 100644 docs/guest-guide/mem/XENMEM_claim_pages.rst
 create mode 100644 docs/guest-guide/mem/index.rst
 create mode 100644 docs/hypervisor-guide/mm/claims.rst
 create mode 100644 docs/hypervisor-guide/mm/index.rst
Signature · 1 line
2.39.5