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, coypu%sdf.org@localhost wrote:

I feel like we mostly care about adaptive mutexes, how about this
alternate suggestion?

mutex_adaptive_owned(kmutex_t * mtx)
{
	if (mtx == NULL)
		return 0;

	KASSERT(MUTEX_ADAPTIVE_P(mtx));
	return MUTEX_OWNER(mtx->mtx_owner) == (uintptr_t)curlwp;
}

It seems reasonable, as a general case, if the caller knows that the
mutex is indeed adaptive.  (But wouldn't the NULL check for the mtx
be better as a KASSERT rather than returning "not-held"?)

For my use-case, it is unknown whether the caller-provided mutex is
adaptive vs spin.  I would expect it to be adaptive, and indeed, for
all currently-planned uses of localcount(9), this would be an adaptive
mutex.  But there is no reason for the localcount(9) stuff to require
an adaptive mutex here.

Thus, I would not be able to use your alternate suggestion.



+------------------+--------------------------+----------------------------+
| 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