Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(mm): add page reclaim for file-backed memory pressure (rebased) #1007
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
Uh oh!
There was an error while loading. Please reload this page.
feat(mm): add page reclaim for file-backed memory pressure (rebased) #1007
Changes from 5 commits
15f02b49f516db6fd0beacb849d487c05db733add3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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_cache锁内直接调用 eviction listener 并随后让pagedrop。当前 Starry 的 listener 在FileBackendInner::register_listener()中会先aspace.try_lock(),拿不到地址空间锁时直接返回;这在普通page_or_insert()eviction 里还能由 populate callback 延后处理,但 reclaim 路径没有保存(pn, page)也没有重试/回滚,函数返回后 clean page 的物理页会被释放,用户页表里可能仍然保留指向该物理页的 PTE。也就是说,这个“避免死锁”的try_lock分支会把死锁风险转成悬空映射/use-after-free。建议把 reclaim 改成两阶段:在持有
page_cache时只挑选并移出候选页,释放page_cache后调用 listener;并且 listener/回调需要能反馈是否完成了所有映射失效。若任何 listener 因锁竞争无法完成 unmap,就不能 drop 该 page(要放回 cache,或像 populate 的PopulateCallback一样延后到持有AddrSpace时再释放)。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.
复核
cb849d4b1后,这个问题仍然存在。新提交把try_evict_clean_pages()的返回值改成实际pop的数量,并补了 TODO,但当前代码仍然在page_cache锁内调用 listener,Starry 侧 listener 在aspace.try_lock()失败时仍然直接返回;reclaim 路径随后会 droppage释放物理页,没有PopulateCallback那样的保活/延后 unmap 机制。这里需要先让 reclaim eviction 能确认所有相关映射已经失效;如果 listener 因锁竞争或错误无法完成 unmap,就不能释放这个 page,需要放回 cache 或保留到后续能在持有
AddrSpace时安全 unmap。Uh oh!
There was an error while loading. Please reload this page.