-
-
Notifications
You must be signed in to change notification settings - Fork 169
UEFI Allocator: add PAGE_SIZE shortcut #1611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The refactoring to a match {} block simplifies the following improvements.
This is a prerequisite for the next commit.
Allocating page-aligned memory via the global allocator is not uncommon for UEFI OS loaders. Therefore, it is feasible to use a shortcut in the allocator, and directly use boot::allocate_pages() rather than boot::allocate_pool(). ## Testing We can look at the TRACE messages of `cargo xtask run` to verify that the shortcut is taken.
We have not been requested yet to do this, but this gives downstream users more flexibility.
`allocator_api` is a `core::alloc` feature, not a feature of the `alloc` crate. This fixes build issues.
aligned_ptr | ||
// Allocating pages is actually very expected in UEFI OS loaders, so | ||
// it makes sense to provide this optimization. | ||
// In Rust, each allocation's size must be at least the alignment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of automatically using allocate_pages
in some cases. Would it make sense to branch on the size rather than just alignment? E.g. if (size % PAGE_SIZE) == 0 && align <= PAGE_SIZE { ... }
? Then there's never a concern about over-allocating memory.
General note: there are a lot of changes going on in this PR. I know it's broken down more clearly by commit, but especially when I'm just "allocating" (😉) 5 or 10 minutes of review time to a PR it helps to have less stuff in each one. E.g. the implementation of |
allocator_api
core
s allocator_api
: add PAGE_SIZE shortcut
core
s allocator_api
: add PAGE_SIZE shortcut
Please review this commit-by-commit.
Steps to Un-Draft
Checklist