fix: handle zero start correctly when splitting frame ranges#47
Merged
jiegec merged 1 commit intorcore-os:masterfrom Mar 26, 2026
Merged
fix: handle zero start correctly when splitting frame ranges#47jiegec merged 1 commit intorcore-os:masterfrom
jiegec merged 1 commit intorcore-os:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes FrameAllocator::add_frame special-casing for ranges starting at 0 so the allocator preserves the largest block size permitted by ORDER, avoiding unnecessary fragmentation at address 0.
Changes:
- Replace the
current_start == 0fallback alignment from hard-coded32to the allocator’s computed maximum block size (1 << (ORDER - 1)). - Add a regression test ensuring
add_frame(0, 64)can allocate a full 64-frame block. - Update large-range allocation tests to reflect the corrected block preservation behavior starting at
0.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/frame.rs |
Adjusts add_frame block sizing/alignment logic for start == 0 to use the allocator’s max block size. |
src/test.rs |
Adds regression coverage for zero-start behavior and updates large-range expectations accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the special-case handling in
FrameAllocator::add_framewhen the range starts at0.Specific changes include:
32fallback used whencurrent_start == 0with the allocator's actual maximum block size.add_frame(0, 64)can now preserve and allocate a full64-frame block.0.Why this is useful:
0by assuming a default alignment of 32.ORDERparameter.Testing:
cargo test.cargo test --doc.Note:
This PR changes the expected allocation order in two existing tests because the corrected behavior now preserves the largest valid block at address
0instead of fragmenting it early.