From 0abd57e59bf6e3cf30718064cb1d49947d048906 Mon Sep 17 00:00:00 2001 From: Erika Hunhoff Date: Wed, 6 Dec 2023 22:56:43 -0700 Subject: [PATCH] Update memory allocation scheme --- Cargo.lock | 213 +----------------- .../arch/x86_64/rackscale/get_shmem_frames.rs | 16 +- kernel/src/arch/x86_64/rackscale/syscalls.rs | 8 +- usr/init/src/dynrep/mod.rs | 9 +- 4 files changed, 26 insertions(+), 220 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 462abc1fc..1b11d08f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,15 +65,6 @@ dependencies = [ "as-slice", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "apic" version = "0.0.1" @@ -684,19 +675,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "generator" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" -dependencies = [ - "cc", - "libc 0.2.126", - "log", - "rustversion", - "windows", -] - [[package]] name = "generic-array" version = "0.12.4" @@ -869,7 +847,6 @@ dependencies = [ "lineup", "log", "md-5", - "nr2", "num-traits", "proptest 1.0.0 (git+https://github.com/gz/proptest.git?branch=x86-asm)", "rawtime", @@ -1041,19 +1018,6 @@ dependencies = [ "syn", ] -[[package]] -name = "loom" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" -dependencies = [ - "cfg-if 1.0.0", - "generator", - "scoped-tls", - "tracing", - "tracing-subscriber", -] - [[package]] name = "managed" version = "0.7.2" @@ -1066,15 +1030,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata", -] - [[package]] name = "matches" version = "0.1.9" @@ -1179,20 +1134,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "nr2" -version = "0.2.0" -source = "git+https://github.com/gz/node-replication.git?branch=nr-dymanic-replication#23d79389079659a202abc03a4d9753130acce22d" -dependencies = [ - "arr_macro", - "arrayvec", - "crossbeam-utils", - "hashbrown 0.11.2", - "log", - "loom", - "static_assertions", -] - [[package]] name = "nrk" version = "0.0.4" @@ -1346,7 +1287,7 @@ checksum = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" dependencies = [ "libc 0.2.126", "rand 0.4.6", - "smallvec 0.6.14", + "smallvec", "winapi 0.3.9", ] @@ -1689,9 +1630,6 @@ name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax", -] [[package]] name = "regex-syntax" @@ -1811,12 +1749,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "rusty-fork" version = "0.3.0" @@ -1835,12 +1767,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.1.0" @@ -1898,15 +1824,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "siphasher" version = "0.3.10" @@ -1931,12 +1848,6 @@ dependencies = [ "maybe-uninit", ] -[[package]] -name = "smallvec" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - [[package]] name = "smoltcp" version = "0.7.5" @@ -2052,16 +1963,6 @@ dependencies = [ "serde", ] -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if 1.0.0", - "once_cell", -] - [[package]] name = "tracing" version = "0.1.35" @@ -2092,36 +1993,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" -dependencies = [ - "ansi_term", - "matchers", - "once_cell", - "regex", - "sharded-slab", - "smallvec 1.11.2", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", ] [[package]] @@ -2179,12 +2050,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "vcell" version = "0.1.3" @@ -2323,115 +2188,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "x86" version = "0.47.0" diff --git a/kernel/src/arch/x86_64/rackscale/get_shmem_frames.rs b/kernel/src/arch/x86_64/rackscale/get_shmem_frames.rs index 205d9d803..b4cdd16ab 100644 --- a/kernel/src/arch/x86_64/rackscale/get_shmem_frames.rs +++ b/kernel/src/arch/x86_64/rackscale/get_shmem_frames.rs @@ -45,7 +45,7 @@ pub(crate) fn rpc_get_shmem_frames(pid: Option, num_frames: usize) -> KResu let mid = if pid.is_none() { Some(*crate::environment::MACHINE_ID) } else { - None + Some(*crate::environment::MACHINE_ID) }; let req = ShmemFrameReq { @@ -139,18 +139,24 @@ pub(crate) fn handle_get_shmem_frames( } } } else if let Some(pid) = pid { + let mid = mid.expect("Expected a machine ID"); + // Let DCM choose node - let (_, mids) = dcm_resource_alloc(pid, 0, num_frames as u64); + //let (_, mids) = dcm_resource_alloc(pid, 0, num_frames as u64); for i in 0..num_frames { - let mid = mids[i]; - log::debug!("Received node assignment from DCM: node {:?}", mid); + //let mid = mids[i]; + log::debug!( + "Allocating memory for process {:?} from node {:?}", + pid, + mid + ); // TODO(error_handling): should handle errors gracefully here, maybe percolate to client? let mut manager = &mut SHMEM_MEMSLICE_ALLOCATORS[mid - 1].lock(); let frame = manager .allocate_large_page() .expect("DCM OK'd allocation, this should succeed"); - assert!(frame.affinity == mid_to_shmem_affinity(mid)); + //assert!(frame.affinity == mid_to_shmem_affinity(mid)); regions.push(ShmemRegion { base: frame.base.as_u64(), affinity: frame.affinity, diff --git a/kernel/src/arch/x86_64/rackscale/syscalls.rs b/kernel/src/arch/x86_64/rackscale/syscalls.rs index 9f6beec1b..5f41471c1 100644 --- a/kernel/src/arch/x86_64/rackscale/syscalls.rs +++ b/kernel/src/arch/x86_64/rackscale/syscalls.rs @@ -52,7 +52,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { // This is necessary because map_frames -> MemMapFrames seems to assume // that base pages follow large pages. - let mut initial_base_frames = Vec::try_with_capacity(bp)?; + //let mut initial_base_frames = Vec::try_with_capacity(bp)?; let pid = current_pid()?; @@ -68,6 +68,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { let mut total_len = 0; if total_needed_base_pages > 0 { + /* let mut per_process_bp_cache = CLIENT_STATE.per_process_base_pages[pid].lock(); let base_pages_from_cache = core::cmp::min( per_process_bp_cache.free_base_pages(), @@ -86,6 +87,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { } total_needed_base_pages -= base_pages_from_cache; + */ // We'll have to allocate another large page to fulfill the request for base pages if total_needed_base_pages > 0 { @@ -127,6 +129,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { } // Add any remaining base pages to the cache, if there's space. + /* let mut per_process_bp_cache = CLIENT_STATE.per_process_base_pages[pid].lock(); let base_pages_to_save = core::cmp::min( base_page_iter.len(), @@ -142,6 +145,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { .grow_base_pages(&[frame]) .expect("We ensure not to overfill the FrameCacheBase above."); } + */ if base_page_iter.len() > 0 { log::debug!( @@ -155,6 +159,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { // Add initial base pages into frame array. doing this in the end ensures // that the order of the frames is large pages and then base pages. + /* for f in initial_base_frames { total_len += f.size; if paddr.is_none() { @@ -164,6 +169,7 @@ impl VSpaceDispatch for Arch86LwkSystemCall { .try_push(f) .expect("Can't fail see `try_with_capacity`"); } + */ nrproc::NrProcess::::map_frames( current_pid()?, diff --git a/usr/init/src/dynrep/mod.rs b/usr/init/src/dynrep/mod.rs index d0367354b..d0f7c8402 100644 --- a/usr/init/src/dynrep/mod.rs +++ b/usr/init/src/dynrep/mod.rs @@ -25,7 +25,7 @@ static POOR_MANS_BARRIER: AtomicUsize = AtomicUsize::new(0); #[derive(Clone)] struct HashTable { - pub map: HashMap, + pub map: HashMap, } impl Default for HashTable { @@ -45,11 +45,7 @@ impl Default for HashTable { } } -fn run_bench( - machine_id: usize, - core_id: usize, - replica: Arc, -) { +fn run_bench(machine_id: usize, core_id: usize, replica: Arc) { let mut random_key: u64 = 0; let batch_size = 64; let duration = 5; @@ -186,7 +182,6 @@ pub fn userspace_dynrep_test() { .spawn_on_core( Some(bencher_trampoline), Arc::into_raw(replicas[mid - 1].clone()) as *const _ as *mut u8, - gtids[core_index], ) .expect("Can't spawn bench thread?"),