Skip to content

Commit

Permalink
Basic MD5 hash added
Browse files Browse the repository at this point in the history
  • Loading branch information
zmckevitt committed Sep 30, 2023
1 parent 8fb92ef commit cdc3457
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 23 deletions.
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions kernel/tests/s10_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,12 +1071,12 @@ fn s10_memhash_benchmark() {
let mut p = spawn_nrk(&cmdline)?;

// Parse lines like
// `init::vmops: 1,maponly,1,4096,10000,1000,634948`
// `init::memhash: thread_id,memhash,operations,cur_cores,tot_cores`
// write them to a CSV file
let expected_lines = if cfg!(feature = "smoke") {
3
} else {
(cores * (cores + 1)) / 2 // sum from i=1 to n of i
(with_cores * (with_cores + 1)) / 2 // sum from i=1 to n of i
};

for _i in 0..expected_lines {
Expand Down Expand Up @@ -1111,5 +1111,4 @@ fn s10_memhash_benchmark() {
};

check_for_successful_exit(&cmdline, qemu_run(cores), output.clone());
// println!("Output: {:?}", output);
}
23 changes: 5 additions & 18 deletions usr/init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ lazy_static = { version = "1.4", default_features = false }
cstr_core = { version = "0.2.3", default-features = false }
spin = { version = "0.5.2", default_features = false }
hashbrown = { version = "0.11", features = [ "nightly" ] }
md-5 = { version = "0.10.6", default-features = false }
base64ct = "1.6.0"

[features]
default = []
Expand All @@ -41,8 +43,8 @@ test-upcall = []
test-scheduler = []
test-scheduler-smp = []
test-syscalls = []
test-rump-tmpfs = [ "rumprt" ]
test-rump-net = [ "rumprt" ]
test-rump-tmpfs = ["rumprt"]
test-rump-net = ["rumprt"]
test-fs = []
test-fs-prop = []
test-pmem-alloc = []
Expand All @@ -65,19 +67,4 @@ smoke = []
# Do latency measurements in benchmarks
latency = []

all-tests = [
"test-print",
"test-map",
"test-alloc",
"test-upcall",
"test-scheduler",
#"test-scheduler-smp", # Doesn't return
"test-syscalls",
"test-rump-tmpfs",
"test-rump-net",
"test-fs",
"test-phys-alloc",
# "test-request-core-remote", TODO: used only for rackscale tests right now
#"test-fs-prop", # needs userspace
#"test-pmem-alloc", # needs SMP
]
all-tests = ["test-print", "test-map", "test-alloc", "test-upcall", "test-scheduler", "test-syscalls", "test-rump-tmpfs", "test-rump-net", "test-fs", "test-phys-alloc"]
10 changes: 8 additions & 2 deletions usr/init/src/memhash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ use x86::bits64::paging::VAddr;

use lineup::tls2::{Environment, SchedulerControlBlock};

use base64ct::{Base64, Encoding};
use md5::{Digest, Md5};

static POOR_MANS_BARRIER: AtomicUsize = AtomicUsize::new(0);

// Hash function
// Equivalent to 1 operation
fn hashmem(core_id: usize) -> u64 {
0
fn hashmem(core_id: usize) {
let mut hasher = Md5::new();
hasher.update(b"hello world");
let hash = hasher.finalize();
// Base64::encode_string(&hash);
}

fn thread_routine(core_id: usize, cur_cores: usize, tot_cores: usize) {
Expand Down

0 comments on commit cdc3457

Please sign in to comment.