From 50550f704b03f3a8e26992b11586f96963de957d Mon Sep 17 00:00:00 2001 From: Erika Hunhoff Date: Sun, 23 Jul 2023 16:19:28 -0700 Subject: [PATCH] reduce number of arcs --- .../src/arch/x86_64/rackscale/client_state.rs | 17 +++++------ .../arch/x86_64/rackscale/controller_state.rs | 30 +++++++++---------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/kernel/src/arch/x86_64/rackscale/client_state.rs b/kernel/src/arch/x86_64/rackscale/client_state.rs index 6512385c1..daf91843a 100644 --- a/kernel/src/arch/x86_64/rackscale/client_state.rs +++ b/kernel/src/arch/x86_64/rackscale/client_state.rs @@ -32,10 +32,10 @@ pub(crate) struct ClientState { pub(crate) rpc_client: Arc>, /// Used to store shmem affinity base pages - pub(crate) affinity_base_pages: ArrayVec>>, MAX_MACHINES>, + pub(crate) affinity_base_pages: Arc>, MAX_MACHINES>>, /// Used to store base pages allocated to a process - pub(crate) per_process_base_pages: ArrayVec>, MAX_PROCESSES>, + pub(crate) per_process_base_pages: Arc, MAX_PROCESSES>>, } impl ClientState { @@ -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))); + )) as Box)); } 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), } } } diff --git a/kernel/src/arch/x86_64/rackscale/controller_state.rs b/kernel/src/arch/x86_64/rackscale/controller_state.rs index f935fffef..f0715e87a 100644 --- a/kernel/src/arch/x86_64/rackscale/controller_state.rs +++ b/kernel/src/arch/x86_64/rackscale/controller_state.rs @@ -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>>, MAX_MACHINES> = { + pub(crate) static ref CONTROLLER_SHMEM_CACHES: Arc>, 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))); + )) as Box)); for i in 1..MAX_MACHINES { - shmem_caches.push(Arc::new(Mutex::new(Box::new(FrameCacheBase::new(mid_to_shmem_affinity(i))) - as Box))); + shmem_caches.push(Mutex::new(Box::new(FrameCacheBase::new(mid_to_shmem_affinity(i))) + as Box)); } - shmem_caches + Arc::new(shmem_caches) }; } /// Caches of memslices allocated by the DCM scheduler lazy_static! { - pub(crate) static ref SHMEM_MEMSLICE_ALLOCATORS: ArrayVec>>, MAX_MACHINES> = { + pub(crate) static ref SHMEM_MEMSLICE_ALLOCATORS: Arc>, 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) }; } @@ -96,9 +96,9 @@ pub(crate) struct ControllerState { /// A composite list of all hardware threads hw_threads_all: Arc>>, /// Bit maps to keep track of free/busy hw threads. Index is machine_id - 1 - thread_maps: ArrayVec>, MAX_MACHINES>, + thread_maps: Arc, MAX_MACHINES>>, /// The NodeId of each thread, organized by client. Index is machine_id - 1 - affinities_per_client: ArrayVec>>, MAX_MACHINES>, + affinities_per_client: Arc>, MAX_MACHINES>>, } impl ControllerState { @@ -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), } }; }