sched/spinlock: Refactor critical section implementation with rspinlock foundation and SMP optimization#18135
sched/spinlock: Refactor critical section implementation with rspinlock foundation and SMP optimization#18135hujun260 wants to merge 8 commits intoapache:masterfrom
Conversation
4e30316 to
3435fb0
Compare
f2e017a to
027169c
Compare
4b4d2ba to
9bb5a7a
Compare
Remove unnecessary preprocessor #undef directives to improve code clarity and reduce conditional compilation complexity. This cleanup aligns with the refactored critical section interface. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Consolidate architecture-specific context switching by replacing up_switch_context with unified nxsched_switch interface, reducing code duplication and improving scheduler integration consistency across all architecture implementations. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Optimize critical section usage by reducing protection scope to only cover essential operations, improving system responsiveness and reducing interrupt latency while maintaining synchronization safety. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Refactor critical section implementation to use rspinlock_t as the foundation, providing consistent synchronization semantics across SMP and non-SMP configurations with improved nesting support and reduced overhead. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Clean up and remove the deprecated irqcount field from task structures as it is no longer used by the refactored critical section implementation. This simplifies the TCB structure and reduces memory overhead. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Inline enter_critical_section function calls in performance-critical paths to reduce function call overhead while maintaining consistent semantics, improving overall system latency and responsiveness in real-time scenarios. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Optimize critical section implementation for non-SMP configurations by directly using up_irq_save/restore instead of rspinlock operations, reducing context switch overhead while maintaining compatibility with SMP code paths. Signed-off-by: hujun5 <hujun5@xiaomi.com>
9bb5a7a to
e10bf58
Compare
jerpelea
left a comment
There was a problem hiding this comment.
please split the PR in multple PRs that can be understood and reviewed
1.Critical Section Refactoring - Standardize interface naming, remove redundant declarations, and consolidate SMP/non-SMP code paths for improved maintainability and reduced compilation complexity.
2.Performance Optimization - Optimize critical section scope by narrowing protection windows to essential operations only, reducing interrupt latency and improving system responsiveness.
3.Architecture Consolidation - Replace up_switch_context with unified nxsched_switch interface across all architecture implementations for improved consistency and reduced code duplication.
4.Cleanup and Removal - Remove deprecated irqcount field and unnecessary preprocessor directives, simplifying the TCB structure and reducing memory overhead.
Add #include <nuttx/spinlock.h> to source files across avr, mips, renesas, and sparc architectures that use irqstate_t and critical section functions but were missing the required header file. Signed-off-by: hujun5 <hujun5@xiaomi.com>
e10bf58 to
b94ef26
Compare
Summary
This pull request refactors the NuttX critical section implementation to use rspinlock_t as the unified foundation while optimizing performance for both SMP and non-SMP configurations. The series introduces enhanced spinlock operations, consolidates the scheduler interface, and eliminates deprecated synchronization mechanisms.
should merge after apache/nuttx-apps#3375
Changes Made
Critical Section Refactoring - Standardize interface naming, remove redundant declarations, and consolidate SMP/non-SMP code paths for improved maintainability and reduced compilation complexity.
Performance Optimization - Optimize critical section scope by narrowing protection windows to essential operations only, reducing interrupt latency and improving system responsiveness.
Architecture Consolidation - Replace
up_switch_contextwith unifiednxsched_switchinterface across all architecture implementations for improved consistency and reduced code duplication.Cleanup and Removal - Remove deprecated
irqcountfield and unnecessary preprocessor directives, simplifying the TCB structure and reducing memory overhead.TEST
OSTEST pass