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 more states for each node #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lucido-simon
Copy link

Hi !

This PR adds a more granular way to configure node in our allocator state. Instead of having a binary view (Free or Allocated), we know have more state, such as Ram, mmio or ReservedAllocated.

This allows us to use a single allocator to handle all of our memory mapping, hence making sure we don't have conflicts in our memory regions.

I've also added a way to retrieve all the current nodes in our allocator.

Comment on lines +51 to +54
/// RAM
Ram,
/// MMIO
Mmio,
Copy link

Choose a reason for hiding this comment

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

RAM or MMIO should not be states but types. You can have Free + Ram or Allocated + Mmio for a node.

Copy link
Author

Choose a reason for hiding this comment

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

I disagree: a memory range marked as Ram is not free: it is allocated to be used as RAM, hence it is not free to use for anything else. Same thing goes for Mmio. Free means 'this memory range is not mapped to anything'.

ReservedUnallocated means This shall not be mapped to anything, like the upper 20MB of the 32bits address range for example.

The goal of these changes was to be able to specify the usage intended for allocated memory ranges. Instead of having only Allocated, you now have to specify what it is allocated for. This allows us to have different behaviors when actually registering memory with KVM. Memory ranges in the Ram state should be registered with KVM and added to E820, while Mmio and ReservedUnallocated should not, for example.

@@ -44,8 +44,14 @@ pub fn align_up(address: u64, alignment: u64) -> Result<u64> {
pub enum NodeState {
/// Node is free.
Free,
/// Node is allocated.
Allocated,
/// Reserved, and should be allocated (x86's real mode for example).
Copy link

Choose a reason for hiding this comment

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

What does Reserved mean here? How is it different from Allocated?

Also, do you mean can be allocated?

Copy link
Author

Choose a reason for hiding this comment

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

Reserved is close to meaning to allocated, it is more or less a catch-all for all use cases that are not RAM neither MMIO.

I mean KVM should know about this memory region.

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 this pull request may close these issues.

2 participants