diff --git a/cache_utils/src/calibration.rs b/cache_utils/src/calibration.rs index d48b0fc..cc97a59 100644 --- a/cache_utils/src/calibration.rs +++ b/cache_utils/src/calibration.rs @@ -163,6 +163,9 @@ pub fn calibrate_flush() -> u64 { miss_histogram[min(CFLUSH_BUCKET_NUMBER - 1, d / CFLUSH_BUCKET_SIZE) as usize] += 1; } + let mut hit_max: (usize, u32) = (0, 0); + let mut miss_max: (usize, u32) = (0, 0); + for i in 0..hit_histogram.len() { serial_println!( "{:3}: {:10} {:10}", @@ -170,7 +173,23 @@ pub fn calibrate_flush() -> u64 { hit_histogram[i], miss_histogram[i] ); + if hit_max.1 < hit_histogram[i] { + hit_max = (i, hit_histogram[i]); + } + if miss_max.1 < miss_histogram[i] { + miss_max = (i, miss_histogram[i]); + } + } + serial_println!("Miss max {}", miss_max.0 * CFLUSH_BUCKET_SIZE); + serial_println!("Max hit {}", hit_max.0 * CFLUSH_BUCKET_SIZE); + let mut threshold: (usize, u32) = (0, u32::max_value()); + for i in miss_max.0..hit_max.0 { + if hit_histogram[i] + miss_histogram[i] < threshold.1 { + threshold = (i, hit_histogram[i] + miss_histogram[i]); + } } - (-1_i64) as u64 + serial_println!("Threshold {}", threshold.0 * CFLUSH_BUCKET_SIZE); + serial_println!("Calibration done."); + (threshold.0 * CFLUSH_BUCKET_SIZE) as u64 } diff --git a/src/main.rs b/src/main.rs index 51d8098..0bfd7c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use dendrobates_tinctoreus_azureus::allocator; use polling_serial::serial_print; use polling_serial::serial_println; use vga_buffer; // required for custom panic handler -use vga_buffer::println; +use vga_buffer::{print, println}; use x86_64; #[cfg(not(test))] @@ -92,6 +92,12 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! { cache_utils::prefetcher::prefetcher_status() ); + print!("Testing reverse range:"); + for i in (0..2).rev() { + print!(" {}", i); + } + println!(); + cache_utils::calibration::calibrate_access(); cache_utils::calibration::calibrate_flush(); cache_utils::prefetcher::enable_prefetchers(false);