-
-
Notifications
You must be signed in to change notification settings - Fork 158
实现页面反向映射 #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
实现页面反向映射 #670
Conversation
r? @fslongjin dragonosbot has assigned @fslongjin. Use |
kernel/src/mm/page.rs
Outdated
}; | ||
|
||
lazy_static! { | ||
/// 全局物理页信息管理器 | ||
pub static ref PAGE_MANAGER: SpinLock<PageManager> = SpinLock::new(PageManager::new()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这玩意应当显式指定初始化的时机,而不是使用lazy_static
deallocate_page_frames( | ||
PhysPageFrame::new(PhysAddr::new(paddr)), | ||
page_count, | ||
&mut PAGE_MANAGER.lock(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个PAGE_MANAGER.lock()
最好封装成函数。
并且应当是lock_irqsave?因为hzp在写的那个pagefault处理,估计中断上下文内会使用到这个东西,因此得lock irqsave
kernel/src/mm/ucontext.rs
Outdated
|
||
// 如果物理页的anon_vma链表长度为0并且不是共享页,则释放物理页. | ||
// 目前由于还没有实现共享页,所以直接释放物理页也没问题。 | ||
// 但是在实现共享页之后,就不能直接释放物理页了,需要在anon_vma链表长度为0的时候才能释放物理页 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
过时的注释得删掉
@dragonosbot author |
@dragonosbot ready |
|
||
/// 判断当前物理页是否能被回 | ||
pub fn can_deallocate(&self) -> bool { | ||
self.map_count == 0 && !self.shared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也许这个map_count为0就能释放?不然的话如果忘记清除shared,就永远无法释放
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我一开始也是这么想的,但是Linux的共享内存即使映射计数是0,在没有设置可被回收的情况下,是不会被释放的,进程依然能够连接到这块共享内存。或者看我们想怎么设计
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我一开始也是这么想的,但是Linux的共享内存即使映射计数是0,在没有设置可被回收的情况下,是不会被释放的,进程依然能够连接到这块共享内存。或者看我们想怎么设计
哦哦哦,确实有道理。
结构:
机制: