/// Try to refill our core-local tcache.
Try to refill our core-local tcache.
Try to refill our core - local tcache .
pub fn try_refill_tcache(
        needed_base_pages: usize,
        needed_large_pages: usize,
        mem_type: MemType,
    ) -> Result<(), KError> {
        let kcb = kcb::try_get_kcb().ok_or(KError::KcbUnavailable)?;
        if mem_type == MemType::Mem && kcb.physical_memory.gmanager.is_none() {
            // No gmanager, can't refill then, let's hope it works anyways...
            return Ok(());
        }
        if mem_type == MemType::PMem && kcb.pmem_memory.gmanager.is_none() {
            // No gmanager, can't refill then, let's hope it works anyways...
            return Ok(());
        }
        let (gmanager, mut mem_manager, affinity) = match mem_type {
            MemType::Mem => (
                kcb.physical_memory.gmanager.unwrap(),
                kcb.try_mem_manager()?,
                kcb.physical_memory.affinity as usize,
            ),
            MemType::PMem => (
                kcb.pmem_memory.gmanager.unwrap(),
                kcb.pmem_manager(),
                kcb.pmem_memory.affinity as usize,
            ),
            _ => unreachable!(),
        };
        let mut ncache = gmanager.node_caches[affinity].lock();
        // Make sure we don't overflow the TCache
        let needed_base_pages =
            core::cmp::min(mem_manager.spare_base_page_capacity(), needed_base_pages);
        let needed_large_pages =
            core::cmp::min(mem_manager.spare_large_page_capacity(), needed_large_pages);
        for _i in 0..needed_base_pages {
            let frame = ncache.allocate_base_page()?;
            mem_manager
                .grow_base_pages(&[frame])
                .expect("We ensure to not overfill the TCache above.");
        }
        for _i in 0..needed_large_pages {
            let frame = ncache.allocate_large_page()?;
            mem_manager
                .grow_large_pages(&[frame])
                .expect("We ensure to not overfill the TCache above.");
        }
        Ok(())
    }
pub fn try_refill_tcache ( needed_base_pages : usize , needed_large_pages : usize , mem_type : MemType , ) -> Result < ( ) , KError > { let kcb = kcb :: try_get_kcb ( ) . ok_or ( KError :: KcbUnavailable ) ? ; if mem_type == MemType :: Mem && kcb . physical_memory . gmanager . is_none ( ) { // No gmanager, can't refill then, let's hope it works anyways... return Ok ( ( ) ) ; } if mem_type == MemType :: PMem && kcb . pmem_memory . gmanager . is_none ( ) { // No gmanager, can't refill then, let's hope it works anyways... return Ok ( ( ) ) ; } let ( gmanager , mut mem_manager , affinity ) = match mem_type { MemType :: Mem => ( kcb . physical_memory . gmanager . unwrap ( ) , kcb . try_mem_manager ( ) ? , kcb . physical_memory . affinity as usize , ) , MemType :: PMem => ( kcb . pmem_memory . gmanager . unwrap ( ) , kcb . pmem_manager ( ) , kcb . pmem_memory . affinity as usize , ) , _ => unreachable ! ( ) , } ; let mut ncache = gmanager . node_caches [ affinity ] . lock ( ) ; // Make sure we don't overflow the TCache let needed_base_pages = core :: cmp :: min ( mem_manager . spare_base_page_capacity ( ) , needed_base_pages ) ; let needed_large_pages = core :: cmp :: min ( mem_manager . spare_large_page_capacity ( ) , needed_large_pages ) ; for _i in 0 .. needed_base_pages { let frame = ncache . allocate_base_page ( ) ? ; mem_manager . grow_base_pages ( & [ frame ] ) . expect ( " " ) ; } for _i in 0 .. needed_large_pages { let frame = ncache . allocate_large_page ( ) ? ; mem_manager . grow_large_pages ( & [ frame ] ) . expect ( " " ) ; } Ok ( ( ) ) }
Try to refill our core-local tcache.
Try to refill our core - local tcache .
needed_base_pages
usize
needed_large_pages
usize
mem_type
MemType