Skip to content
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

fix(mm): 修复fat文件系统的PageCache同步问题 #1005

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
add9d4b
实现read系统调用读取pagecache
MemoryShore Oct 19, 2024
d2ad608
完善read逻辑
MemoryShore Oct 20, 2024
60e36ca
完善create_pages
MemoryShore Oct 21, 2024
773e36d
添加read_direct
MemoryShore Oct 21, 2024
f99aec5
解决create_pages时的死锁问题
MemoryShore Oct 21, 2024
032db07
修复元数据未更新的问题
MemoryShore Oct 21, 2024
19ea62b
Merge branch 'master' into patch-fix-pagecache
MemoryShore Oct 21, 2024
8365ca3
重构read逻辑
MemoryShore Oct 26, 2024
acc821a
重写write逻辑
MemoryShore Oct 26, 2024
7d13a5b
修正页面回写逻辑
MemoryShore Oct 26, 2024
f97b0b7
Merge branch 'master' into patch-fix-pagecache
MemoryShore Oct 26, 2024
0553021
优化代码
MemoryShore Oct 27, 2024
63bd233
优化代码
MemoryShore Nov 10, 2024
fd59c5b
Merge branch 'master' into patch-fix-pagecache
MemoryShore Nov 10, 2024
1a7e9cc
修复lru链表缩减逻辑
MemoryShore Nov 10, 2024
668a279
修正page_writeback逻辑
MemoryShore Nov 11, 2024
ec98b84
添加write_direct
MemoryShore Nov 11, 2024
74c7059
Merge branch 'master' into patch-fix-pagecache
MemoryShore Nov 12, 2024
7a3608b
完善页面释放逻辑
MemoryShore Nov 12, 2024
0ba9483
完善Page结构体和页面创建流程
MemoryShore Nov 16, 2024
8c8051d
优化PageCache的drop逻辑
MemoryShore Nov 16, 2024
839bef9
PageCache改为HashMap存储页面
MemoryShore Nov 18, 2024
da46956
修正PageCache读写逻辑
MemoryShore Nov 18, 2024
67039ad
完善fat元数据的更新逻辑
MemoryShore Nov 18, 2024
49ab468
允许execve加载文件时缓存到PageCache
MemoryShore Nov 18, 2024
bac195a
优化代码
MemoryShore Nov 20, 2024
2e3f29f
修复内存泄露
MemoryShore Nov 25, 2024
0b281af
Page添加truncate方法
MemoryShore Nov 25, 2024
b9938e1
修复重复释放内存
MemoryShore Nov 25, 2024
9336e3a
PageCache加锁
MemoryShore Nov 26, 2024
f2d383f
PageCache创建单独模块
MemoryShore Nov 26, 2024
df1e8e3
Page外部添加PhysAddr
MemoryShore Nov 26, 2024
7951698
完善Page结构
MemoryShore Nov 27, 2024
f71462b
修复PageFlags初始化错误
MemoryShore Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions kernel/src/mm/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,7 @@ impl PageReclaimer {
/// - `count`: 需要缩减的页面数量
pub fn shrink_list(&mut self, count: PageFrameCount) {
for _ in 0..count.data() {
let (paddr, page) = self.lru.pop_lru().expect("pagecache is empty");
let page_cache = page.read_irqsave().page_cache().unwrap();
for vma in page.read_irqsave().anon_vma() {
let address_space = vma.lock_irqsave().address_space().unwrap();
let address_space = address_space.upgrade().unwrap();
let mut guard = address_space.write();
let mapper = &mut guard.user_mapper.utable;
let virt = vma.lock_irqsave().page_address(&page).unwrap();
unsafe {
mapper.unmap(virt, false).unwrap().flush();
}
}
page_cache.remove_page(page.read_irqsave().index().unwrap());
page_manager_lock_irqsave().remove_page(&paddr);
let (_, page) = self.lru.pop_lru().expect("pagecache is empty");
if page.read_irqsave().flags.contains(PageFlags::PG_DIRTY) {
Self::page_writeback(&page, true);
}
Expand Down Expand Up @@ -233,6 +220,7 @@ impl PageReclaimer {
let virt = vma.lock_irqsave().page_address(page).unwrap();
if unmap {
unsafe {
// 取消页表映射
mapper.unmap(virt, false).unwrap().flush();
}
} else {
Expand Down Expand Up @@ -286,6 +274,12 @@ impl PageReclaimer {
SpinLock::new(FilePrivateData::Unused).lock(),
)
.unwrap();

// 删除页面
let page_cache = page.read_irqsave().page_cache().unwrap();
let paddr = page.read_irqsave().phys_address();
page_cache.remove_page(page.read_irqsave().index().unwrap());
fslongjin marked this conversation as resolved.
Show resolved Hide resolved
page_manager_lock_irqsave().remove_page(&paddr);
}

/// lru脏页刷新
Expand Down
Loading