mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 10:23:23 +00:00
Remove some repetitive locks forking Vmar
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
ac6d9256ef
commit
7407cc8091
@ -669,11 +669,11 @@ impl Vmar_ {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let inner = self.inner.lock();
|
let inner = self.inner.lock();
|
||||||
|
let mut new_inner = new_vmar_.inner.lock();
|
||||||
|
|
||||||
// Clone free regions.
|
// Clone free regions.
|
||||||
for (free_region_base, free_region) in &inner.free_regions {
|
for (free_region_base, free_region) in &inner.free_regions {
|
||||||
new_vmar_
|
new_inner
|
||||||
.inner
|
|
||||||
.lock()
|
|
||||||
.free_regions
|
.free_regions
|
||||||
.insert(*free_region_base, free_region.clone());
|
.insert(*free_region_base, free_region.clone());
|
||||||
}
|
}
|
||||||
@ -681,9 +681,7 @@ impl Vmar_ {
|
|||||||
// Clone child vmars.
|
// Clone child vmars.
|
||||||
for (child_vmar_base, child_vmar_) in &inner.child_vmar_s {
|
for (child_vmar_base, child_vmar_) in &inner.child_vmar_s {
|
||||||
let new_child_vmar = child_vmar_.new_fork(Some(&new_vmar_))?;
|
let new_child_vmar = child_vmar_.new_fork(Some(&new_vmar_))?;
|
||||||
new_vmar_
|
new_inner
|
||||||
.inner
|
|
||||||
.lock()
|
|
||||||
.child_vmar_s
|
.child_vmar_s
|
||||||
.insert(*child_vmar_base, new_child_vmar);
|
.insert(*child_vmar_base, new_child_vmar);
|
||||||
}
|
}
|
||||||
@ -698,11 +696,7 @@ impl Vmar_ {
|
|||||||
for (vm_mapping_base, vm_mapping) in &inner.vm_mappings {
|
for (vm_mapping_base, vm_mapping) in &inner.vm_mappings {
|
||||||
// Clone the `VmMapping` to the new VMAR.
|
// Clone the `VmMapping` to the new VMAR.
|
||||||
let new_mapping = Arc::new(vm_mapping.new_fork(&new_vmar_)?);
|
let new_mapping = Arc::new(vm_mapping.new_fork(&new_vmar_)?);
|
||||||
new_vmar_
|
new_inner.vm_mappings.insert(*vm_mapping_base, new_mapping);
|
||||||
.inner
|
|
||||||
.lock()
|
|
||||||
.vm_mappings
|
|
||||||
.insert(*vm_mapping_base, new_mapping);
|
|
||||||
|
|
||||||
// Protect the mapping and copy to the new page table for COW.
|
// Protect the mapping and copy to the new page table for COW.
|
||||||
cur_cursor.jump(*vm_mapping_base).unwrap();
|
cur_cursor.jump(*vm_mapping_base).unwrap();
|
||||||
@ -714,6 +708,8 @@ impl Vmar_ {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop(new_inner);
|
||||||
|
|
||||||
Ok(new_vmar_)
|
Ok(new_vmar_)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user