Date: Wed, 21 Jan 2009 13:15:20 -0500 From: Steve Sears <sjs@netapp.com> To: <freebsd-arch@freebsd.org> Subject: mtx_trylock and td_locks Message-ID: <C59CD068.30508%sjs@netapp.com>
next in thread | raw e-mail | index | archive | help
I just discovered something that I would think would be documented somewhere, but my best google'ing turns up nary a mention of it. In debug builds thread->td_locks is incremented and decremented with mtx_lock, mtx_trylock, and mtx_unlock. However, if LOCK_DEBUG = 0 then mtx_lock() and mtx_unlock become inline routines that don't modify thread->td_locks. mtx_trylock() doesn't have a non-debug inline version, so it still increments the thread value. This means mtx_trylock() should not be used with mtx_unlock(), but rather should always be paired with mtx_unlock_flags() to ensure thread->td_locks receives proper accounting. Is this by design? Or a bug? mtx_trylock is not heavily used, so it's easy to understand that it may not have had as much attention as the other locking routines. Thanks, -Steve
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C59CD068.30508%sjs>