refactor(futex): 迁移futex系统调用到syscall table机制#1320
refactor(futex): 迁移futex系统调用到syscall table机制#1320fslongjin merged 1 commit intoDragonOS-Community:masterfrom
Conversation
fslongjin
commented
Oct 10, 2025
- 将futex系统调用从通用系统调用模块中分离
- 为futex和robust futex创建独立的系统调用处理器
- 将futex系统调用从通用系统调用模块中分离 - 为futex和robust futex创建独立的系统调用处理器 Signed-off-by: longjin <longjin@DragonOS.org>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the futex system call implementation by migrating it from the general syscall module to a dedicated syscall table mechanism. The change separates futex functionality into specialized handlers while maintaining the same API and functionality.
- Migrates futex, set_robust_list, and get_robust_list system calls to dedicated handlers
- Creates independent syscall handlers implementing the
Syscalltrait for better modularity - Removes futex-related code from the general syscall dispatcher
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| kernel/src/syscall/mod.rs | Removes futex-related imports and syscall cases from the general dispatcher |
| kernel/src/libs/futex/syscall/sys_robust_futex.rs | Implements dedicated handlers for set_robust_list and get_robust_list syscalls |
| kernel/src/libs/futex/syscall/sys_futex.rs | Implements dedicated handler for the futex syscall with complete functionality |
| kernel/src/libs/futex/syscall/mod.rs | Module declaration for the new syscall handlers |
| kernel/src/libs/futex/syscall.rs | Removes old futex implementation from the general syscall module |
| kernel/src/driver/base/kobject.rs | Updates lifetime annotations for lock guard methods |
| kernel/src/arch/x86_64/driver/rtc.rs | Updates lifetime annotations for lock guard methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| let reader = UserBufferReader::new( | ||
| utime as *const PosixTimeSpec, | ||
| core::mem::size_of::<PosixTimeSpec>(), | ||
| frame.is_from_user(), |
There was a problem hiding this comment.
The frame.is_from_user() call suggests context-dependent behavior, but this parameter should be validated. Consider adding a comment explaining when this would be false and ensuring the behavior is correct for kernel-space calls.
| let len = Self::len(args); | ||
|
|
||
| // 判断用户空间地址的合法性 | ||
| verify_area(head, core::mem::size_of::<u32>())?; |
There was a problem hiding this comment.
The verification uses size_of::<u32>() but the comment mentions *const PosixRobustListHead. The size validation should match the actual structure being accessed, not a u32.
| verify_area(head, core::mem::size_of::<u32>())?; | |
| verify_area(head, core::mem::size_of::<crate::libs::futex::futex::RobustListHead>())?; |
| verify_area(head, core::mem::size_of::<u32>())?; | ||
| verify_area(len_ptr, core::mem::size_of::<u32>())?; |
There was a problem hiding this comment.
Similar to the set_robust_list handler, the verification uses size_of::<u32>() but should use the correct sizes for PosixRobustListHead pointer and usize respectively.
| verify_area(uaddr, core::mem::size_of::<u32>())?; | ||
| verify_area(uaddr2, core::mem::size_of::<u32>())?; |
There was a problem hiding this comment.
The verification of uaddr2 occurs unconditionally, but some futex operations don't use uaddr2. Consider moving this verification to only the operations that actually use the second address to avoid unnecessary validation.