Implement the stray marking in PT to ensure serializability

This commit is contained in:
Zhang Junyang
2025-03-24 11:58:03 +08:00
committed by Tate, Hongliang Tian
parent 5b7637eac3
commit 54fbdcf059
10 changed files with 167 additions and 126 deletions

View File

@ -3,7 +3,10 @@
//! This module provides accessors to the page table entries in a node.
use super::{Child, MapTrackingStatus, PageTableEntryTrait, PageTableGuard, PageTableNode};
use crate::mm::{nr_subpage_per_huge, page_prop::PageProperty, page_size, PagingConstsTrait};
use crate::{
mm::{nr_subpage_per_huge, page_prop::PageProperty, page_size, PagingConstsTrait},
sync::RcuDrop,
};
/// A view of an entry in a page table node.
///
@ -127,8 +130,10 @@ impl<'guard, 'pt, E: PageTableEntryTrait, C: PagingConstsTrait> Entry<'guard, 'p
// 1. The index is within the bounds.
// 2. The new PTE is compatible with the page table node.
unsafe {
self.node
.write_pte(self.idx, Child::PageTable(new_page).into_pte())
self.node.write_pte(
self.idx,
Child::PageTable(RcuDrop::new(new_page)).into_pte(),
)
};
*self.node.nr_children_mut() += 1;
@ -178,8 +183,10 @@ impl<'guard, 'pt, E: PageTableEntryTrait, C: PagingConstsTrait> Entry<'guard, 'p
// 1. The index is within the bounds.
// 2. The new PTE is compatible with the page table node.
unsafe {
self.node
.write_pte(self.idx, Child::PageTable(new_page).into_pte())
self.node.write_pte(
self.idx,
Child::PageTable(RcuDrop::new(new_page)).into_pte(),
)
};
// SAFETY: The resulting guard lifetime (`'a`) is no shorter than the