Author: markj
Date: Thu Mar 29 17:19:59 2018
New Revision: 331738
URL: https://svnweb.freebsd.org/changeset/base/331738

Log:
  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

Modified:
  head/sys/sys/proc.h

Modified: head/sys/sys/proc.h
==============================================================================
--- head/sys/sys/proc.h Thu Mar 29 15:58:49 2018        (r331737)
+++ head/sys/sys/proc.h Thu Mar 29 17:19:59 2018        (r331738)
@@ -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)
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to