From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 3 18:06:02 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 4393216A41F for ; Tue, 3 Jan 2006 18:06:02 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1D81643D53 for ; Tue, 3 Jan 2006 18:05:45 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 5182136 for multiple; Tue, 03 Jan 2006 13:03:50 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k03I5bO1094388; Tue, 3 Jan 2006 13:05:38 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 3 Jan 2006 12:52:41 -0500 User-Agent: KMail/1.8.2 References: <1fa17f810512312321n619291a0l59473e11af5cb147@mail.gmail.com> In-Reply-To: <1fa17f810512312321n619291a0l59473e11af5cb147@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601031252.42657.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1225/Mon Jan 2 12:54:07 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: 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 18:06:02 -0000 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_. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org