feat(smp): 实现SYS_GETCPU系统调用#1368
Merged
fslongjin merged 1 commit intoDragonOS-Community:masterfrom Nov 12, 2025
Merged
Conversation
Member
fslongjin
commented
Nov 12, 2025
- 新增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>
Contributor
There was a problem hiding this comment.
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.
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.