替换 local_irq_save 为 IrqFlagsGuard 实现 (#317)

This commit is contained in:
Chiichen
2023-08-05 18:30:55 +08:00
committed by GitHub
parent abf3f634bf
commit 9550910ae1
4 changed files with 18 additions and 16 deletions

View File

@ -1,9 +1,10 @@
use super::{page::PageFlags, PageTableKind, PhysAddr, VirtAddr};
use crate::{
arch::{
asm::irqflags::{local_irq_restore, local_irq_save},
mm::{LockedFrameAllocator, PageMapper},
CurrentIrqArch,
},
exception::InterruptArch,
libs::align::page_align_up,
mm::allocator::page_frame::PageFrameCount,
mm::{MMArch, MemoryManagementArch},
@ -126,12 +127,12 @@ impl KernelMapper {
impl Drop for KernelMapper {
fn drop(&mut self) {
// 为了防止fetch_sub和store之间由于中断导致store错误清除了owner导致错误因此需要关中断。
let flags = local_irq_save();
let guard = unsafe { CurrentIrqArch::save_and_disable_irq() };
let prev_count = KERNEL_MAPPER_LOCK_COUNT.fetch_sub(1, Ordering::Relaxed);
if prev_count == 1 {
KERNEL_MAPPER_LOCK_OWNER.store(KERNEL_MAPPER_NO_PROCESSOR, Ordering::Release);
}
local_irq_restore(flags);
drop(guard);
compiler_fence(Ordering::Release);
}
}

View File

@ -1118,7 +1118,8 @@ impl VMA {
// kdebug!("VMA::zeroed: flusher dropped");
// 清空这些内存
let virt_iter: VirtPageFrameIter = VirtPageFrameIter::new(destination, destination.add(page_count));
let virt_iter: VirtPageFrameIter =
VirtPageFrameIter::new(destination, destination.add(page_count));
for frame in virt_iter {
let paddr = mapper.translate(frame.virt_address()).unwrap().0;