/// Create dispatchers for a given Pid to run on all cores.
///
/// Also make sure they are all using NUMA local memory
Create dispatchers for a given Pid to run on all cores.
Also make sure they are all using NUMA local memory
Create dispatchers for a given Pid to run on all cores . Also make sure they are all using NUMA local memory
pub fn allocate_dispatchers<P: Process>(pid: Pid) -> Result<(), KError> {
    trace!("Allocate dispatchers");
    let mut create_per_region: ArrayVec<(atopology::NodeId, usize), MAX_NUMA_NODES> =
        ArrayVec::new();
    if atopology::MACHINE_TOPOLOGY.num_nodes() > 0 {
        for node in atopology::MACHINE_TOPOLOGY.nodes() {
            let threads = node.threads().count();
            debug_assert!(!create_per_region.is_full(), "Ensured by for loop range");
            create_per_region.push((node.id, threads));
        }
    } else {
        debug_assert!(!create_per_region.is_full(), "ensured MAX_NUMA_NODES >= 1");
        create_per_region.push((0, atopology::MACHINE_TOPOLOGY.num_threads()));
    }
    for (affinity, to_create) in create_per_region {
        let mut dispatchers_created = 0;
        while dispatchers_created < to_create {
            KernelAllocator::try_refill_tcache(20, 1, MemType::Mem)?;
            let mut frame = {
                let kcb = crate::kcb::get_kcb();
                kcb.physical_memory.gmanager.unwrap().node_caches[affinity as usize]
                    .lock()
                    .allocate_large_page()?
            };
            unsafe {
                frame.zero();
            }
            match nrproc::NrProcess::<P>::allocate_dispatchers(pid, frame) {
                Ok(count) => {
                    dispatchers_created += count;
                }
                _ => unreachable!("Got unexpected response"),
            }
        }
    }
    debug!("Allocated dispatchers");
    Ok(())
}
pub fn allocate_dispatchers < P : Process > ( pid : Pid ) -> Result < ( ) , KError > { trace ! ( " " ) ; let mut create_per_region : ArrayVec < ( atopology :: NodeId , usize ) , MAX_NUMA_NODES > = ArrayVec :: new ( ) ; if atopology :: MACHINE_TOPOLOGY . num_nodes ( ) > 0 { for node in atopology :: MACHINE_TOPOLOGY . nodes ( ) { let threads = node . threads ( ) . count ( ) ; debug_assert ! ( create_per_region is_full ( ) " " ) ; create_per_region . push ( ( node . id , threads ) ) ; } } else { debug_assert ! ( create_per_region is_full ( ) " " ) ; create_per_region . push ( ( 0 , atopology :: MACHINE_TOPOLOGY . num_threads ( ) ) ) ; } for ( affinity , to_create ) in create_per_region { let mut dispatchers_created = 0 ; while dispatchers_created < to_create { KernelAllocator :: try_refill_tcache ( 20 , 1 , MemType :: Mem ) ? ; let mut frame = { let kcb = crate :: kcb :: get_kcb ( ) ; kcb . physical_memory . gmanager . unwrap ( ) . node_caches [ affinity as usize ] . lock ( ) . allocate_large_page ( ) ? } ; unsafe { frame . zero ( ) ; } match nrproc :: NrProcess :: < P > :: allocate_dispatchers ( pid , frame ) { Ok ( count ) => { dispatchers_created += count ; } _ => unreachable ! ( " " ) , } } } debug ! ( " " ) ; Ok ( ( ) ) }
Create dispatchers for a given Pid to run on all cores.
Create dispatchers for a given Pid to run on all cores .
pid
Pid