-
Notifications
You must be signed in to change notification settings - Fork 20
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
PMM: add simple buddy allocator (splitting and merging frames) #244
Merged
Conversation
This file contains 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
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
The destroy_frame() makes sure to unlink a frame from its list and update frames_count. Then it clears up frame's frame_array entry. Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
It allows to find a frame_t struct pointer for specified MFN and order. Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
The split_frame() breaks given frame into two smaller frames. Original frame's frame_t struct is reused, frame order is decremented and the struct is re-assigned to lower order free frame list. Another, new frame is created for the second half of the original frame. The get_free_frame(), when cannot find free frame of requested order, keeps finding first free higher-order frame and split it, until desired order frame becomes available. Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
The merge_frames() attempts to merge two consecutive frames into a higher order frame. It only merges higher-order aligned frame with its following frame. To do so, it checks if the frame being returned is higher-order aligned frame and attempts to find its following frame. If the frame being returned is not higher-order aligned, it tries to find its preceding frame, which will be properly aligned. When the two frames are found, the first frame's struct is reused, order is incremented and the struct is relinked to higher order free frames list. The second frame struct is destroyed. The merge_frames() calls itself recursively in attempt to merge all merge- able higher-order frames for all orders. The put_free_frames() find corresponding frame struct for given MFN and order. If the frame is fully returned (there is no more references) and relinked from busy_frames to free_frames, it attempts to merge the frame. Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
After creating early frames, the process_memory_range() finds highest available frame order (i.e. frame order whose size fits into available physical memory size). Instead of creating 2M frames by default, it creates frames of the detected order and uses the rest of available space to create 2M frames and 4K frames. Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
bjoernd
approved these changes
Jan 23, 2022
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.
Nothing obviously stands out. Test cases would make me even more confident.
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.
The split_frame() breaks given frame into two smaller frames.
Original frame's frame_t struct is reused, frame order is decremented
and the struct is re-assigned to lower order free frame list.
Another, new frame is created for the second half of the original frame.
The get_free_frame(), when cannot find free frame of requested order,
keeps finding first free higher-order frame and split it, until desired
order frame becomes available.
The merge_frames() attempts to merge two consecutive frames into a higher
order frame. It only merges higher-order aligned frame with its following
frame. To do so, it checks if the frame being returned is higher-order
aligned frame and attempts to find its following frame. If the frame
being returned is not higher-order aligned, it tries to find its preceding
frame, which will be properly aligned.
When the two frames are found, the first frame's struct is reused, order
is incremented and the struct is relinked to higher order free frames list.
The second frame struct is destroyed.
The merge_frames() calls itself recursively in attempt to merge all merge-
able higher-order frames for all orders.
The put_free_frames() find corresponding frame struct for given MFN and
order. If the frame is fully returned (there is no more references) and
relinked from busy_frames to free_frames, it attempts to merge the frame.
After creating early frames, the process_memory_range() finds highest
available frame order (i.e. frame order whose size fits into available
physical memory size).
Instead of creating 2M frames by default, it creates frames of the
detected order and uses the rest of available space to create 2M frames
and 4K frames.
Implements #7.