From acd72eb169c94eb88945f1aa0961399de232932a Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 9 Nov 2010 20:46:41 +0000 Subject: - Remove . Most of the headers were empty, and the contents of the ones that were not empty were stale and unused. - Now that no longer exists, there is no need to allow it to override various helper macros in . - Rename various helper macros for low-level operations on mutexes to live in the _mtx_* or __mtx_* namespaces. While here, change the names to more closely match the real API functions they are backing. - Drop support for including in assembly source files. Suggested by: bde (1, 2) --- sys/amd64/include/mutex.h | 35 ---------------- sys/arm/include/mutex.h | 32 --------------- sys/i386/include/mutex.h | 66 ------------------------------ sys/ia64/include/mutex.h | 70 -------------------------------- sys/kern/kern_mutex.c | 22 +++++----- sys/mips/include/mutex.h | 2 - sys/pc98/include/mutex.h | 6 --- sys/powerpc/include/mutex.h | 67 ------------------------------ sys/sparc64/include/mutex.h | 32 --------------- sys/sun4v/include/mutex.h | 32 --------------- sys/sys/mutex.h | 99 +++++++++++++++++---------------------------- 11 files changed, 47 insertions(+), 416 deletions(-) delete mode 100644 sys/amd64/include/mutex.h delete mode 100644 sys/arm/include/mutex.h delete mode 100644 sys/i386/include/mutex.h delete mode 100644 sys/ia64/include/mutex.h delete mode 100644 sys/mips/include/mutex.h delete mode 100644 sys/pc98/include/mutex.h delete mode 100644 sys/powerpc/include/mutex.h delete mode 100644 sys/sparc64/include/mutex.h delete mode 100644 sys/sun4v/include/mutex.h diff --git a/sys/amd64/include/mutex.h b/sys/amd64/include/mutex.h deleted file mode 100644 index a2edadd..0000000 --- a/sys/amd64/include/mutex.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. - * - * 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#endif /* __MACHINE_MUTEX_H */ diff --git a/sys/arm/include/mutex.h b/sys/arm/include/mutex.h deleted file mode 100644 index c9b2e1d..0000000 --- a/sys/arm/include/mutex.h +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * 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 AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#endif /* !_MACHINE_MUTEX_H_ */ diff --git a/sys/i386/include/mutex.h b/sys/i386/include/mutex.h deleted file mode 100644 index 651e226..0000000 --- a/sys/i386/include/mutex.h +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. - * - * 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#ifdef LOCORE - -/* - * Simple assembly macros to get and release mutexes. - * - * Note: All of these macros accept a "flags" argument and are analoguous - * to the mtx_lock_flags and mtx_unlock_flags general macros. If one - * desires to not pass a flag, the value 0 may be passed as second - * argument. - * - * XXX: We only have MTX_LOCK_SPIN and MTX_UNLOCK_SPIN for now, since that's - * all we use right now. We should add MTX_LOCK and MTX_UNLOCK (for sleep - * locks) in the near future, however. - */ -#define MTX_LOCK_SPIN(lck, flags) \ - pushl $0 ; \ - pushl $0 ; \ - pushl $flags ; \ - pushl $lck ; \ - call _mtx_lock_spin_flags ; \ - addl $0x10, %esp ; \ - -#define MTX_UNLOCK_SPIN(lck) \ - pushl $0 ; \ - pushl $0 ; \ - pushl $0 ; \ - pushl $lck ; \ - call _mtx_unlock_spin_flags ; \ - addl $0x10, %esp ; \ - -#endif /* LOCORE */ -#endif /* __MACHINE_MUTEX_H */ diff --git a/sys/ia64/include/mutex.h b/sys/ia64/include/mutex.h deleted file mode 100644 index 96d8f3d..0000000 --- a/sys/ia64/include/mutex.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. - * - * 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#ifdef LOCORE - -/* - * Simple assembly macros to get and release non-recursive spin locks - */ -#define MTX_ENTER(lck, rPSR, rOLD, rNEW, rLCK) \ - mov rPSR=psr ; \ - mov rNEW=pcpup ; \ - addl rLCK=@ltoff(lck),gp ;; \ - ld8 rLCK=[rLCK] ;; \ - add rLCK=MTX_LOCK,rLCK ;; \ - rsm psr.i ; \ - mov ar.ccv=MTX_UNOWNED ; \ - add rNEW=PC_CURTHREAD,rNEW ;; \ - ld8 rNEW=[rNEW] ;; \ -1: cmpxchg8.acq rOLD=[rLCK],rNEW,ar.ccv ;; \ - cmp.eq p1,p0=MTX_UNOWNED,rOLD ;; \ -(p1) br.cond.spnt.few 1b ;; \ - addl rLCK=@ltoff(lck),gp ;; \ - ld8 rLCK=[rLCK] ;; \ - add rLCK=MTX_SAVEINTR,rLCK ;; \ - st4 [rLCK]=rPSR - -#define MTX_EXIT(lck, rTMP, rLCK) \ - mov rTMP=MTX_UNOWNED ; \ - addl rLCK=@ltoff(lck),gp;; \ - ld8 rLCK=[rLCK];; \ - add rLCK=MTX_LOCK,rLCK;; \ - st8.rel [rLCK]=rTMP,MTX_SAVEINTR-MTX_LOCK ;; \ - ld4 rTMP=[rLCK] ;; \ - mov psr.l=rTMP ;; \ - srlz.d - -#endif /* !LOCORE */ - -#endif /* __MACHINE_MUTEX_H */ diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index c0bef50..041b480 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -200,7 +200,7 @@ _mtx_lock_flags(struct mtx *m, int opts, const char *file, int line) WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); - _get_sleep_lock(m, curthread, opts, file, line); + __mtx_lock(m, curthread, opts, file, line); LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); @@ -224,7 +224,7 @@ _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line) if (m->mtx_recurse == 0) LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_UNLOCK_RELEASE, m); - _rel_sleep_lock(m, curthread, opts, file, line); + __mtx_unlock(m, curthread, opts, file, line); } void @@ -243,7 +243,7 @@ _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); - _get_spin_lock(m, curthread, opts, file, line); + __mtx_lock_spin(m, curthread, opts, file, line); LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); @@ -264,7 +264,7 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line) line); mtx_assert(m, MA_OWNED); - _rel_spin_lock(m); + __mtx_unlock_spin(m); } /* @@ -293,7 +293,7 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) atomic_set_ptr(&m->mtx_lock, MTX_RECURSED); rval = 1; } else - rval = _obtain_lock(m, (uintptr_t)curthread); + rval = _mtx_obtain_lock(m, (uintptr_t)curthread); LOCK_LOG_TRY("LOCK", &m->lock_object, opts, rval, file, line); if (rval) { @@ -355,7 +355,7 @@ _mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts, const char *file, "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->lock_object.lo_name, (void *)m->mtx_lock, file, line); - while (!_obtain_lock(m, tid)) { + while (!_mtx_obtain_lock(m, tid)) { #ifdef KDTRACE_HOOKS spin_cnt++; #endif @@ -511,7 +511,7 @@ _mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file, CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); - while (!_obtain_lock(m, tid)) { + while (!_mtx_obtain_lock(m, tid)) { /* Give interrupts a chance while we spin. */ spinlock_exit(); @@ -569,7 +569,7 @@ retry: m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); - while (!_obtain_lock(m, tid)) { + while (!_mtx_obtain_lock(m, tid)) { #ifdef KDTRACE_HOOKS spin_cnt++; #endif @@ -597,7 +597,7 @@ retry: } if (m == td->td_lock) break; - _rel_spin_lock(m); /* does spinlock_exit() */ + __mtx_unlock_spin(m); /* does spinlock_exit() */ #ifdef KDTRACE_HOOKS spin_cnt++; #endif @@ -673,7 +673,7 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m); MPASS(ts != NULL); turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE); - _release_lock_quick(m); + _mtx_release_lock_quick(m); /* * This turnstile is now no longer associated with the mutex. We can @@ -685,7 +685,7 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) /* * All the unlocking of MTX_SPIN locks is done inline. - * See the _rel_spin_lock() macro for the details. + * See the __mtx_unlock_spin() macro for the details. */ /* diff --git a/sys/mips/include/mutex.h b/sys/mips/include/mutex.h deleted file mode 100644 index cbc066d..0000000 --- a/sys/mips/include/mutex.h +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -/* Empty file */ diff --git a/sys/pc98/include/mutex.h b/sys/pc98/include/mutex.h deleted file mode 100644 index a79c8f7..0000000 --- a/sys/pc98/include/mutex.h +++ /dev/null @@ -1,6 +0,0 @@ -/*- - * This file is in the public domain. - */ -/* $FreeBSD$ */ - -#include diff --git a/sys/powerpc/include/mutex.h b/sys/powerpc/include/mutex.h deleted file mode 100644 index b6f80fb..0000000 --- a/sys/powerpc/include/mutex.h +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. - * - * 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#if 0 -#ifdef LOCORE - -/* - * Simple assembly macros to get and release non-recursive spin locks - */ -#define MTX_ENTER(lck) \ - mfmsr r10; \ /* disable interrupts */ - rlwinm r0, r10, 0, 17, 15; \ - mtmsr r0; \ -1: li r11, MTX_LOCK; \ /* MTX_LOCK offset */ - lwarx r0, r11, lck; \ /* load current lock value */ - cmplwi r0, r1, MTX_UNOWNED; \ /* compare with unowned */ - beq 1; \ /* if owned, loop */ - lwz r0, PC_CURPROC(pcpup); \ /* load curproc */ - stwcx. r0, r11, lck; \ /* attempt to store */ - beq 1; \ /* loop if failed */ - sync; \ /* sync */ - eieio; \ /* sync */ - stw r10, MTX_SAVEINTR(lck) /* save flags */ - -#define MTX_EXIT(lck) \ - sync; \ /* sync */ - eieio; \ /* sync */ - li r0, MTX_UNOWNED; \ /* load in unowned */ - stw r0, MTX_LOCK(lck); \ /* store to lock */ - lwz r0, MTX_SAVEINTR(lck); \ /* load saved flags */ - mtmsr r0 /* enable interrupts */ - -#endif /* !LOCORE */ - -#endif -#endif /* __MACHINE_MUTEX_H */ diff --git a/sys/sparc64/include/mutex.h b/sys/sparc64/include/mutex.h deleted file mode 100644 index c9b2e1d..0000000 --- a/sys/sparc64/include/mutex.h +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * 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 AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#endif /* !_MACHINE_MUTEX_H_ */ diff --git a/sys/sun4v/include/mutex.h b/sys/sun4v/include/mutex.h deleted file mode 100644 index c9b2e1d..0000000 --- a/sys/sun4v/include/mutex.h +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * 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 AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#endif /* !_MACHINE_MUTEX_H_ */ diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 5800f80..7088575 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -32,7 +32,6 @@ #ifndef _SYS_MUTEX_H_ #define _SYS_MUTEX_H_ -#ifndef LOCORE #include #include #include @@ -43,12 +42,6 @@ #include #include #include -#endif /* _KERNEL_ */ -#endif /* !LOCORE */ - -#include - -#ifdef _KERNEL /* * Mutex types and options passed to mtx_init(). MTX_QUIET and MTX_DUPOK @@ -83,8 +76,6 @@ #endif /* _KERNEL */ -#ifndef LOCORE - /* * XXX: Friendly reminder to fix things in MP code that is presently being * XXX: worked on. @@ -137,68 +128,59 @@ void _thread_lock_flags(struct thread *, int, const char *, int); #define mtx_recurse lock_object.lo_data -/* - * We define our machine-independent (unoptimized) mutex micro-operations - * here, if they are not already defined in the machine-dependent mutex.h - */ +/* Very simple operations on mtx_lock. */ /* Try to obtain mtx_lock once. */ -#ifndef _obtain_lock -#define _obtain_lock(mp, tid) \ +#define _mtx_obtain_lock(mp, tid) \ atomic_cmpset_acq_ptr(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) -#endif /* Try to release mtx_lock if it is unrecursed and uncontested. */ -#ifndef _release_lock -#define _release_lock(mp, tid) \ +#define _mtx_release_lock(mp, tid) \ atomic_cmpset_rel_ptr(&(mp)->mtx_lock, (tid), MTX_UNOWNED) -#endif /* Release mtx_lock quickly, assuming we own it. */ -#ifndef _release_lock_quick -#define _release_lock_quick(mp) \ +#define _mtx_release_lock_quick(mp) \ atomic_store_rel_ptr(&(mp)->mtx_lock, MTX_UNOWNED) -#endif /* - * Obtain a sleep lock inline, or call the "hard" function if we can't get it - * easy. + * Full lock operations that are suitable to be inlined in non-debug + * kernels. If the lock cannot be acquired or released trivially then + * the work is deferred to another function. */ -#ifndef _get_sleep_lock -#define _get_sleep_lock(mp, tid, opts, file, line) do { \ + +/* Lock a normal mutex. */ +#define __mtx_lock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ - if (!_obtain_lock((mp), _tid)) \ + \ + if (!_mtx_obtain_lock((mp), _tid)) \ _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ else \ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, \ mp, 0, 0, (file), (line)); \ } while (0) -#endif /* - * Obtain a spin lock inline, or call the "hard" function if we can't get it - * easy. For spinlocks, we handle recursion inline (it turns out that function - * calls can be significantly expensive on some architectures). - * Since spin locks are not _too_ common, inlining this code is not too big - * a deal. + * Lock a spin mutex. For spinlocks, we handle recursion inline (it + * turns out that function calls can be significantly expensive on + * some architectures). Since spin locks are not _too_ common, + * inlining this code is not too big a deal. */ -#ifndef _get_spin_lock #ifdef SMP -#define _get_spin_lock(mp, tid, opts, file, line) do { \ +#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ + \ spinlock_enter(); \ - if (!_obtain_lock((mp), _tid)) { \ + if (!_mtx_obtain_lock((mp), _tid)) { \ if ((mp)->mtx_lock == _tid) \ (mp)->mtx_recurse++; \ - else { \ + else \ _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ - } \ } else \ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ mp, 0, 0, (file), (line)); \ } while (0) #else /* SMP */ -#define _get_spin_lock(mp, tid, opts, file, line) do { \ +#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ \ spinlock_enter(); \ @@ -206,49 +188,42 @@ void _thread_lock_flags(struct thread *, int, const char *, int); (mp)->mtx_recurse++; \ else { \ KASSERT((mp)->mtx_lock == MTX_UNOWNED, ("corrupt spinlock")); \ - (mp)->mtx_lock = _tid; \ + (mp)->mtx_lock = _tid; \ } \ } while (0) #endif /* SMP */ -#endif -/* - * Release a sleep lock inline, or call the "hard" function if we can't do it - * easy. - */ -#ifndef _rel_sleep_lock -#define _rel_sleep_lock(mp, tid, opts, file, line) do { \ +/* Unlock a normal mutex. */ +#define __mtx_unlock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ \ - if (!_release_lock((mp), _tid)) \ + if (!_mtx_release_lock((mp), _tid)) \ _mtx_unlock_sleep((mp), (opts), (file), (line)); \ } while (0) -#endif /* - * For spinlocks, we can handle everything inline, as it's pretty simple and - * a function call would be too expensive (at least on some architectures). - * Since spin locks are not _too_ common, inlining this code is not too big - * a deal. + * Unlock a spin mutex. For spinlocks, we can handle everything + * inline, as it's pretty simple and a function call would be too + * expensive (at least on some architectures). Since spin locks are + * not _too_ common, inlining this code is not too big a deal. * * Since we always perform a spinlock_enter() when attempting to acquire a * spin lock, we need to always perform a matching spinlock_exit() when * releasing a spin lock. This includes the recursion cases. */ -#ifndef _rel_spin_lock #ifdef SMP -#define _rel_spin_lock(mp) do { \ +#define __mtx_unlock_spin(mp) do { \ if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ mp); \ - _release_lock_quick((mp)); \ + _mtx_release_lock_quick((mp)); \ } \ spinlock_exit(); \ } while (0) #else /* SMP */ -#define _rel_spin_lock(mp) do { \ +#define __mtx_unlock_spin(mp) do { \ if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ @@ -259,7 +234,6 @@ void _thread_lock_flags(struct thread *, int, const char *, int); spinlock_exit(); \ } while (0) #endif /* SMP */ -#endif /* * Exported lock manipulation interface. @@ -336,13 +310,13 @@ extern struct mtx_pool *mtxpool_sleep; _mtx_unlock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE) #else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */ #define mtx_lock_flags(m, opts) \ - _get_sleep_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) + __mtx_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) #define mtx_unlock_flags(m, opts) \ - _rel_sleep_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) + __mtx_unlock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) #define mtx_lock_spin_flags(m, opts) \ - _get_spin_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) + __mtx_lock_spin((m), curthread, (opts), LOCK_FILE, LOCK_LINE) #define mtx_unlock_spin_flags(m, opts) \ - _rel_spin_lock((m)) + __mtx_unlock_spin((m)) #endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */ #define mtx_trylock_flags(m, opts) \ @@ -451,5 +425,4 @@ struct mtx_args { #define MTX_NETWORK_LOCK "network driver" #endif /* _KERNEL */ -#endif /* !LOCORE */ #endif /* _SYS_MUTEX_H_ */ -- cgit v1.1