Skip to content

apps: Add spinlock.h include for critical section support - #3375

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
hujun260:apache_remove_csection
Jan 26, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
hujun260:apache_remove_csection

Conversation

@hujun260

@hujun260 hujun260 commented Jan 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request adds necessary header includes to NuttX applications to support inlined critical section operations. The changes enable the kernel-side optimization of enter_critical_section by providing access to spinlock definitions in application code paths that require fine-grained synchronization.

should merge before apache/nuttx#18135

Changes Made

  1. benchmarks/osperf/osperf.c - Added #include <nuttx/spinlock.h> to support performance measurement of critical section operations with inlining capability.

  2. testing/ostest/wdog.c - Added #include <nuttx/spinlock.h> to enable watchdog timer tests to access inlined synchronization primitives.

Related Issues

This commit is part of the critical section refactoring series in NuttX kernel that consolidates synchronization mechanisms using rspinlock_t foundation.

Impact

  • Compatibility: Fully backward compatible with existing applications
  • Performance: Enables kernel-side inlining optimizations for applications using critical sections
  • Build: No changes to build system or configuration
  • API: No public API changes

Files Modified

Applications Layer:

  • benchmarks/osperf/osperf.c - Performance benchmark tool
  • testing/ostest/wdog.c - Watchdog timer tests

Testing

  1. Build Test: Verify applications build successfully with new includes
  2. Functionality Test: Run osperf and ostest to confirm normal operation
  3. Performance Test: Verify osperf measurements remain consistent
  4. Integration Test: Test with critical section refactoring (NuttX kernel changes)

Verification Checklist

  • Code builds without warnings
  • Includes are necessary and used by kernel optimizations
  • No circular dependencies introduced
  • Existing tests pass
  • Applications run correctly
  • Performance metrics remain stable

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @hujun260 + for perfect PR description :-)

Looks like some more work is needed.. build errors!

Could you please also fix comment typo in benchmarks/osperf/osperf.c:133 to fix spellcheck complain ?

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 <[email protected]>

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @hujun260 :-)

@xiaoxiang781216
xiaoxiang781216 merged commit d1de009 into apache:master Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants