Fix-Point opened a new pull request, #22243:
URL: https://github.com/apache/nuttx/pull/22243

   ## Summary
   
   `spin_unlock()` / `spin_unlock_irqrestore()` cleared the spinlock debug
   holder (*after* releasing the lock value). On SMP this leaves a window in
   which another thread may acquire the lock (observing ``lock`` as free)
   while ``info->holder`` still refers to the previous owner, so
   ``spinlock_mark_locked()`` misreports a relock — seen as
   "Detect thread(...) relocks spinlock(...)" then "waiting for multiple
   spinlocks" spam in the ``wqueue``/HPWORK worker under
   ``CONFIG_SPINLOCK_DEBUG``.
   
   Mark the spinlock as unlocked *before* releasing the lock value, matching
   the reference implementation ordering. The recursive rspin path already
   used the correct order. Document the ordering requirement in the new
   spinlock debug page.
   
   2 commits:
   1. `spinlock: mark spinlock unlocked before releasing the lock`
   2. `Documentation: document the spinlock debug tools` (spinlock debug
      page; the unlock-ordering section describes this requirement)
   
   ## Impact
   
   - **User impact**: removes the false relock/multi-wait reports under SMP +
     ``CONFIG_SPINLOCK_DEBUG``; documents the spinlock debug tools.
   - **Build**: no ``CONFIG_*`` change.
   - **Compatibility**: no API change; only the ordering inside the unlock
     helpers.
   - **Documentation**: new ``Documentation/debugging/spinlockdebug.rst``.
   - **Security**: no new attack surface.
   - **Hardware**: none.
   
   ## Testing
   
   Build Host: Linux x86_64
   
   Boards/Configurations:
   - `qemu-armv7a:smp` with ``CONFIG_SPINLOCK_DEBUG=y``,
     ``CONFIG_TESTING_OSTEST=y``
   
   Verification:
   - `tools/checkpatch.sh` green on both commits.
   - Build ``qemu-armv7a:smp`` with ``CONFIG_SPINLOCK_DEBUG=y``: PASS.
   - (Full ``ostest`` with the same unlocks was run in the source series:
     ``ostest_main: Exiting with status 0``, no relock reports.)
   


-- 
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]

Reply via email to