Date: Tue, 16 Mar 2004 10:09:48 -0500 From: John Baldwin <john@baldwin.cx> To: arch@FreeBSD.org Cc: Seigo Tanimura <tanimura@tanimura.dyndns.org> Subject: Re: Is MTX_CONTESTED evil? Message-ID: <200403161009.48938.john@baldwin.cx> In-Reply-To: <200403160519.i2G5J0V6023193@urban> References: <200403160519.i2G5J0V6023193@urban>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 16 March 2004 12:19 am, Seigo Tanimura wrote: > _mtx_unlock_sleep() currently wakes up only one thread being blocked, > and leaves MTX_CONTESTED on a mutex. According to Solaris Internals, > that strategy adds an overhead to check for MTX_CONTESTED on a mutex, > even though it is not held by any thread. The thread waken up cannot > grab the mutex immediately by _obtain_lock() and have to go through > _mtx_lock_sleep(). The penalty tends to be large for a mutex with a > high contention, and we have at least one of such a mutex - Giant. > > What would it be like if we axed MTX_CONTEST and let > _mtx_unlock_sleep() wake up all of the blocked threads? We wouldn't be able to axe MTX_CONTEST. We also use it to determine on unlock if we can unlock easily or if we have waiters that we need to awake. The only way we might be able to axe MTX_CONTEST would be to penalize every unlock operation requiring a turnstile lookup (spin lock acquire/release + hash table lookup) even unlocks of an uncontested mutex. However, what I think you want to do is get rid of the mtx_lock == MTX_CONTESTED case and use turnstile_wakeup() rather than turnstile_signal()? Is that what you are asking? That is something we can try at some point in the future, but we would need to benchmark both ways. What we might can do is add a kernel option MUTEX_WAKE_ALL or some such that uses the Solaris behavior. Having it be an option like ADAPTIVE_MUTEXES makes it easier to benchmark both cases. -- John Baldwin <john@baldwin.cx> <>< http://www.baldwin.cx/~john/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403161009.48938.john>