tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: New diagnostic routine - mutex_ownable()



On 01.05.2017 00:12, coypu%sdf.org@localhost wrote:
> On Sun, Apr 30, 2017 at 08:49:04AM +0800, Paul Goyette wrote:
>> While working on getting the localcount(9) stuff whipped into shape, I ran
>> across a situation where it is desirable to ensure that the current
>> process/lwp does not already own a mutex.
>>
>> We cannot use !mutex_owned() since that doesn't return the desired result
>> for a spin mutex, so I'm proposing to add a new routine called
>> mutex_ownable().  This does nothing in normal kernels, but for LOCKDEBUG
>> kernels it does a mutex_enter() followed immediately by mutex_exit(). If the
>> current process already owns the mutex, the system will panic with a
>> "locking against myself" error; otherwise mutex_ownable() just returns 1,
>> enabling its use as
>>
>> 	KASSERT(mutex_ownable(mtx));
>>
>> Diffs are attached (including man-page and sets-list updates).
>>
>> Comments?  Any reason why this cannot be committed?
> 
> I have an alternate proposal for the same purpose, but not much of a
> suggestion for yours.
> 
> I find it weird to have two names which kinda mean the same thing but
> also don't, and it's not immediate what the difference is, but not sure
> if I can come up with better names.
> 

I agree with this, it's very odd.. Can we just make this mutex_ownable()
a private assert in the localcount .c file? Without pushing it to other
places.


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index