Skip to content

feat:Improve OSComp musl compatibility, VFS page cache behavior, and procfs/syscall semantics - #268

Merged
a6d9a6m merged 45 commits into
mainfrom
ccy-dev02
Jun 28, 2026
Merged

feat:Improve OSComp musl compatibility, VFS page cache behavior, and procfs/syscall semantics#268
a6d9a6m merged 45 commits into
mainfrom
ccy-dev02

Conversation

@a6d9a6m

@a6d9a6m a6d9a6m commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

概述

本 PR 将 ccy-dev02 合并回 main。本分支主要围绕 OSComp/musl 测试环境做兼容性和内核语义修复,目标是让真实用户态测试程序少卡在内核行为差异上。重点覆盖文件系统缓存、procfs 进程文件、futex/wait/signal 状态、内存锁兼容、socket errno 行为,以及本地评测镜像挂载路径。

相对 origin/main,当前分支包含 38 个非 merge 提交和 3 个 merge 提交,共修改 54 个文件,约 2.9k 行新增、0.45k 行删除。

主要变更

OSComp 与 musl 测试运行环境

  • 对齐 RISC-V 和 LoongArch 本地运行路径,使其更接近官方 test image 的挂载形态。
  • 修正 LoongArch 测试镜像设备顺序:官方测试盘暴露为 /dev/vda,内核分区盘暴露为 /dev/vdb
  • 将 musl init 脚本中的测试 staging 从 cp -a 调整为 cp -R,避免不必要的元数据保留语义影响测试搬运。
  • 在 RISC-V musl 环境中把 LTP testcase bin 目录加入 PATH,同时把默认启动流程收窄到当前确认不会卡死的脚本范围。

VFS、ext4、tmpfs 与 page cache

  • 新增共享的 VFS clean page cache,支持 byte-backed 和 frame-backed cached page、统计计数、范围失效、inode/filesystem 失效,以及 clean range refresh。
  • 将 ext4 普通文件读取接入共享 VFS page cache。
  • 在 ext4 写入、truncate、unlink、rename、create 等 inode 变更路径中刷新或失效缓存页,避免文件更新后继续读到旧数据。
  • 加固 tmpfs 页分配和 truncate 语义,包括分配失败回滚、部分页截断后的尾部清零。
  • 为目录遍历增加 per-open 目录快照缓存,减少重复 readdir 的状态不一致风险。
  • 修正 fd-table 在动态 max_fds 下的 dup/dup-from 行为。
  • 增加 VFS/ext4/tmpfs 相关测试,覆盖 page cache 命中、失效、写入刷新、truncate、mmap 一致性和目录/文件边界行为。

procfs 进程兼容性

  • 新增可写动态 procfs 文件能力。
  • 实现每进程 /proc/<pid>/oom_score_adj,支持用户态写入。
  • 实现每进程 /proc/<pid>/oom_score
  • 允许可写动态 procfs 文件被 truncate 到 0,匹配常见用户态写 proc 文件流程。

syscall 与进程语义

  • 改进 futex 支持,补齐 wait/wake 公共路径、FUTEX_WAIT_BITSETFUTEX_WAKE_BITSET、requeue/cmp-requeue 等行为。
  • 增加 mlockmunlockmlockallmunlockall 兼容路径:在不支持 swap 的内核中作为 no-op,但仍校验地址范围和资源限制。
  • 将信号终止的进程退出状态编码到 wait status 中,不再简单压平成普通 exit code。
  • 修正 wait4:当不存在匹配子进程时返回 ECHILD,避免阻塞等待永久睡眠。
  • 补齐上述行为所需的 syscall 分发表、编号和 uapi 常量。

网络兼容性

  • 对不支持的 sockaddr family 和非本机 IPv4 bind 地址返回更接近 Linux 的 errno。
  • Unix socket bind 前释放 task lock,避免在 socket/filesystem bind 工作期间持有进程状态锁。
  • 对 UDP socket 调用 accept 返回 EOPNOTSUPP
  • 在 UDP sendtoconnect 前确保 socket 绑定到合适的本地 endpoint,并处理 loopback 源地址。

代表提交

  • a2e1b9d fix: 确定默认不会卡死的脚本范围
  • fb7c405 procfs: 实现每进程 oom_score
  • 6e7bfd4 procfs: 实现每进程 oom_score_adj
  • f96f58f procfs: 增加可写动态 proc inode 支持
  • 596741b net: 对 UDP accept 返回 EOPNOTSUPP
  • 11ea465 net: Unix socket bind 前释放 task lock
  • 6ab12f6 fix(libc): 改进 syscall 兼容性
  • 0038e83 fix(net): 返回 Linux 风格 bind 地址错误
  • 5257d33 fix(compat): 增加 cyclictest 兼容 hook
  • 6d4345d fix(mm): 增加 memlock syscall 兼容
  • 6236827 fix(wait): 在 wait status 中编码信号退出
  • 230841e fix(oscomp): 对齐 test image 启动路径
  • 8e3abc5 fix(tmpfs): 加固页存储语义
  • 63fd74c feat(vfs): 增加 clean page cache
  • dc5e04e feat(ext4): 使用 VFS page cache 读取 ext4
  • 1686ee9 fix(ext4): 在文件变更时失效 page cache

a6d9a6m added 30 commits June 27, 2026 16:22

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a shared clean file page cache for VFS-backed filesystems (integrated with ext4), refactors tmpfs page allocation, adds support for /proc/[pid]/oom_score and /proc/[pid]/oom_score_adj, implements memory locking syscalls (mlock/munlock), and improves directory snapshot caching. Critical feedback highlights a potential deadlock in the bind syscall where a spinlock is held during user-space memory copies, a POSIX compliance bug in dup_from that could allocate file descriptors below min_fd, and a data race in the new page cache when refreshing pages concurrently with readers. Additionally, improvements are suggested for OOM score calculations to avoid overestimating memory usage and to handle trailing null bytes when parsing oom_score_adj inputs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread os/src/kernel/syscall/network/socket_ops.rs Outdated
Comment thread os/src/vfs/fd_table.rs
Comment thread os/src/vfs/page_cache.rs
Comment thread os/src/fs/proc/generators/process/oom_score.rs Outdated
Comment thread os/src/fs/proc/generators/process/oom_score_adj.rs Outdated
@a6d9a6m
a6d9a6m merged commit 0f2b71e into main Jun 28, 2026
1 check passed
@a6d9a6m
a6d9a6m deleted the ccy-dev02 branch June 28, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant