diff options
author | 2015-09-26 04:03:25 +0000 | |
---|---|---|
committer | 2015-09-26 04:03:25 +0000 | |
commit | 3ab4d7f09786b9aa2f3a3a104afd2c96da1cbeb2 (patch) | |
tree | 83a03b936d2eb1aa5abb69dac8810770bd1fd120 | |
parent | /* NOTREACHED */ after abort() is silly, delete it (diff) | |
download | wireguard-openbsd-3ab4d7f09786b9aa2f3a3a104afd2c96da1cbeb2.tar.xz wireguard-openbsd-3ab4d7f09786b9aa2f3a3a104afd2c96da1cbeb2.zip |
Add a spinout check to the mips64 mutex, to aid debugging.
ok kettenis@
-rw-r--r-- | sys/arch/mips64/mips64/mutex.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sys/arch/mips64/mips64/mutex.c b/sys/arch/mips64/mips64/mutex.c index 1709bff6d1b..6a14441227a 100644 --- a/sys/arch/mips64/mips64/mutex.c +++ b/sys/arch/mips64/mips64/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.2 2015/09/21 06:23:03 kettenis Exp $ */ +/* $OpenBSD: mutex.c,v 1.3 2015/09/26 04:03:25 visa Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -32,6 +32,7 @@ #include <machine/intr.h> +#include <ddb/db_output.h> void __mtx_init(struct mutex *mtx, int wantipl) @@ -42,11 +43,32 @@ __mtx_init(struct mutex *mtx, int wantipl) } #ifdef MULTIPROCESSOR + +#ifdef MP_LOCKDEBUG +#ifndef DDB +#error "MP_LOCKDEBUG requires DDB" +#endif + +/* CPU-dependent timing, needs this to be settable from ddb. */ +extern int __mp_lock_spinout; +#endif + void mtx_enter(struct mutex *mtx) { - while (mtx_enter_try(mtx) == 0) - ; +#ifdef MP_LOCKDEBUG + int ticks = __mp_lock_spinout; +#endif + + while (mtx_enter_try(mtx) == 0) { +#ifdef MP_LOCKDEBUG + if (--ticks == 0) { + db_printf("%s(%p): lock spun out", __func__, mtx); + Debugger(); + ticks = __mp_lock_spinout; + } +#endif + } } int |