The recursive unlock assumes that the caller owns the lock. This behavior will be checked when RTE_ENABLE_ASSERT is on. There is an additional check for the count which should be positive if no corruption happened.
Signed-off-by: Thomas Monjalon <[email protected]> --- v3: new patch in the series --- lib/eal/include/generic/rte_spinlock.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h index ffdcb8fa3d..e7cd18a8e2 100644 --- a/lib/eal/include/generic/rte_spinlock.h +++ b/lib/eal/include/generic/rte_spinlock.h @@ -21,6 +21,7 @@ #ifdef RTE_FORCE_INTRINSICS #include <rte_common.h> #endif +#include <rte_debug.h> #include <rte_lock_annotations.h> #include <rte_pause.h> #include <rte_stdatomic.h> @@ -245,6 +246,8 @@ static inline void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr) static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis { + RTE_ASSERT(rte_atomic_load_explicit(&slr->owner, rte_memory_order_relaxed) == rte_gettid()); + RTE_ASSERT(slr->count > 0); if (--(slr->count) == 0) { rte_atomic_store_explicit(&slr->owner, -1, rte_memory_order_relaxed); rte_spinlock_unlock(&slr->sl); -- 2.54.0

