On Thu, Jan 12, 2017 at 01:31:17AM +0000, Taylor R Campbell wrote: > Currently, there's a long comment in src/sys/sys/mutex.h which reads in > part: > > ... > * > * MUTEX_OWNER(owner) > * Returns the owner of the adaptive mutex (LWP address). > * > * MUTEX_OWNED(owner) > * Returns non-zero if an adaptive mutex is currently > * held by an LWP. > * > ... > > It seems to me that the arguments of these two macros should be (mtx) > rather than (owner). > > Am I misunderstanding something? Or should I fix it? :) > > Actually, `owner' is correct. Specifically, these pick apart the bits > of the struct kmutex::mtx_owner field. Some of the bits make up a > pointer, either struct lwp * or struct cpu_info *, but in an aligned > pointer some bits are always zero, and those bits are used for other > purposes. See, e.g., the definition of mutex_owned in kern_mutex.c.
Maybe the naming should be adjusted to be less confusing :-) -- David A. Holland dholl...@netbsd.org