cvs commit: src/sys/sys mutex.h

John Baldwin jhb at FreeBSD.org
Thu Oct 16 09:45:37 PDT 2003


On 15-Oct-2003 Jeff Roberson wrote:
> On Tue, 14 Oct 2003, John Baldwin wrote:
>> On 14-Oct-2003 Jeff Roberson wrote:
>> > I know it is racy in most contexts.  I use it to check to see if a thread
>> > on the runq owns giant.  Since I have the sched lock it isn't racy but
>> > even if it was it wouldn't matter in this case.
>>
>> sched lock doesn't keep it from being racy.  Uncontested acquire and
>> releases don't go anywhere near sched lock.  Are you checking a
>> non-curthread thread pointer?  Maybe you could just do it for curthread
>> and that would be enough for your heuristic, i.e.
> 
> Yes it does.  I'm checking a thread that is on the run queue but not
> running.  If it holds giant it will hold giant until I drop the sched lock
> and schedule it to run.

Ah, ok.

>>
>>         if (thread == curthread && mtx_owned(&Giant)) {
>>                 ...
>>         }
>>
>> I'm just worried that if this is there someone is going to use it. :(
> 
> Yes, I see, this is a valid concern.  I originally had it in sched_ule.c
> only but decided that it was ugly to do so.  I could move it back or
> manually code the check there.

I would prefer that then.  This is really only a "temporary" heuristic
while Giant exists anyways.

-- 

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


More information about the cvs-src mailing list