Add uninit option for VmAllocOption

This commit is contained in:
Jianfeng Jiang
2023-06-01 16:21:39 +08:00
committed by Tate, Hongliang Tian
parent 7304e06c88
commit 7803d9037e
4 changed files with 30 additions and 19 deletions

View File

@ -112,7 +112,8 @@ struct Page {
impl Page {
pub fn alloc() -> Result<Self> {
let frame = {
let vm_alloc_option = VmAllocOptions::new(1);
let mut vm_alloc_option = VmAllocOptions::new(1);
vm_alloc_option.uninit(true);
let mut frames = VmFrameVec::allocate(&vm_alloc_option)?;
frames.pop().unwrap()
};
@ -126,7 +127,6 @@ impl Page {
let frame = {
let vm_alloc_option = VmAllocOptions::new(1);
let mut frames = VmFrameVec::allocate(&vm_alloc_option)?;
frames.zero();
frames.pop().unwrap()
};
Ok(Self {

View File

@ -204,9 +204,7 @@ impl Vmo_ {
let frames = match &inner.pager {
None => {
let vm_alloc_option = VmAllocOptions::new(1);
let frames = VmFrameVec::allocate(&vm_alloc_option)?;
frames.iter().for_each(|frame| frame.zero());
frames
VmFrameVec::allocate(&vm_alloc_option)?
}
Some(pager) => {
let frame = pager.commit_page(offset)?;