Remove the level in RawPageTableNode

This commit is contained in:
Ruihan Li
2024-06-05 20:36:35 +08:00
committed by Tate, Hongliang Tian
parent 6cfccccab1
commit 4f2d537516
2 changed files with 9 additions and 18 deletions

View File

@ -56,7 +56,6 @@ where
[(); C::NR_LEVELS as usize]:,
{
pub(super) raw: Paddr,
pub(super) level: PagingLevel,
_phantom: PhantomData<(E, C)>,
}
@ -74,7 +73,6 @@ where
// transferring the ownership to a new handle. No increment of the reference
// count is needed.
let page = unsafe { Page::<PageTablePageMeta<E, C>>::from_raw(self.paddr()) };
debug_assert!(page.meta().level == self.level);
// Acquire the lock.
while page
@ -98,7 +96,6 @@ where
Self {
raw: self.raw,
level: self.level,
_phantom: PhantomData,
}
}
@ -121,8 +118,6 @@ where
mm::CachePolicy,
};
debug_assert_eq!(self.level, PagingConsts::NR_LEVELS);
let last_activated_paddr = current_page_table_paddr();
activate_page_table(self.raw, CachePolicy::Writeback);
@ -137,7 +132,6 @@ where
// Restore and drop the last activated page table.
drop(Self {
raw: last_activated_paddr,
level: PagingConsts::NR_LEVELS,
_phantom: PhantomData,
});
}
@ -149,8 +143,6 @@ where
pub(super) unsafe fn first_activate(&self) {
use crate::{arch::mm::activate_page_table, mm::CachePolicy};
debug_assert_eq!(self.level, PagingConsts::NR_LEVELS);
self.inc_ref();
activate_page_table(self.raw, CachePolicy::Writeback);
@ -240,7 +232,6 @@ where
/// Converts the handle into a raw handle to be stored in a PTE or CPU.
pub(super) fn into_raw(self) -> RawPageTableNode<E, C> {
let level = self.level();
let raw = self.page.paddr();
self.page.meta().lock.store(0, Ordering::Release);
@ -248,7 +239,6 @@ where
RawPageTableNode {
raw,
level,
_phantom: PhantomData,
}
}
@ -259,7 +249,6 @@ where
RawPageTableNode {
raw: self.page.paddr(),
level: self.level(),
_phantom: PhantomData,
}
}
@ -283,7 +272,6 @@ where
core::mem::forget(inc_ref);
Child::PageTable(RawPageTableNode {
raw: paddr,
level: self.level() - 1,
_phantom: PhantomData,
})
} else if in_tracked_range {
@ -368,7 +356,6 @@ where
) {
// They should be ensured by the cursor.
debug_assert!(idx < nr_subpage_per_huge::<C>());
debug_assert_eq!(pt.level, self.level() - 1);
let pte = Some(E::new_pt(pt.paddr()));
self.overwrite_pte(idx, pte, in_tracked_range);