tech-kern archive

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

Re: New diagnostic routine - mutex_ownable()



On Mon, May 01, 2017 at 06:59:45PM +0800, Paul Goyette wrote:
> On Mon, 1 May 2017, Paul Goyette wrote:
> 
> > > even when using expensive checks, it's best not to make them
> > > more expensive than is really necessary.
> > 
> > I understand and agree.
> > 
> > From my reading of sys/lockdebug.h, kern/subr_lockdebug.c and
> > kern/kern_mutex.c it would appear that mutex_ownable() can become
> > 
> > 	int
> > 	mutex_ownable(kmutex_t mtx)
> > 	{
> > 
> > 		#ifdef DEBUG
> > 		MUTEX_WANTLOCK(mtx)
> > 		#endif
> > 		return 1;
> > 	}
> 
> Taylor pointed out privately that this won't quite work, since
> lockdebug_wantlock() currently updates ld->ld_{ex,sh}want counters.
> 
> The attached diffs get around this by making the "shared" argument to
> lockdebug_wantlock() have three values instead of two.  A positive value now
> refers to shwant, a zero value to exwant, and a negative value means don't
> touch either counter!  The new MUTEX_TESTLOCK() macro uses -1 for the shared
> argument.
> 
> Diffs attached (including man-page and sets-lists updates) - please let me
> know if this is acceptable.

the man page still says mutex_ownable() acquires the mutex,
otherwise it looks fine.

thanks,
-Chuck


Home | Main Index | Thread Index | Old Index