mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-30 10:53:58 +00:00
Avoid an Arc::clone
in mmap
to make it scale
This commit is contained in:
committed by
Chengjun Chen
parent
f9284d3803
commit
298a205da2
@ -58,8 +58,7 @@ impl Vmar<Rights> {
|
|||||||
/// which ensures that any updated memory permissions do not go beyond
|
/// which ensures that any updated memory permissions do not go beyond
|
||||||
/// the access rights of the underlying VMOs.
|
/// the access rights of the underlying VMOs.
|
||||||
pub fn new_map(&self, size: usize, perms: VmPerms) -> Result<VmarMapOptions<Rights, Rights>> {
|
pub fn new_map(&self, size: usize, perms: VmPerms) -> Result<VmarMapOptions<Rights, Rights>> {
|
||||||
let dup_self = self.dup()?;
|
Ok(VmarMapOptions::new(self, size, perms))
|
||||||
Ok(VmarMapOptions::new(dup_self, size, perms))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Changes the permissions of the memory mappings in the specified range.
|
/// Changes the permissions of the memory mappings in the specified range.
|
||||||
|
@ -480,8 +480,8 @@ impl<R> Vmar<R> {
|
|||||||
/// Options for creating a new mapping. The mapping is not allowed to overlap
|
/// Options for creating a new mapping. The mapping is not allowed to overlap
|
||||||
/// with any child VMARs. And unless specified otherwise, it is not allowed
|
/// with any child VMARs. And unless specified otherwise, it is not allowed
|
||||||
/// to overlap with any existing mapping, either.
|
/// to overlap with any existing mapping, either.
|
||||||
pub struct VmarMapOptions<R1, R2> {
|
pub struct VmarMapOptions<'a, R1, R2> {
|
||||||
parent: Vmar<R1>,
|
parent: &'a Vmar<R1>,
|
||||||
vmo: Option<Vmo<R2>>,
|
vmo: Option<Vmo<R2>>,
|
||||||
perms: VmPerms,
|
perms: VmPerms,
|
||||||
vmo_offset: usize,
|
vmo_offset: usize,
|
||||||
@ -496,14 +496,14 @@ pub struct VmarMapOptions<R1, R2> {
|
|||||||
handle_page_faults_around: bool,
|
handle_page_faults_around: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R1, R2> VmarMapOptions<R1, R2> {
|
impl<'a, R1, R2> VmarMapOptions<'a, R1, R2> {
|
||||||
/// Creates a default set of options with the VMO and the memory access
|
/// Creates a default set of options with the VMO and the memory access
|
||||||
/// permissions.
|
/// permissions.
|
||||||
///
|
///
|
||||||
/// The VMO must have access rights that correspond to the memory
|
/// The VMO must have access rights that correspond to the memory
|
||||||
/// access permissions. For example, if `perms` contains `VmPerms::Write`,
|
/// access permissions. For example, if `perms` contains `VmPerms::Write`,
|
||||||
/// then `vmo.rights()` should contain `Rights::WRITE`.
|
/// then `vmo.rights()` should contain `Rights::WRITE`.
|
||||||
pub fn new(parent: Vmar<R1>, size: usize, perms: VmPerms) -> Self {
|
pub fn new(parent: &'a Vmar<R1>, size: usize, perms: VmPerms) -> Self {
|
||||||
Self {
|
Self {
|
||||||
parent,
|
parent,
|
||||||
vmo: None,
|
vmo: None,
|
||||||
|
@ -68,8 +68,7 @@ impl<R: TRights> Vmar<TRightSet<R>> {
|
|||||||
size: usize,
|
size: usize,
|
||||||
perms: VmPerms,
|
perms: VmPerms,
|
||||||
) -> Result<VmarMapOptions<TRightSet<R>, Rights>> {
|
) -> Result<VmarMapOptions<TRightSet<R>, Rights>> {
|
||||||
let dup_self = self.dup()?;
|
Ok(VmarMapOptions::new(self, size, perms))
|
||||||
Ok(VmarMapOptions::new(dup_self, size, perms))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Change the permissions of the memory mappings in the specified range.
|
/// Change the permissions of the memory mappings in the specified range.
|
||||||
|
Reference in New Issue
Block a user