Skip to content
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

Add Mapper methods to map PageRange to PhysFrameRange #192

Open
chbaker0 opened this issue Oct 15, 2020 · 2 comments · May be fixed by #266
Open

Add Mapper methods to map PageRange to PhysFrameRange #192

chbaker0 opened this issue Oct 15, 2020 · 2 comments · May be fixed by #266

Comments

@chbaker0
Copy link

Hey, first I want to say this crate is great. It removes a lot of pain from starting with OS dev.

I ran into a minor annoyance: mapping a large range of memory is pretty slow. In my code I'm trying to identity map all the machine's physical memory. It takes a few seconds in a release build and quite a bit longer in a debug build. I suspect a lot of this is from traversing the same tables over and over when repeatedly calling map_to.

I think methods for mapping entire ranges could be faster: instead of a loop that traverses down all levels each iteration, there could be loops at each level.

Is this a reasonable request? I'm interested in writing up a PR if it's something you'd accept.

@josephlr
Copy link
Contributor

josephlr commented Oct 16, 2020

This honestly seems quite reasonable (especially if it gives a huge speedup). Algorithmically, I'm not sure about the best way to go about things, but improvements can definitely be made.

My preferred way to do this would be to have a new method: map_range_with_table_flags which has a default implementation based on map_to_with_table_flags, but is overridden by mappers to be more efficient.

Then the following methods can be provided:

  • map_range
  • identity_map_range

EDIT: For a short-term workaround, using larger 2M/1G pages is a way to very quickly identity map the entire space.

@phil-opp
Copy link
Member

My preferred way to do this would be to have a new method: map_range_with_table_flags which has a default implementation based on map_to_with_table_flags, but is overridden by mappers to be more efficient.

Sounds reasonable to me. This method would then behave like the Mapper::map method introduced in #136 and allocate the target frames from the frame allocator, right?

@Freax13 Freax13 linked a pull request Jun 7, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants