diff options
author | 2017-09-11 09:52:15 +0000 | |
---|---|---|
committer | 2017-09-11 09:52:15 +0000 | |
commit | 9dba4f4e8f70ecc766c09be3f3a5aa5cbdb8db7b (patch) | |
tree | babd340c873dc1ca91e782c708d89a5247f7a2c5 /sys | |
parent | Mention that filter is a format. (diff) | |
download | wireguard-openbsd-9dba4f4e8f70ecc766c09be3f3a5aa5cbdb8db7b.tar.xz wireguard-openbsd-9dba4f4e8f70ecc766c09be3f3a5aa5cbdb8db7b.zip |
Sync alpha/mips64/powerpc mutex implementations.
No functionnal change.
ok visa@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/alpha/alpha/mutex.c | 29 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/mutex.c | 11 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/mutex.c | 14 |
3 files changed, 40 insertions, 14 deletions
diff --git a/sys/arch/alpha/alpha/mutex.c b/sys/arch/alpha/alpha/mutex.c index 04dbf9cdfd3..c8acedb786e 100644 --- a/sys/arch/alpha/alpha/mutex.c +++ b/sys/arch/alpha/alpha/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.18 2017/05/29 14:19:49 mpi Exp $ */ +/* $OpenBSD: mutex.c,v 1.19 2017/09/11 09:52:15 mpi Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -39,16 +39,38 @@ void __mtx_init(struct mutex *mtx, int wantipl) { mtx->mtx_owner = NULL; - mtx->mtx_oldipl = IPL_NONE; mtx->mtx_wantipl = wantipl; + mtx->mtx_oldipl = IPL_NONE; } #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 nticks = __mp_lock_spinout; +#endif + + while (__mtx_enter_try(mtx) == 0) { CPU_BUSY_CYCLE(); + +#ifdef MP_LOCKDEBUG + if (--nticks == 0) { + db_printf("%s: %p lock spun out", __func__, mtx); + db_enter(); + nticks = __mp_lock_spinout; + } +#endif + } } int @@ -90,6 +112,7 @@ __mtx_enter(struct mutex *mtx) if (__predict_false(mtx->mtx_owner == ci)) panic("mtx %p: locking against myself", mtx); #endif + if (mtx->mtx_wantipl != IPL_NONE) mtx->mtx_oldipl = splraise(mtx->mtx_wantipl); diff --git a/sys/arch/mips64/mips64/mutex.c b/sys/arch/mips64/mips64/mutex.c index 0cd640cc914..69d22a0b30e 100644 --- a/sys/arch/mips64/mips64/mutex.c +++ b/sys/arch/mips64/mips64/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.6 2017/04/30 16:45:45 mpi Exp $ */ +/* $OpenBSD: mutex.c,v 1.7 2017/09/11 09:52:15 mpi Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -43,7 +43,6 @@ __mtx_init(struct mutex *mtx, int wantipl) } #ifdef MULTIPROCESSOR - #ifdef MP_LOCKDEBUG #ifndef DDB #error "MP_LOCKDEBUG requires DDB" @@ -61,9 +60,11 @@ __mtx_enter(struct mutex *mtx) #endif while (__mtx_enter_try(mtx) == 0) { + CPU_BUSY_CYCLE(); + #ifdef MP_LOCKDEBUG if (--nticks == 0) { - db_printf("%s(%p): lock spun out", __func__, mtx); + db_printf("%s: %p lock spun out", __func__, mtx); db_enter(); nticks = __mp_lock_spinout; } @@ -76,8 +77,8 @@ __mtx_enter_try(struct mutex *mtx) { struct cpu_info *owner, *ci = curcpu(); int s; - - if (mtx->mtx_wantipl != IPL_NONE) + + if (mtx->mtx_wantipl != IPL_NONE) s = splraise(mtx->mtx_wantipl); owner = atomic_cas_ptr(&mtx->mtx_owner, NULL, ci); diff --git a/sys/arch/powerpc/powerpc/mutex.c b/sys/arch/powerpc/powerpc/mutex.c index 5a6a8012931..277647f9142 100644 --- a/sys/arch/powerpc/powerpc/mutex.c +++ b/sys/arch/powerpc/powerpc/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.6 2017/05/29 14:19:50 mpi Exp $ */ +/* $OpenBSD: mutex.c,v 1.7 2017/09/11 09:52:15 mpi Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -36,15 +36,15 @@ #include <ddb/db_output.h> void -__mtx_init(struct mutex *mtx, int ipl) +__mtx_init(struct mutex *mtx, int wantipl) { mtx->mtx_owner = NULL; - mtx->mtx_wantipl = ipl; + mtx->mtx_wantipl = wantipl; mtx->mtx_oldipl = IPL_NONE; } #ifdef MULTIPROCESSOR -#if defined(MP_LOCKDEBUG) +#ifdef MP_LOCKDEBUG #ifndef DDB #error "MP_LOCKDEBUG requires DDB" #endif @@ -56,17 +56,18 @@ extern int __mp_lock_spinout; void __mtx_enter(struct mutex *mtx) { -#if defined(MP_LOCKDEBUG) +#ifdef MP_LOCKDEBUG int nticks = __mp_lock_spinout; #endif while (__mtx_enter_try(mtx) == 0) { CPU_BUSY_CYCLE(); -#if defined(MP_LOCKDEBUG) +#ifdef MP_LOCKDEBUG if (--nticks == 0) { db_printf("%s: %p lock spun out", __func__, mtx); db_enter(); + nticks = __mp_lock_spinout; } #endif } @@ -111,6 +112,7 @@ __mtx_enter(struct mutex *mtx) if (__predict_false(mtx->mtx_owner == ci)) panic("mtx %p: locking against myself", mtx); #endif + if (mtx->mtx_wantipl != IPL_NONE) mtx->mtx_oldipl = splraise(mtx->mtx_wantipl); |