/// Refill TCache only if the layout will exhaust the cache's current
/// stored memory
///
/// `let (needed_base_pages, needed_large_pages) = KernelAllocator::refill_amount(layout);`
Refill TCache only if the layout will exhaust the cache's current
stored memory


Refill TCache only if the layout will exhaust the cache ' s current stored memory
fn maybe_refill_tcache(
        &self,
        needed_base_pages: usize,
        needed_large_pages: usize,
    ) -> Result<(), KError> {
        let kcb = kcb::try_get_kcb().ok_or(KError::KcbUnavailable)?;
        let mem_manager = kcb.try_mem_manager()?;
        let free_bp = mem_manager.free_base_pages();
        let free_lp = mem_manager.free_large_pages();
        // Dropping things, as they'll get reacquired in try_refill_tcache
        drop(mem_manager);
        if needed_base_pages > free_bp || needed_large_pages > free_lp {
            debug!(
                "Refilling the TCache: needed_bp {} needed_lp {} free_bp {} free_lp {}",
                needed_base_pages, needed_large_pages, free_bp, free_lp
            );
            KernelAllocator::try_refill_tcache(needed_base_pages, needed_large_pages, MemType::Mem)
        } else {
            debug!(
                "Refilling unnecessary: needed_bp {} needed_lp {} free_bp {} free_lp {}",
                needed_base_pages, needed_large_pages, free_bp, free_lp
            );
            Ok(())
        }
    }
fn maybe_refill_tcache ( & self , needed_base_pages : usize , needed_large_pages : usize , ) -> Result < ( ) , KError > { let kcb = kcb :: try_get_kcb ( ) . ok_or ( KError :: KcbUnavailable ) ? ; let mem_manager = kcb . try_mem_manager ( ) ? ; let free_bp = mem_manager . free_base_pages ( ) ; let free_lp = mem_manager . free_large_pages ( ) ; // Dropping things, as they'll get reacquired in try_refill_tcache drop ( mem_manager ) ; if needed_base_pages > free_bp || needed_large_pages > free_lp { debug ! ( " " needed_base_pages needed_large_pages free_bp free_lp ) ; KernelAllocator :: try_refill_tcache ( needed_base_pages , needed_large_pages , MemType :: Mem ) } else { debug ! ( " " needed_base_pages needed_large_pages free_bp free_lp ) ; Ok ( ( ) ) } }
Refill TCache only if the layout will exhaust the cache's current
stored memory
Refill TCache only if the layout will exhaust the cache ' s current stored memory
&self
needed_base_pages
usize
needed_large_pages
usize