Have TD_LOCKS_DEC() assert that td_locks is positive.

This makes it easier to catch lock accounting bugs, since the problem
is otherwise only detected upon a return to user mode (or never, for
kernel threads).

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D14896
This commit is contained in:
Mark Johnston 2018-03-29 17:19:59 +00:00
parent ac28199cca
commit af00071dba

View File

@ -381,7 +381,10 @@ do { \
} while (0)
#define TD_LOCKS_INC(td) ((td)->td_locks++)
#define TD_LOCKS_DEC(td) ((td)->td_locks--)
#define TD_LOCKS_DEC(td) do { \
KASSERT((td)->td_locks > 0, ("thread %p owns no locks", (td))); \
(td)->td_locks--; \
} while (0)
#else
#define THREAD_LOCKPTR_ASSERT(td, lock)