-
Notifications
You must be signed in to change notification settings - Fork 25
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 used() API in AddressAllocator #95
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Merge branch 'main' of https://github.com/ylzh10/vm-allocator add `available()` to AddressAllocator Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Create rust.yml Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update CHANGELOG.md Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Delete .github/workflows directory Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update CHANGELOG.md Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> update changelog.md Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> update format Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> update format Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> update changelog.md Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update CHANGELOG.md Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Delete .github/workflows directory Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update address_allocator.rs Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Update CHANGELOG.md Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com> Create rust.yml Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com>
dup of #94 @roypat thanks for reviewing my PR. |
You can have a memory pool from 0 to 12K. You can allocate a block with ExactMatch from 4k to 8k. Now you have 8k of available memory but you can not allocate a 8k blob. I think that in this scenario "available" as it is implemented is misleading.
Maybe you could check that the memory that has been freed is the same as memory that has been allocated. |
yeah, i understand this fragmentation and
the |
Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com>
maybe we can have the inverse of this API instead? Something that returns how many bytes are used from the allocator range? That should cover what you want to do, and be less misleading, API-wise. |
sg, that works too, any API that can expose the available/used memory in the address space/interval tree would be helpful. let me update the code. |
Signed-off-by: ylzh10 <46687083+ylzh10@users.noreply.github.com>
@roypat @AlexandruCihodaru can you help review the changes again and see if you have any further comments? |
Summary: follow wiki (https://www.internalfb.com/wiki/Rust/Third_Party_Libraries/Adding_or_Updating_Libraries/#maintaining-local-change) to patch the pkg w/ my PR. * rust-vmm/vm-allocator#95 * Added a `used()` API in `AddressAllocator` so in runtime we can report DRAM/SRAM usage. NOTE to myself on updating rust 3rd party lib * update https://www.internalfb.com/code/fbsource/[eae01930e4f97fad5f6f03341bbbdc0b62636187]/third-party/rust/Cargo.toml?lines=1483 * `cd ~/fbsource && fbcode/common/rust/tools/reindeer/vendor && arc autocargo` Reviewed By: diliop Differential Revision: D69826054 fbshipit-source-id: c712d57a6e74398b61e8288c6fae5d50954a967f
Summary: follow wiki (https://www.internalfb.com/wiki/Rust/Third_Party_Libraries/Adding_or_Updating_Libraries/#maintaining-local-change) to patch the pkg w/ my PR. * rust-vmm/vm-allocator#95 * Added a `used()` API in `AddressAllocator` so in runtime we can report DRAM/SRAM usage. NOTE to myself on updating rust 3rd party lib * update https://www.internalfb.com/code/fbsource/[eae01930e4f97fad5f6f03341bbbdc0b62636187]/third-party/rust/Cargo.toml?lines=1483 * `cd ~/fbsource && fbcode/common/rust/tools/reindeer/vendor && arc autocargo` Reviewed By: diliop Differential Revision: D69826054 fbshipit-source-id: c712d57a6e74398b61e8288c6fae5d50954a967f
Summary of the PR
bit dumb here, but I thought it should be a common use case to get the available memories in
AddressAllocator
, while i don't see a way on how to get this info today.Or there is already a way to get this info from allocator and somehow i missed it? (please lmk)
So add a new private var
used
allocate/free()
used()
so we can infer how many available memories are left (We don't want to exposeavailable()
directly since it can be confusing/inaccurate due to fragmentations most times)Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s
), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafe
code is properly documented.