hujun260 opened a new pull request, #17954:
URL: https://github.com/apache/nuttx/pull/17954
## Summary
This PR refactors the loadable binary module cleanup mechanism to remove the
deprecated `group_exitinfo()` function and simplify the module unload
process.
The changes eliminate unnecessary critical section locking in the exec path
and
integrate module unload setup directly into the task initialization sequence.
## Changes
The refactoring involves several related changes across the binary format
and
group management subsystems:
1. **binfmt/binfmt_exec.c** - Simplify exec_internal():
- Remove `irqstate_t flags` variable and related critical section
management
- Remove `enter_critical_section()` and `sched_lock()` calls
- Remove deprecated `group_exitinfo()` call and associated error handling
- Simplify error handling paths by eliminating unnecessary cleanup code
- Result: Cleaner, more straightforward module execution flow
2. **binfmt/binfmt_execmodule.c** - Move unload setup to exec_module():
- Add direct assignment: `tcb->group->tg_bininfo = binp` under
CONFIG_BINFMT_LOADABLE
- Integrates naturally with task activation
- Eliminates need for separate group_exitinfo() function call
- Module information is now directly accessible when task exits
3. **include/nuttx/sched.h** - Remove deprecated interface:
- Remove `group_exitinfo()` function declaration
- Remove associated documentation and comments
4. **sched/group/CMakeLists.txt** and **Make.defs**:
- Remove `group_exitinfo.c` source file from build
- Clean up build configuration
## Benefits
- **Code Simplification**: Eliminates unnecessary critical section overhead
- **Performance**: Removes redundant locking/unlocking operations
- **Maintainability**: Consolidates module initialization logic into single
place
- **Architecture**: Direct assignment pattern is clearer than indirect
registration
- **Robustness**: Reduces complexity reduces potential race conditions
## Testing
Tested on:
- **Platform**: NuttX with loadable module support (CONFIG_BINFMT_LOADABLE=y)
- **Configuration**: ELF and other binary format drivers
- **Test scenarios**:
- Load and execute tasks with loadable modules
- Verify module cleanup occurs at task exit
- Test error paths during module loading/execution
- Concurrent task creation with different module types
- Memory allocation/deallocation for module structures
- **Result**:
- All loadable modules work correctly with simplified mechanism
- No memory leaks during module cleanup
- Performance improved due to reduced critical section overhead
- No functional regressions observed
## Impact
- **Stability**: Maintains module loading/unloading functionality
- **Performance**: Improves performance by eliminating critical section
overhead
- **Compatibility**: No breaking changes to public APIs
- **Code Quality**: Improves code organization and maintainability
- **Architecture**: Aligns module setup with natural task initialization flow
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]