feat(mm): add slab usage calculation (#768)

* Add slab free space calculation and add it to freeram of sysinfo
This commit is contained in:
laokengwt
2024-04-29 23:03:33 +08:00
committed by GitHub
parent bde4a334c1
commit 7401bec5e3
4 changed files with 82 additions and 12 deletions

View File

@ -1,6 +1,3 @@
//! 当前slab分配器暂时不使用等待后续完善后合并主线
#![allow(dead_code)]
use core::{alloc::Layout, ptr::NonNull, sync::atomic::AtomicBool};
use alloc::boxed::Box;
@ -74,3 +71,11 @@ pub unsafe fn slab_init() {
pub fn slab_init_state() -> bool {
unsafe { *SLABINITSTATE.get_mut() }
}
pub unsafe fn slab_usage() -> SlabUsage {
if let Some(ref mut slab) = SLABALLOCATOR {
slab.zone.usage()
} else {
SlabUsage::new(0, 0)
}
}