Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2002 23:48:12 -0500 (EST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Greg Lehey <grog@FreeBSD.org>
Cc:        current@FreeBSD.ORG, "David O'Brien" <obrien@FreeBSD.ORG>, Matthew Dillon <dillon@apollo.backplane.com>, Jake Burkholder <jake@locore.ca>
Subject:   Re: Patch to improve mutex collision performance
Message-ID:  <XFMail.020220234812.jhb@FreeBSD.org>
In-Reply-To: <20020221111915.N65817@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 21-Feb-02 Greg Lehey wrote:
> On Monday, 18 February 2002 at 15:38:07 -0500, Jake Burkholder wrote:
>> Apparently, On Mon, Feb 18, 2002 at 11:51:44AM -0800,
>>      Matthew Dillon said words to the effect of;
>>>     I'm fairly sure JHB does not have a patch to address this but, please,
>>>     be my guest and check P4.
>>
>> Actually he does.  Maybe you should have checked p4 first yourself.
> 
> Well, maybe, like me, he doesn't know how.  I only recently learnt of
> the existence of this repo, and I still don't know where it is.  It
> certainly wasn't announced on the SMP mailing list.  I've seen a few
> references to p4 there, but no indication of how to access the repo.
> 
>> What John's patch does is spin while the lock owner is running on
>> another cpu.  Spinning while there are no other processes on the run
>> queues as well makes sense but you'll also be doing a lot of
>> acquires and releases of sched_lock.
> 
> I must be misinterpreting this statement.  Under what circumstances do
> you spin?  Yes, I read the "while the owner is running in another
> CPU", but the way I read that, it turns the blocking lock into a spin
> lock.

Only in some cases.  This is the classic way of implementing an adaptive mutex.
You spin if the other thread is actually executing on another CPU (the idea
being it will release the lock soon so you are better off avoiding the context
switch) and block if it is not executing on another CPU (releasing the lock is
already at least one context switch away, so we might as well switch).

> Greg
> --
> See complete headers for address and phone numbers
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-current" in the body of the message

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.020220234812.jhb>