tech-kern archive

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

Re: New diagnostic routine - mutex_ownable()



On Sun, 30 Apr 2017, Chuck Silvers wrote:

<snip>

Hence I suggest that mutex_ownable be limited to KDASSERT -- so that
you get it only if you combine DEBUG (expensive consistency checks)
and LOCKDEBUG (locking bug detection).

Yes, I agree. I've already made the KDASSERT() change in my local sources.

this is still much more expensive than necessary.
it would be easy to add a new lockdebug interface to perform this check
rather than using mutex_enter() to get the recursion-check part of
lockdebug_wantlock() as a side-effect, so please do that.

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;
	}

This would provide the locking-against-myself recursion check, as well as the sleep-vs-spl check.

Would this be acceptable? Would it be proper to include this in kern/kern_mutex.c, or would it be best to simply code it in-line at point-of-use?


+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+


Home | Main Index | Thread Index | Old Index