diff options
author | 2017-11-19 13:18:13 +0000 | |
---|---|---|
committer | 2017-11-19 13:18:13 +0000 | |
commit | 7e85837ac0f99dec74e29b7db5668b6dc36fe013 (patch) | |
tree | bb781543bfbfb6edc1660116933e7dc12e3a87a0 | |
parent | add growfs(8) to ramdisk (diff) | |
download | wireguard-openbsd-7e85837ac0f99dec74e29b7db5668b6dc36fe013.tar.xz wireguard-openbsd-7e85837ac0f99dec74e29b7db5668b6dc36fe013.zip |
Remove lock_machdep.c from amd64, i386, mips64 and sparc64.
The architectures have been using the MI mplock for a while.
OK deraadt@, kettenis@
-rw-r--r-- | sys/arch/amd64/amd64/lock_machdep.c | 174 | ||||
-rw-r--r-- | sys/arch/i386/i386/lock_machdep.c | 188 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/lock_machdep.c | 169 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/lock_machdep.c | 140 |
4 files changed, 0 insertions, 671 deletions
diff --git a/sys/arch/amd64/amd64/lock_machdep.c b/sys/arch/amd64/amd64/lock_machdep.c deleted file mode 100644 index c3fd540b5a4..00000000000 --- a/sys/arch/amd64/amd64/lock_machdep.c +++ /dev/null @@ -1,174 +0,0 @@ -/* $OpenBSD: lock_machdep.c,v 1.16 2017/05/29 14:19:49 mpi Exp $ */ - -/* - * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/atomic.h> -#include <sys/witness.h> -#include <sys/_lock.h> - -#include <machine/cpu.h> -#include <machine/cpufunc.h> - -#include <ddb/db_output.h> - -void -___mp_lock_init(struct __mp_lock *mpl) -{ - memset(mpl->mpl_cpus, 0, sizeof(mpl->mpl_cpus)); - mpl->mpl_users = 0; - mpl->mpl_ticket = 1; -} - -#if defined(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 - -static __inline void -__mp_lock_spin(struct __mp_lock *mpl, u_int me) -{ -#ifndef MP_LOCKDEBUG - while (mpl->mpl_ticket != me) - CPU_BUSY_CYCLE(); -#else - int nticks = __mp_lock_spinout; - - while (mpl->mpl_ticket != me) { - CPU_BUSY_CYCLE(); - - if (--nticks <= 0) { - db_printf("__mp_lock(%p): lock spun out", mpl); - db_enter(); - nticks = __mp_lock_spinout; - } - } -#endif -} - -void -___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - unsigned long s; -#ifdef WITNESS - int lock_held; - - lock_held = __mp_lock_held(mpl); - if (!lock_held) - WITNESS_CHECKORDER(&mpl->mpl_lock_obj, - LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL); -#endif - - s = intr_disable(); - if (cpu->mplc_depth++ == 0) - cpu->mplc_ticket = atomic_inc_int_nv(&mpl->mpl_users); - intr_restore(s); - - __mp_lock_spin(mpl, cpu->mplc_ticket); - - WITNESS_LOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); -} - -void -___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - unsigned long s; - -#ifdef MP_LOCKDEBUG - if (!__mp_lock_held(mpl)) { - db_printf("__mp_unlock(%p): not held lock\n", mpl); - db_enter(); - } -#endif - - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); - - s = intr_disable(); - if (--cpu->mplc_depth == 0) - mpl->mpl_ticket++; - intr_restore(s); -} - -int -___mp_release_all(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - unsigned long s; - int rv; -#ifdef WITNESS - int i; -#endif - - s = intr_disable(); - rv = cpu->mplc_depth; -#ifdef WITNESS - for (i = 0; i < rv; i++) - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); -#endif - cpu->mplc_depth = 0; - mpl->mpl_ticket++; - intr_restore(s); - - return (rv); -} - -int -___mp_release_all_but_one(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - int rv = cpu->mplc_depth - 1; -#ifdef WITNESS - int i; - - for (i = 0; i < rv; i++) - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); -#endif - -#ifdef MP_LOCKDEBUG - if (!__mp_lock_held(mpl)) { - db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl); - db_enter(); - } -#endif - - cpu->mplc_depth = 1; - - return (rv); -} - -void -___mp_acquire_count(struct __mp_lock *mpl, int count LOCK_FL_VARS) -{ - while (count--) - ___mp_lock(mpl LOCK_FL_ARGS); -} - -int -__mp_lock_held(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - - return (cpu->mplc_ticket == mpl->mpl_ticket && cpu->mplc_depth > 0); -} diff --git a/sys/arch/i386/i386/lock_machdep.c b/sys/arch/i386/i386/lock_machdep.c deleted file mode 100644 index 0274c6f5461..00000000000 --- a/sys/arch/i386/i386/lock_machdep.c +++ /dev/null @@ -1,188 +0,0 @@ -/* $OpenBSD: lock_machdep.c,v 1.25 2017/05/29 14:19:49 mpi Exp $ */ -/* $NetBSD: lock_machdep.c,v 1.1.2.3 2000/05/03 14:40:30 sommerfeld Exp $ */ - -/*- - * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Machine-dependent spin lock operations. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/atomic.h> -#include <sys/witness.h> -#include <sys/_lock.h> - -#include <machine/cpu.h> -#include <machine/cpufunc.h> - -#include <ddb/db_output.h> - -#ifdef MULTIPROCESSOR - void -___mp_lock_init(struct __mp_lock *mpl) -{ - memset(mpl->mpl_cpus, 0, sizeof(mpl->mpl_cpus)); - mpl->mpl_users = 0; - mpl->mpl_ticket = 1; -} - -#if defined(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 - -static __inline void -__mp_lock_spin(struct __mp_lock *mpl, u_int me) -{ -#ifndef MP_LOCKDEBUG - while (mpl->mpl_ticket != me) - CPU_BUSY_CYCLE(); -#else - int nticks = __mp_lock_spinout; - - while (mpl->mpl_ticket != me) { - CPU_BUSY_CYCLE(); - - if (--nticks <= 0) { - db_printf("__mp_lock(%p): lock spun out", mpl); - db_enter(); - nticks = __mp_lock_spinout; - } - } -#endif -} - -void -___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - unsigned long s; -#ifdef WITNESS - int lock_held; - - lock_held = __mp_lock_held(mpl); - if (!lock_held) - WITNESS_CHECKORDER(&mpl->mpl_lock_obj, - LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL); -#endif - - s = intr_disable(); - if (cpu->mplc_depth++ == 0) - cpu->mplc_ticket = atomic_inc_int_nv(&mpl->mpl_users); - intr_restore(s); - - __mp_lock_spin(mpl, cpu->mplc_ticket); - - WITNESS_LOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); -} - -void -___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - unsigned long s; - -#ifdef MP_LOCKDEBUG - if (!__mp_lock_held(mpl)) { - db_printf("__mp_unlock(%p): not held lock\n", mpl); - db_enter(); - } -#endif - - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); - - s = intr_disable(); - if (--cpu->mplc_depth == 0) - mpl->mpl_ticket++; - intr_restore(s); -} - -int -___mp_release_all(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - unsigned long s; - int rv; -#ifdef WITNESS - int i; -#endif - - s = intr_disable(); - rv = cpu->mplc_depth; -#ifdef WITNESS - for (i = 0; i < rv; i++) - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); -#endif - cpu->mplc_depth = 0; - mpl->mpl_ticket++; - intr_restore(s); - - return (rv); -} - -int -___mp_release_all_but_one(struct __mp_lock *mpl LOCK_FL_VARS) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - int rv = cpu->mplc_depth - 1; -#ifdef WITNESS - int i; - - for (i = 0; i < rv; i++) - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line); -#endif - - cpu->mplc_depth = 1; - - return (rv); -} - -void -___mp_acquire_count(struct __mp_lock *mpl, int count LOCK_FL_VARS) -{ - while (count--) - ___mp_lock(mpl LOCK_FL_ARGS); -} - -int -__mp_lock_held(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - - return (cpu->mplc_ticket == mpl->mpl_ticket && cpu->mplc_depth > 0); -} - -#endif diff --git a/sys/arch/mips64/mips64/lock_machdep.c b/sys/arch/mips64/mips64/lock_machdep.c deleted file mode 100644 index 4af2c02eeda..00000000000 --- a/sys/arch/mips64/mips64/lock_machdep.c +++ /dev/null @@ -1,169 +0,0 @@ -/* $OpenBSD: lock_machdep.c,v 1.5 2017/05/29 14:19:50 mpi Exp $ */ - -/* - * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/atomic.h> - -#include <machine/cpu.h> - -#include <ddb/db_output.h> - -void -__mp_lock_init(struct __mp_lock *lock) -{ - lock->mpl_cpu = NULL; - lock->mpl_count = 0; -} - -#if defined(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 - -static __inline void -__mp_lock_spin(struct __mp_lock *mpl) -{ -#ifndef MP_LOCKDEBUG - while (mpl->mpl_count != 0) - CPU_BUSY_CYCLE(); -#else - int nticks = __mp_lock_spinout; - - while (mpl->mpl_count != 0 && --nticks > 0) - CPU_BUSY_CYCLE(); - - if (nticks == 0) { - db_printf("__mp_lock(%p): lock spun out", mpl); - db_enter(); - } -#endif -} - -void -__mp_lock(struct __mp_lock *mpl) -{ - register_t sr; - struct cpu_info *ci = curcpu(); - - /* - * Please notice that mpl_count gets incremented twice for the - * first lock. This is on purpose. The way we release the lock - * in mp_unlock is to decrement the mpl_count and then check if - * the lock should be released. Since mpl_count is what we're - * spinning on, decrementing it in mpl_unlock to 0 means that - * we can't clear mpl_cpu, because we're no longer holding the - * lock. In theory mpl_cpu doesn't need to be cleared, but it's - * safer to clear it and besides, setting mpl_count to 2 on the - * first lock makes most of this code much simpler. - */ - while (1) { - sr = disableintr(); - if (atomic_cas_ulong(&mpl->mpl_count, 0, 1) == 0) { - mips_sync(); - mpl->mpl_cpu = ci; - } - - if (mpl->mpl_cpu == ci) { - mpl->mpl_count++; - setsr(sr); - break; - } - setsr(sr); - - __mp_lock_spin(mpl); - } -} - -void -__mp_unlock(struct __mp_lock *mpl) -{ - register_t sr; - -#ifdef MP_LOCKDEBUG - if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_unlock(%p): not held lock\n", mpl); - db_enter(); - } -#endif - - sr = disableintr(); - if (--mpl->mpl_count == 1) { - mpl->mpl_cpu = NULL; - mips_sync(); - mpl->mpl_count = 0; - } - - setsr(sr); -} - -int -__mp_release_all(struct __mp_lock *mpl) -{ - int rv = mpl->mpl_count - 1; - register_t sr; - -#ifdef MP_LOCKDEBUG - if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all(%p): not held lock\n", mpl); - db_enter(); - } -#endif - - sr = disableintr(); - mpl->mpl_cpu = NULL; - mips_sync(); - mpl->mpl_count = 0; - setsr(sr); - - return (rv); -} - -int -__mp_release_all_but_one(struct __mp_lock *mpl) -{ - int rv = mpl->mpl_count - 2; -#ifdef MP_LOCKDEBUG - if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl); - db_enter(); - } -#endif - - mpl->mpl_count = 2; - - return (rv); -} - -void -__mp_acquire_count(struct __mp_lock *mpl, int count) -{ - while (count--) - __mp_lock(mpl); -} - -int -__mp_lock_held(struct __mp_lock *mpl) -{ - return mpl->mpl_cpu == curcpu(); -} diff --git a/sys/arch/sparc64/sparc64/lock_machdep.c b/sys/arch/sparc64/sparc64/lock_machdep.c deleted file mode 100644 index bd55818c6e4..00000000000 --- a/sys/arch/sparc64/sparc64/lock_machdep.c +++ /dev/null @@ -1,140 +0,0 @@ -/* $OpenBSD: lock_machdep.c,v 1.17 2017/05/29 14:19:50 mpi Exp $ */ - -/* - * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/atomic.h> -#include <sys/param.h> -#include <sys/systm.h> - -#include <machine/cpu.h> -#include <machine/psl.h> - -#include <ddb/db_output.h> - -void -__mp_lock_init(struct __mp_lock *mpl) -{ - memset(mpl->mpl_cpus, 0, sizeof(mpl->mpl_cpus)); - mpl->mpl_users = 0; - mpl->mpl_ticket = 1; -} - -#if defined(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 - -static __inline void -__mp_lock_spin(struct __mp_lock *mpl, u_int me) -{ -#ifndef MP_LOCKDEBUG - while (mpl->mpl_ticket != me) - CPU_BUSY_CYCLE(); -#else - int nticks = __mp_lock_spinout; - - while (mpl->mpl_ticket != me) { - CPU_BUSY_CYCLE(); - - if (--nticks <= 0) { - db_printf("__mp_lock(%p): lock spun out", mpl); - db_enter(); - nticks = __mp_lock_spinout; - } - } -#endif -} - -void -__mp_lock(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - u_int64_t s; - - s = intr_disable(); - if (cpu->mplc_depth++ == 0) - cpu->mplc_ticket = atomic_inc_int_nv(&mpl->mpl_users); - intr_restore(s); - - __mp_lock_spin(mpl, cpu->mplc_ticket); - membar_enter(); -} - -void -__mp_unlock(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - u_int64_t s; - - s = intr_disable(); - if (--cpu->mplc_depth == 0) { - membar_exit(); - mpl->mpl_ticket++; - } - intr_restore(s); -} - -int -__mp_release_all(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - u_int64_t s; - int rv; - - s = intr_disable(); - rv = cpu->mplc_depth; - cpu->mplc_depth = 0; - membar_exit(); - mpl->mpl_ticket++; - intr_restore(s); - - return (rv); -} - -int -__mp_release_all_but_one(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - u_int64_t s; - int rv; - - s = intr_disable(); - rv = cpu->mplc_depth; - cpu->mplc_depth = 1; - intr_restore(s); - - return (rv - 1); -} - -void -__mp_acquire_count(struct __mp_lock *mpl, int count) -{ - while (count--) - __mp_lock(mpl); -} - -int -__mp_lock_held(struct __mp_lock *mpl) -{ - struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()]; - - return (cpu->mplc_ticket == mpl->mpl_ticket && cpu->mplc_depth > 0); -} |