From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 3 19:56:50 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 05CE016A41F; Tue, 3 Jan 2006 19:56:50 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id F23B743D46; Tue, 3 Jan 2006 19:56:45 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.14] (imini.samsco.home [192.168.254.14]) (authenticated bits=0) by pooker.samsco.org (8.13.4/8.13.4) with ESMTP id k03JuhuR074867; Tue, 3 Jan 2006 12:56:44 -0700 (MST) (envelope-from scottl@samsco.org) Message-ID: <43BAD6FB.9090006@samsco.org> Date: Tue, 03 Jan 2006 12:56:43 -0700 From: Scott Long User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.7) Gecko/20050416 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on pooker.samsco.org Cc: freebsd-hackers@freebsd.org, prime Subject: Re: An idea of remove MUTEX_WAKE_ALL X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2006 19:56:50 -0000 Daniel Eischen wrote: > On Tue, 3 Jan 2006, John Baldwin wrote: > > >>On Sunday 01 January 2006 02:21 am, prime wrote: >> >>>Hi hackers, >>> I have an idea about remove the kernel option MUTEX_WAKE_ALL. >>> When we unlock the mutex(in _mtx_unlock_sleep),we can directly >>>give the lock to the first thread waiting on the turnstile.And a >>>thread gets the mutex after he returned from turnstile_wait so he >>>can simply jump out the _obtain_lock loop in _mtx_lock_sleep. >>>This makes a mutex always be owned by a thread when there are threads >>>waiting on the turnstile,so priority inheritance can work now. >>> This idea need only a few changes in kern/kern_mutex.c .But when >>>NO_ADAPTIVE_MUTEXS not set,it makes threads that spinning on other CPU >>>to get the mutex have to spin for a long time,and this makes the short >>>term mutex more expensive(maybe should use spin mutex instead). >>> >>>What do think about the idea? Thanks. >> >>Sun actually found that the performance was better when you did MUTEX_WAKE_ALL >>because once you woke up N threads, if they don't all resume at once then >>they will acquire the lock in sequence and the lock acquires and releaes will >>all be simple ones rather than all being the complicated contested case. >>There are more details in _Solaris Internals_. > > > Yes, but doesn't this partly rely on having the threads spin(*) > for a bit if the current lock owner is running on another CPU? > Do we currently do that? > > (*) No, I am not referring to spin mutexes. > Adaptive mutexes are enabled by default and have been for at least a year. Scott