-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathmain.rs
More file actions
40 lines (33 loc) · 1.09 KB
/
main.rs
File metadata and controls
40 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#[cfg(all(feature = "mm", feature = "fs"))]
#[test]
fn test_mbind() {
let size = 8192;
unsafe {
let vaddr = rustix::mm::mmap_anonymous(
std::ptr::null_mut(),
size,
rustix::mm::ProtFlags::READ | rustix::mm::ProtFlags::WRITE,
rustix::mm::MapFlags::PRIVATE,
)
.unwrap();
vaddr.cast::<usize>().write(100);
let mask = &[1];
rustix::numa::mbind(
vaddr,
size,
rustix::numa::Mode::BIND | rustix::numa::Mode::STATIC_NODES,
mask,
rustix::numa::ModeFlags::empty(),
)
.unwrap();
rustix::numa::get_mempolicy_node(vaddr).unwrap();
match rustix::numa::get_mempolicy_next_node() {
Err(rustix::io::Errno::INVAL) => (),
_ => panic!(
"rustix::numa::get_mempolicy_next_node() should return EINVAL for MPOL_DEFAULT"
),
}
rustix::numa::set_mempolicy(rustix::numa::Mode::INTERLEAVE, mask).unwrap();
rustix::numa::get_mempolicy_next_node().unwrap();
}
}