Skip to content

Commit

Permalink
reduce number of arcs
Browse files Browse the repository at this point in the history
  • Loading branch information
hunhoffe committed Jul 23, 2023
1 parent a1d559e commit 50550f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
17 changes: 7 additions & 10 deletions kernel/src/arch/x86_64/rackscale/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ pub(crate) struct ClientState {
pub(crate) rpc_client: Arc<Mutex<Client>>,

/// Used to store shmem affinity base pages
pub(crate) affinity_base_pages: ArrayVec<Arc<Mutex<Box<dyn MemManager + Send>>>, MAX_MACHINES>,
pub(crate) affinity_base_pages: Arc<ArrayVec<Mutex<Box<dyn MemManager + Send>>, MAX_MACHINES>>,

/// Used to store base pages allocated to a process
pub(crate) per_process_base_pages: ArrayVec<Arc<Mutex<FrameCacheBase>>, MAX_PROCESSES>,
pub(crate) per_process_base_pages: Arc<ArrayVec<Mutex<FrameCacheBase>, MAX_PROCESSES>>,
}

impl ClientState {
Expand Down Expand Up @@ -64,24 +64,21 @@ impl ClientState {
let mut per_process_base_pages = ArrayVec::new();
for _i in 0..MAX_PROCESSES {
// TODO(rackscale): this is a bogus affinity because it should really be "ANY_SHMEM"
per_process_base_pages.push(Arc::new(Mutex::new(FrameCacheBase::new(
local_shmem_affinity(),
))));
per_process_base_pages.push(Mutex::new(FrameCacheBase::new(local_shmem_affinity())));
}

let mut affinity_base_pages = ArrayVec::new();
for i in 0..MAX_MACHINES {
affinity_base_pages.push(Arc::new(Mutex::new(Box::new(FrameCacheBase::new(
affinity_base_pages.push(Mutex::new(Box::new(FrameCacheBase::new(
mid_to_shmem_affinity(i),
))
as Box<dyn MemManager + Send>)));
)) as Box<dyn MemManager + Send>));
}

log::debug!("Finished initializing client state");
ClientState {
rpc_client,
affinity_base_pages,
per_process_base_pages,
affinity_base_pages: Arc::new(affinity_base_pages),
per_process_base_pages: Arc::new(per_process_base_pages),
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions kernel/src/arch/x86_64/rackscale/controller_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@ use crate::transport::shmem::get_affinity_shmem;
/// Caches of memory for use by the controller. The controller cache includes all shmem belonging to the controller,
/// because DCM does not allocate controller shmem.
lazy_static! {
pub(crate) static ref CONTROLLER_SHMEM_CACHES: ArrayVec<Arc<Mutex<Box<dyn MemManager + Send>>>, MAX_MACHINES> = {
pub(crate) static ref CONTROLLER_SHMEM_CACHES: Arc<ArrayVec<Mutex<Box<dyn MemManager + Send>>, MAX_MACHINES>> = {
let mut shmem_caches = ArrayVec::new();
// TODO(rackscale): think about how we should constrain the mcache?
shmem_caches.push(Arc::new(Mutex::new(Box::new(MCache::<2048, 2048>::new_with_frame::<2048, 2048>(
shmem_caches.push(Mutex::new(Box::new(MCache::<2048, 2048>::new_with_frame::<2048, 2048>(
local_shmem_affinity(),
get_affinity_shmem(),
)) as Box<dyn MemManager + Send>)));
)) as Box<dyn MemManager + Send>));
for i in 1..MAX_MACHINES {
shmem_caches.push(Arc::new(Mutex::new(Box::new(FrameCacheBase::new(mid_to_shmem_affinity(i)))
as Box<dyn MemManager + Send>)));
shmem_caches.push(Mutex::new(Box::new(FrameCacheBase::new(mid_to_shmem_affinity(i)))
as Box<dyn MemManager + Send>));
}

shmem_caches
Arc::new(shmem_caches)
};
}

/// Caches of memslices allocated by the DCM scheduler
lazy_static! {
pub(crate) static ref SHMEM_MEMSLICE_ALLOCATORS: ArrayVec<Arc<Mutex<MCache<0, 2048>>>, MAX_MACHINES> = {
pub(crate) static ref SHMEM_MEMSLICE_ALLOCATORS: Arc<ArrayVec<Mutex<MCache<0, 2048>>, MAX_MACHINES>> = {
// TODO(rackscale): think about how we should constrain the mcache?
let mut shmem_allocators = ArrayVec::new();
for i in 1..(MAX_MACHINES + 1) {
shmem_allocators.push(Arc::new(Mutex::new(MCache::<0, 2048>::new(mid_to_shmem_affinity(i)))));
shmem_allocators.push(Mutex::new(MCache::<0, 2048>::new(mid_to_shmem_affinity(i))));
}
shmem_allocators
Arc::new(shmem_allocators)
};
}

Expand Down Expand Up @@ -96,9 +96,9 @@ pub(crate) struct ControllerState {
/// A composite list of all hardware threads
hw_threads_all: Arc<Mutex<ArrayVec<CpuThread, { MAX_MACHINES * MAX_CORES }>>>,
/// Bit maps to keep track of free/busy hw threads. Index is machine_id - 1
thread_maps: ArrayVec<Arc<Mutex<ThreadMap>>, MAX_MACHINES>,
thread_maps: Arc<ArrayVec<Mutex<ThreadMap>, MAX_MACHINES>>,
/// The NodeId of each thread, organized by client. Index is machine_id - 1
affinities_per_client: ArrayVec<Arc<Mutex<ArrayVec<NodeId, MAX_CORES>>>, MAX_MACHINES>,
affinities_per_client: Arc<ArrayVec<Mutex<ArrayVec<NodeId, MAX_CORES>>, MAX_MACHINES>>,
}

impl ControllerState {
Expand Down Expand Up @@ -145,13 +145,13 @@ lazy_static! {
let mut affinities_per_client = ArrayVec::new();
let mut thread_maps = ArrayVec::new();
for i in 0..MAX_MACHINES {
affinities_per_client.push(Arc::new(Mutex::new(ArrayVec::new())));
thread_maps.push(Arc::new(Mutex::new(ThreadMap::new())));
affinities_per_client.push(Mutex::new(ArrayVec::new()));
thread_maps.push(Mutex::new(ThreadMap::new()));
}
ControllerState {
hw_threads_all: Arc::new(Mutex::new(ArrayVec::new())),
thread_maps,
affinities_per_client,
thread_maps: Arc::new(thread_maps),
affinities_per_client: Arc::new(affinities_per_client),
}
};
}

0 comments on commit 50550f7

Please sign in to comment.