-
Notifications
You must be signed in to change notification settings - Fork 25
Provide a specialized interval tree for resource management #3
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
Conversation
Implement a simple interval tree with generic methods insert()/delete() to prepare for resource management.
src/lib.rs
Outdated
|
|
||
| impl Constraint { | ||
| /// Create a new constraint object with default settings. | ||
| pub fn new(size: u64) -> Self { |
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.
It seems this function needs more parameters?
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.
It's used to cover the most common usage scenario. For rare use cases, you may dirrectly construct a Constraint object or we may add some new interfaces for those cases.
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.
So what is the difference between this and ResourceConstraint defined in rust-vmm/vm-device#9 ?
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.
It's two related abstractions. With Device::ResourceConstraint and vm_allocator::Constraint, there's still one piece missing of the whole puzzle. We need the vmm to implement a resource manager, which converts Device::ResourceConstraint to vm_allocator::Constraint.
- vm_allocator is just a generic resource allocator,
- vmm::ResourceManager needs to define type of resources and use vm_allocator to manage its resources.
It's still unclear whether vmm::ResourceManager should be VMM specific or we need another vmm_resource crate.
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.
It's two related abstractions. With Device::ResourceConstraint and vm_allocator::Constraint, there's still one piece missing of the whole puzzle. We need the vmm to implement a resource manager, which converts Device::ResourceConstraint to vm_allocator::Constraint.
Ok, this is the "glue" part between vm-device and vm-allocator.
- vm_allocator is just a generic resource allocator,
- vmm::ResourceManager needs to define type of resources and use vm_allocator to manage its resources.
It's still unclear whether vmm::ResourceManager should be VMM specific or we need another vmm_resource crate.
I think we also need a conversion from the vmm::ResourceManager::allocate_resources() return type to vm_device::Resource for registering devices.
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.
Yes, that's true. Interval tree just manages a set of IDs, the resource manager needs to define the specific resources the ID stands for.
|
Before looking deeper into the actual code, I guess my first general question would be: why couldn't we use one of the existing rust collection structure as the inner struct IntervalTree<T> {
root: BTreeMap<Range, T>>,
} |
IntervalTree supports using |
Add more interval tree helper methods to support resource management. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Introduce struct Constraint to describe resource allocation constraints. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Implement IntervalTree::allocate()/free() to allocate/free resources. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Add several methods to get mutable reference to data in the interval tree. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
|
Closing this as it is obsolete. |
This PR implements a specialized version of interval tree for resource management, which could be used manage normal VMM resources.