Skip to content

Conversation

@mistcoversmyeyes
Copy link
Contributor

概述

修复了 sysinfo 系统调用的 3 个关键字段未正确填充的问题,导致 gvisor 测试失败。

主要修改

1. uptime 字段

使用 clock() / HZ 计算系统运行时间(秒)

  • 修复前: uptime = 0
  • 修复后: uptime = clock() / HZ

2. procs 字段

使用 ProcessManager::get_all_processes() 统计进程数

  • 修复前: procs = 0
  • 修复后: procs = ProcessManager::get_all_processes().len() as u16

3. mem_unit 字段

设为 1(字节单位)

  • 修复前: mem_unit = 0
  • 修复后: mem_unit = 1

测试验证

  • ✅ Gvisor sysinfo 测试: 8/8 通过
  • ✅ 新增 r_unittest 测试: 4/4 通过

影响范围

  • kernel/src/syscall/misc.rs: sysinfo 系统调用实现(6 行修改)
  • user/apps/r_unitest/src/bin/test_sysinfo.rs: 新增单元测试(206 行)

相关 Issue

解决 gvisor sysinfo 测试失败问题

修复了 sysinfo 系统调用的 3 个关键字段未正确填充的问题,
导致 gvisor 测试失败。

## 主要修改

1. **uptime 字段**: 使用 clock() / HZ 计算系统运行时间(秒)
   - 修复前: uptime = 0
   - 修复后: uptime = clock() / HZ

2. **procs 字段**: 使用 ProcessManager::get_all_processes() 统计进程数
   - 修复前: procs = 0
   - 修复后: procs = ProcessManager::get_all_processes().len() as u16

3. **mem_unit 字段**: 设为 1(字节单位)
   - 修复前: mem_unit = 0
   - 修复后: mem_unit = 1

## 测试验证

- Gvisor sysinfo 测试: 8/8 通过
- 新增 r_unittest 测试: 4/4 通过

## 影响范围

- kernel/src/syscall/misc.rs: sysinfo 系统调用实现
- user/apps/r_unitest/src/bin/test_sysinfo.rs: 新增单元测试
@github-actions github-actions bot added the Bug fix A bug is fixed in this pull request label Jan 11, 2026
@fslongjin
Copy link
Member

#1622
这里有重复的了已经。

@mistcoversmyeyes mistcoversmyeyes deleted the fix/sysinfo branch January 13, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix A bug is fixed in this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants