feat(mm): 实现用户态缺页 OOM killer#1984
Open
sparkzky wants to merge 2 commits into
Open
Conversation
当用户态缺页处理遇到 VM_FAULT_OOM 时,调用 OOM killer 选择并终止 占用内存最多的进程,释放内存后重试缺页,避免系统 livelock。 主要变更: - 新增 kernel/src/mm/oom.rs:OOM killer 核心逻辑,包括进程评分、 选择与终止、内存释放通知与重试等待机制 - 在 AddressSpace 中新增 resident_user_pages 原子计数器,跟踪每个 地址空间的驻留物理页数,作为 OOM 评分的依据 - 缺页处理路径 (fault.rs) 中注入 VM_FAULT_OOM 故障点,并统计新建 present mapping 的页数 - x86_64 page fault handler 中处理 VM_FAULT_OOM:调用 OOM killer 后重试缺页,重试失败则向触发进程发送 SIGKILL - 新增 /proc/sys/vm/oom_fault_inject 调试接口,用于注入 OOM 故障 - 修复 /proc/pid/stat 和 /proc/pid/statm 使用 resident_pages 计数 - 进程退出时通知 OOM 子系统释放地址空间(notify_mm_released) - 新增用户态测试程序 test_oom_killer.c - 新增 OOM killer 设计文档 Signed-off-by: sparkzky <sparkhhhhhhhhhh@outlook.com>
0c991a5 to
ad214c7
Compare
Member
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad214c7418
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Comment on lines
+113
to
+115
| fn current_is_killed_or_exiting() -> bool { | ||
| let current = ProcessManager::current_pcb(); | ||
| Signal::fatal_signal_pending(¤t) || current.flags().intersects(ProcessFlags::EXITING) |
There was a problem hiding this comment.
Comment on lines
+133
to
+134
| if score < 0 && !capable(CAPFlags::CAP_SYS_RESOURCE) { | ||
| return Err(SystemError::EACCES); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
当用户态缺页处理遇到 VM_FAULT_OOM 时,调用 OOM killer 选择并终止
占用内存最多的进程,释放内存后重试缺页,避免系统 livelock。
主要变更: