Fix-Point opened a new pull request, #22083: URL: https://github.com/apache/nuttx/pull/22083
## Summary Two commits that follow up the merged spinlock debug-tools series: 1. **Fix the spinlock unlock ordering** (`spinlock: mark spinlock unlocked before releasing the lock`): `spin_unlock()`/`spin_unlock_irqrestore()` cleared the debug holder *after* `spin_unlock_notrace()` had released the lock value. On SMP this leaves a window in which another thread can acquire the lock while `info->holder` still refers to the previous owner, so `spinlock_mark_locked()` misreports a relock (seen as "relocks spinlock" then "waiting for multiple spinlocks" spam in the `wqueue`/HPWORK thread under `CONFIG_SPINLOCK_DEBUG`). The ordering now matches the downstream implementation: mark the spinlock unlocked first, then release the lock value. The recursive rspin path already used the correct order. 2. **Document the spinlock debug tools** (`Documentation: document the spinlock debug tools`): new `Documentation/debugging/spinlockdebug.rst` describing `CONFIG_SPINLOCK_DEBUG` (holder tracking and misuse detection) and `CONFIG_SPINLOCK_BACKTRACE` (holder call stack recording), registered in the debugging index. ## Impact - **User impact**: fixed false relock/multi-wait reports under SMP + `CONFIG_SPINLOCK_DEBUG`; new documentation page. - **Build**: no `CONFIG_*` change; new doc file only for the documentation commit. - **Compatibility**: no API change. - **Documentation**: new `spinlockdebug.rst` (and it is linked from `Documentation/debugging/index.rst`). - **Security**: no new attack surface; the fix removes a spurious panic path under SMP debugging. - **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 every commit (16/16). - Full `ostest` on `qemu-armv7a:smp` with `SPINLOCK_DEBUG=y`: the `wqueue`/HPWORK segment no longer reports relock/multi-wait (previously flooded), `ostest_main: Exiting with status 0`. - Log: `/disk0/gitcode/.review-tmp/tools-unlock-fix-ostest.log` -- 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]
