cache_utils update
This commit is contained in:
parent
2e7558c948
commit
ba210848e2
@ -139,7 +139,7 @@ pub fn calibrate_access(array: &[u8; 4096]) -> u64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CFLUSH_BUCKET_SIZE: usize = 1;
|
const CFLUSH_BUCKET_SIZE: usize = 1;
|
||||||
const CFLUSH_BUCKET_NUMBER: usize = 250;
|
const CFLUSH_BUCKET_NUMBER: usize = 500;
|
||||||
|
|
||||||
const CFLUSH_NUM_ITER: usize = 1 << 11;
|
const CFLUSH_NUM_ITER: usize = 1 << 11;
|
||||||
const CFLUSH_SPURIOUS_THRESHOLD: usize = 1;
|
const CFLUSH_SPURIOUS_THRESHOLD: usize = 1;
|
||||||
@ -231,9 +231,6 @@ pub fn calibrate_flush(
|
|||||||
miss_histogram[i]
|
miss_histogram[i]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// FIXME
|
|
||||||
// Code duplication for histogram analysis is meh.
|
|
||||||
// Is there a better way ?
|
|
||||||
|
|
||||||
for (min, max, med, sum, hist) in &mut [
|
for (min, max, med, sum, hist) in &mut [
|
||||||
(
|
(
|
||||||
@ -265,7 +262,7 @@ pub fn calibrate_flush(
|
|||||||
|
|
||||||
if **med == 0 {
|
if **med == 0 {
|
||||||
**sum += hist[i];
|
**sum += hist[i];
|
||||||
if **sum >= CFLUSH_NUM_ITER / 2 {
|
if **sum >= (CFLUSH_NUM_ITER - hist[hist.len() - 1]) / 2 {
|
||||||
**med = i;
|
**med = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,53 @@ use nix::sched::{sched_getaffinity, sched_setaffinity, CpuSet};
|
|||||||
use nix::unistd::Pid;
|
use nix::unistd::Pid;
|
||||||
use nix::Error::Sys;
|
use nix::Error::Sys;
|
||||||
|
|
||||||
|
use nix::sys::mman;
|
||||||
|
use static_assertions::_core::ptr::{null_mut, slice_from_raw_parts};
|
||||||
|
|
||||||
|
/* from linux kernel headers.
|
||||||
|
#define HUGETLB_FLAG_ENCODE_SHIFT 26
|
||||||
|
#define HUGETLB_FLAG_ENCODE_MASK 0x3f
|
||||||
|
|
||||||
|
#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)
|
||||||
|
#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)
|
||||||
|
#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)
|
||||||
|
#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
|
||||||
|
*/
|
||||||
|
|
||||||
|
const SIZE: usize = 2 << 20;
|
||||||
|
/*
|
||||||
#[repr(align(4096))]
|
#[repr(align(4096))]
|
||||||
struct Page {
|
struct Page {
|
||||||
pub mem: [u8; 4096],
|
pub mem: [u8; 4096],
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let p = Box::new(Page { mem: [0; 4096] });
|
let m: &[u8] = unsafe {
|
||||||
|
let p: *mut u8 = mman::mmap(
|
||||||
|
null_mut(),
|
||||||
|
SIZE,
|
||||||
|
mman::ProtFlags::PROT_READ | mman::ProtFlags::PROT_WRITE,
|
||||||
|
mman::MapFlags::MAP_PRIVATE
|
||||||
|
| mman::MapFlags::MAP_ANONYMOUS
|
||||||
|
| mman::MapFlags::MAP_HUGETLB,
|
||||||
|
-1,
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
.unwrap() as *mut u8;
|
||||||
|
/*addr: *mut c_void,
|
||||||
|
length: size_t,
|
||||||
|
prot: ProtFlags,
|
||||||
|
flags: MapFlags,
|
||||||
|
fd: RawFd,
|
||||||
|
offset: off_t*/
|
||||||
|
|
||||||
let m: &[u8] = &p.mem;
|
&*slice_from_raw_parts(p, SIZE)
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
let p = Box::new(Page { mem: [0; 4096] });
|
||||||
|
|
||||||
|
let m: &[u8] = &p.mem;
|
||||||
|
*/
|
||||||
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
||||||
|
|
||||||
for i in 0..(CpuSet::count() - 1) {
|
for i in 0..(CpuSet::count() - 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user