From 15969dfa68e37d305dd11968e20ca0a425d2092a Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Tue, 28 Sep 2010 20:27:57 +0000 Subject: Implement a per-cpu held mutex counter if DIAGNOSTIC on all non-x86 platforms, to complete matthew@'s commit of a few days ago, and drop __HAVE_CPU_MUTEX_LEVEL define. With help from, and ok deraadt@. --- sys/arch/octeon/octeon/mutex.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sys/arch/octeon') diff --git a/sys/arch/octeon/octeon/mutex.c b/sys/arch/octeon/octeon/mutex.c index e85f65a96b3..4135e53139f 100644 --- a/sys/arch/octeon/octeon/mutex.c +++ b/sys/arch/octeon/octeon/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.1 2010/09/20 06:32:30 syuu Exp $ */ +/* $OpenBSD: mutex.c,v 1.2 2010/09/28 20:27:55 miod Exp $ */ /* * Copyright (c) 2004 Artur Grabowski @@ -76,6 +76,9 @@ mtx_enter(struct mutex *mtx) if (mtx->mtx_wantipl != IPL_NONE) mtx->mtx_oldipl = s; mtx->mtx_owner = curcpu(); +#ifdef DIAGNOSTIC + curcpu()->ci_mutex_level++; +#endif return; } if (mtx->mtx_wantipl != IPL_NONE) @@ -96,6 +99,9 @@ mtx_enter_try(struct mutex *mtx) if (mtx->mtx_wantipl != IPL_NONE) mtx->mtx_oldipl = s; mtx->mtx_owner = curcpu(); +#ifdef DIAGNOSTIC + curcpu()->ci_mutex_level++; +#endif return 1; } if (mtx->mtx_wantipl != IPL_NONE) @@ -107,6 +113,9 @@ void mtx_leave(struct mutex *mtx) { MUTEX_ASSERT_LOCKED(mtx); +#ifdef DIAGNOSTIC + curcpu()->ci_mutex_level--; +#endif mtx->mtx_lock = 0; if (mtx->mtx_wantipl != IPL_NONE) splx(mtx->mtx_oldipl); -- cgit v1.2.3