Skip to content

feat(smp): 实现SYS_GETCPU系统调用#1368

Merged
fslongjin merged 1 commit intoDragonOS-Community:masterfrom
fslongjin:feat-sys-getcpu
Nov 12, 2025
Merged

feat(smp): 实现SYS_GETCPU系统调用#1368
fslongjin merged 1 commit intoDragonOS-Community:masterfrom
fslongjin:feat-sys-getcpu

Conversation

@fslongjin
Copy link
Member

  • 新增sys_getcpu模块,实现获取当前CPU编号和NUMA节点编号功能
  • 在smp/syscall模块中导出sys_getcpu模块
  • 在gvisor测试白名单中添加getcpu相关测试用例
  • 系统调用返回当前CPU ID,对于NUMA节点固定返回0(DragonOS不支持NUMA)

- 新增sys_getcpu模块,实现获取当前CPU编号和NUMA节点编号功能
- 在smp/syscall模块中导出sys_getcpu模块
- 在gvisor测试白名单中添加getcpu相关测试用例
- 系统调用返回当前CPU ID,对于NUMA节点固定返回0(DragonOS不支持NUMA)

Signed-off-by: longjin <longjin@DragonOS.org>
Copilot AI review requested due to automatic review settings November 12, 2025 12:47
@github-actions github-actions bot added the enhancement New feature or request label Nov 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the SYS_GETCPU system call for DragonOS, enabling user programs to query the current CPU ID and NUMA node information.

Summary: The implementation adds a new syscall handler that returns the current processor ID via a user-space pointer parameter. Since DragonOS doesn't support NUMA, all CPUs report node 0. The implementation follows the Linux getcpu interface with three parameters (cpu, node, and cache), where the cache parameter is ignored as per Linux behavior.

Key Changes:

  • Implemented sys_getcpu syscall handler with proper user-space pointer validation
  • Added module declaration in smp/syscall/mod.rs (and corrected sys_sched_getaffinity visibility)
  • Updated gvisor test whitelist to include getcpu test cases

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
kernel/src/smp/syscall/sys_getcpu.rs New syscall implementation that retrieves current CPU ID via smp_get_processor_id() and writes to user space using UserBufferWriter
kernel/src/smp/syscall/mod.rs Added sys_getcpu module declaration and changed sys_sched_getaffinity from pub to private for consistency
user/apps/tests/syscall/gvisor/whitelist.txt Added getcpu_test and getcpu_host_test to the test suite whitelist

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fslongjin fslongjin merged commit 2090919 into DragonOS-Community:master Nov 12, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants