From 257e4a6eb5e11522c8197423339974aa07bbcc7b Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 1 Jan 2019 12:28:45 -0700 Subject: [PATCH] WIP: improve speed of Grant::map_inactive Use recursive page table address to calculate p4 entry --- src/arch/x86_64/paging/table.rs | 2 +- src/context/memory.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arch/x86_64/paging/table.rs b/src/arch/x86_64/paging/table.rs index 6784560..2f979f7 100644 --- a/src/arch/x86_64/paging/table.rs +++ b/src/arch/x86_64/paging/table.rs @@ -9,7 +9,7 @@ use memory::allocate_frames; use super::entry::{EntryFlags, Entry}; use super::ENTRY_COUNT; -pub const P4: *mut Table = 0xffff_ffff_ffff_f000 as *mut _; +pub const P4: *mut Table = (::RECURSIVE_PAGE_OFFSET | 0x7ffffff000) as *mut _; pub trait TableLevel {} diff --git a/src/context/memory.rs b/src/context/memory.rs index 7ec1f80..1fc68b7 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -3,6 +3,7 @@ use alloc::collections::VecDeque; use core::intrinsics; use spin::Mutex; +use arch::paging::PAGE_SIZE; use ipi::{ipi, IpiKind, IpiTarget}; use memory::Frame; use paging::{ActivePageTable, InactivePageTable, Page, PageIter, PhysicalAddress, VirtualAddress}; @@ -67,7 +68,7 @@ impl Grant { pub fn map_inactive(from: VirtualAddress, to: VirtualAddress, size: usize, flags: EntryFlags, new_table: &mut InactivePageTable, temporary_page: &mut TemporaryPage) -> Grant { let mut active_table = unsafe { ActivePageTable::new() }; - let mut frames = VecDeque::new(); + let mut frames = VecDeque::with_capacity(size/PAGE_SIZE); let start_page = Page::containing_address(from); let end_page = Page::containing_address(VirtualAddress::new(from.get() + size - 1));