__cpu_simple_locks really should be simple, otherwise they can cause

problems for e.g. profiling.
This commit is contained in:
ad 2007-11-07 16:02:27 +00:00
parent d37935697b
commit ceb9d03641
3 changed files with 4 additions and 165 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.x86,v 1.33 2007/10/29 00:42:29 xtraeme Exp $
# $NetBSD: files.x86,v 1.34 2007/11/07 16:02:27 ad Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@ -51,7 +51,6 @@ file arch/x86/x86/i8259.c
file arch/x86/x86/idle_machdep.c
file arch/x86/x86/intr.c
file arch/x86/x86/ipi.c multiprocessor
file arch/x86/x86/lock_machdep.c lockdebug
file arch/x86/x86/msr_ipifuncs.c
file arch/x86/x86/mtrr_i686.c mtrr
file arch/x86/x86/patch.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.18 2007/10/17 19:58:15 garbled Exp $ */
/* $NetBSD: lock.h,v 1.19 2007/11/07 16:02:27 ad Exp $ */
/*-
* Copyright (c) 2000, 2006 The NetBSD Foundation, Inc.
@ -43,13 +43,11 @@
#ifndef _X86_LOCK_H_
#define _X86_LOCK_H_
#if defined(_KERNEL_OPT)
#include "opt_lockdebug.h"
#endif
#ifdef _KERNEL
#include <machine/cpufunc.h>
#endif
#include <machine/atomic.h>
static __inline int
__SIMPLELOCK_LOCKED_P(__cpu_simple_lock_t *__ptr)
@ -77,17 +75,6 @@ __cpu_simple_lock_clear(__cpu_simple_lock_t *__ptr)
*__ptr = __SIMPLELOCK_UNLOCKED;
}
#ifdef LOCKDEBUG
extern void __cpu_simple_lock_init(__cpu_simple_lock_t *);
extern void __cpu_simple_lock(__cpu_simple_lock_t *);
extern int __cpu_simple_lock_try(__cpu_simple_lock_t *);
extern void __cpu_simple_unlock(__cpu_simple_lock_t *);
#else
#include <machine/atomic.h>
static __inline void __cpu_simple_lock_init(__cpu_simple_lock_t *)
__attribute__((__unused__));
static __inline void __cpu_simple_lock(__cpu_simple_lock_t *)
@ -191,8 +178,6 @@ __cpu_simple_unlock(__cpu_simple_lock_t *lockp)
*lockp = __SIMPLELOCK_UNLOCKED;
}
#endif /* !LOCKDEBUG */
#define SPINLOCK_SPIN_HOOK /* nothing */
#define SPINLOCK_BACKOFF_HOOK x86_pause()

View File

@ -1,145 +0,0 @@
/* $NetBSD: lock_machdep.c,v 1.7 2007/02/09 21:55:14 ad 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: lock_machdep.c,v 1.7 2007/02/09 21:55:14 ad Exp $");
/*
* Machine-dependent spin lock operations.
*/
#include "opt_ddb.h"
#include <sys/types.h>
#include <sys/lock.h>
#include <sys/systm.h>
#include <machine/atomic.h>
#include <machine/cpu.h>
#include <ddb/db_output.h>
void
__cpu_simple_lock_init(lockp)
__cpu_simple_lock_t *lockp;
{
*lockp = __SIMPLELOCK_UNLOCKED;
}
#if defined (DEBUG) && defined(DDB)
int spin_limit = 10000000;
__cpu_simple_lock_t *wantlock[X86_MAXPROCS], *gotlock[X86_MAXPROCS];
#endif
void
__cpu_simple_lock(lockp)
__cpu_simple_lock_t *lockp;
{
#if defined (DEBUG)
#if defined(DDB)
int spincount = 0;
int mycpu = cpu_number();
int limit = spin_limit * (mycpu + 1);
#endif
__cpu_simple_lock_t v = *lockp;
KDASSERT((v == __SIMPLELOCK_LOCKED) || (v == __SIMPLELOCK_UNLOCKED));
#if defined(DDB)
wantlock[mycpu] = lockp;
#endif
#endif
while (x86_atomic_testset_b(lockp, __SIMPLELOCK_LOCKED) ==
__SIMPLELOCK_LOCKED) {
x86_pause();
#if defined(DEBUG) && defined(DDB)
spincount++;
if (spincount == limit) {
extern int db_active;
spincount = 0;
if (db_active) {
db_printf("cpu%d: spinout while in debugger\n",
mycpu);
while (db_active)
;
}
db_printf("cpu%d: spinout\n", mycpu);
Debugger();
}
#endif
}
#if defined(DEBUG) && defined(DDB)
wantlock[mycpu] = 0;
gotlock[mycpu] = lockp;
#endif
__insn_barrier();
}
int
__cpu_simple_lock_try(lockp)
__cpu_simple_lock_t *lockp;
{
int r;
#ifdef DEBUG
__cpu_simple_lock_t v = *lockp;
KDASSERT((v == __SIMPLELOCK_LOCKED) || (v == __SIMPLELOCK_UNLOCKED));
#endif
r = (x86_atomic_testset_b(lockp, __SIMPLELOCK_LOCKED)
== __SIMPLELOCK_UNLOCKED);
__insn_barrier();
return (r);
}
void
__cpu_simple_unlock(lockp)
__cpu_simple_lock_t *lockp;
{
#ifdef DEBUG
__cpu_simple_lock_t v = *lockp;
KDASSERT((v == __SIMPLELOCK_LOCKED) || (v == __SIMPLELOCK_UNLOCKED));
#endif
__insn_barrier();
*lockp = __SIMPLELOCK_UNLOCKED;
}