Skip to content

Add noreserve parameter to allocate_pages and fix copy_pages chunk length#754

Open
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3d-noreserve
Open

Add noreserve parameter to allocate_pages and fix copy_pages chunk length#754
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3d-noreserve

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 7, 2026

Summary

  • Add noreserve: bool parameter to PageManagementProvider::allocate_pages(). When true, Linux userland uses MAP_NORESERVE for sparse memory reservations. Kernel, LVBS, and Windows platforms accept but ignore it. All current callers pass false (no behavior change).
  • Fix a bug in the default remap_pages() copy loop: to_owned_slice() was using old_range.len() (the entire range) instead of per-chunk length, reading beyond each chunk boundary.

Split from #743.

…ngth

Two changes to page_mgmt:

1. Add a 'noreserve' bool parameter to PageManagementProvider::allocate_pages().
   When true, platforms that support it (Linux userland via MAP_NORESERVE) avoid
   reserving swap/commit upfront, enabling sparse memory reservations. Kernel,
   LVBS, and Windows platforms accept but ignore the parameter. All callers
   currently pass false (no behavior change).

2. Fix a bug in the default remap_pages() copy loop: the to_owned_slice() call
   was using old_range.len() (the entire range length) instead of the per-chunk
   length, causing each iteration to read beyond its chunk boundary.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure trait_method_parameter_count_changed: pub trait method parameter count changed ---

Description:
A trait method now takes a different number of parameters.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-item-signature
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/trait_method_parameter_count_changed.ron

Failed in:
  PageManagementProvider::allocate_pages now takes 6 instead of 5 parameters, in file /home/runner/work/litebox/litebox/litebox/src/platform/page_mgmt.rs:63
  PageManagementProvider::allocate_pages now takes 6 instead of 5 parameters, in file /home/runner/work/litebox/litebox/litebox/src/platform/page_mgmt.rs:63

@jaybosamiya-ms jaybosamiya-ms added the expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment. label Apr 11, 2026
Copy link
Copy Markdown
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description needs to be updated to document what this might be used for.

Is it primarily to provide NORESERVE to a Linux shim? If so, I don't think this PR is a good one to merge. This is because it can cause some programs to seem like they work on Linux platform, and then break when you migrate it to a different platform. If the shim-level NORESERVE is the question, why not just squash it there, and force reservation? Are there actual programs that break if you do it through forced reservation? What is the plan to handle those programs on a Linux-on-Windows or similar scenario?

Also, minor nit: the number of boolean parameters to this particular function has now gone up once more; this means that every callee of it is (yet again) slightly harder to read. Does not need to be fixed in this PR, just making a note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants