Allow rw_tryenter(&lock, RW_READER) to recurse, for vfs_busy().

This commit is contained in:
ad 2008-05-06 17:11:45 +00:00
parent 32cf2beed0
commit 81194e34f1
5 changed files with 25 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lock.c,v 1.140 2008/04/28 20:24:03 martin Exp $ */
/* $NetBSD: kern_lock.c,v 1.141 2008/05/06 17:11:45 ad Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.140 2008/04/28 20:24:03 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.141 2008/05/06 17:11:45 ad Exp $");
#include "opt_multiprocessor.h"
@ -179,7 +179,7 @@ _kernel_lock(int nlocks)
_KERNEL_LOCK_ASSERT(l->l_blcnt == 0);
LOCKDEBUG_WANTLOCK(kernel_lock_dodebug, kernel_lock, RETURN_ADDRESS,
0);
false, false);
if (__cpu_simple_lock_try(kernel_lock)) {
ci->ci_biglock_count = nlocks;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_mutex.c,v 1.39 2008/04/30 00:40:13 yamt Exp $ */
/* $NetBSD: kern_mutex.c,v 1.40 2008/05/06 17:11:45 ad Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -40,7 +40,7 @@
#define __MUTEX_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.39 2008/04/30 00:40:13 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.40 2008/05/06 17:11:45 ad Exp $");
#include "opt_multiprocessor.h"
@ -76,7 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.39 2008/04/30 00:40:13 yamt Exp $")
#define MUTEX_WANTLOCK(mtx) \
LOCKDEBUG_WANTLOCK(MUTEX_DEBUG_P(mtx), (mtx), \
(uintptr_t)__builtin_return_address(0), 0)
(uintptr_t)__builtin_return_address(0), false, false)
#define MUTEX_LOCKED(mtx) \
LOCKDEBUG_LOCKED(MUTEX_DEBUG_P(mtx), (mtx), \
(uintptr_t)__builtin_return_address(0), 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_rwlock.c,v 1.22 2008/04/28 20:24:03 martin Exp $ */
/* $NetBSD: kern_rwlock.c,v 1.23 2008/05/06 17:11:45 ad Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.22 2008/04/28 20:24:03 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.23 2008/05/06 17:11:45 ad Exp $");
#include "opt_multiprocessor.h"
@ -63,9 +63,9 @@ __KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.22 2008/04/28 20:24:03 martin Exp
#if defined(LOCKDEBUG)
#define RW_WANTLOCK(rw, op) \
#define RW_WANTLOCK(rw, op, t) \
LOCKDEBUG_WANTLOCK(RW_DEBUG_P(rw), (rw), \
(uintptr_t)__builtin_return_address(0), op == RW_READER);
(uintptr_t)__builtin_return_address(0), op == RW_READER, t);
#define RW_LOCKED(rw, op) \
LOCKDEBUG_LOCKED(RW_DEBUG_P(rw), (rw), \
(uintptr_t)__builtin_return_address(0), op == RW_READER);
@ -80,7 +80,7 @@ do { \
#else /* LOCKDEBUG */
#define RW_WANTLOCK(rw, op) /* nothing */
#define RW_WANTLOCK(rw, op, t) /* nothing */
#define RW_LOCKED(rw, op) /* nothing */
#define RW_UNLOCKED(rw, op) /* nothing */
#define RW_DASSERT(rw, cond) /* nothing */
@ -294,7 +294,7 @@ rw_vector_enter(krwlock_t *rw, const krw_t op)
RW_ASSERT(rw, !cpu_intr_p());
RW_ASSERT(rw, curthread != 0);
RW_WANTLOCK(rw, op);
RW_WANTLOCK(rw, op, false);
if (panicstr == NULL) {
LOCKDEBUG_BARRIER(&kernel_lock, 1);
@ -567,7 +567,7 @@ rw_vector_tryenter(krwlock_t *rw, const krw_t op)
#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_enter();
#endif
RW_WANTLOCK(rw, op);
RW_WANTLOCK(rw, op, true);
RW_LOCKED(rw, op);
RW_DASSERT(rw, (op != RW_READER && RW_OWNER(rw) == curthread) ||
(op == RW_READER && RW_COUNT(rw) != 0));
@ -680,7 +680,7 @@ rw_tryupgrade(krwlock_t *rw)
curthread = (uintptr_t)curlwp;
RW_ASSERT(rw, curthread != 0);
RW_WANTLOCK(rw, RW_WRITER);
RW_WANTLOCK(rw, RW_WRITER, true);
for (owner = rw->rw_owner;; owner = next) {
RW_ASSERT(rw, (owner & RW_WRITE_LOCKED) == 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_lockdebug.c,v 1.32 2008/05/03 06:24:55 yamt Exp $ */
/* $NetBSD: subr_lockdebug.c,v 1.33 2008/05/06 17:11:45 ad Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.32 2008/05/03 06:24:55 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.33 2008/05/06 17:11:45 ad Exp $");
#include "opt_ddb.h"
@ -460,7 +460,8 @@ lockdebug_more(void)
* Process the preamble to a lock acquire.
*/
void
lockdebug_wantlock(volatile void *lock, uintptr_t where, int shared)
lockdebug_wantlock(volatile void *lock, uintptr_t where, bool shared,
bool trylock)
{
struct lwp *l = curlwp;
lockdebuglk_t *lk;
@ -478,7 +479,7 @@ lockdebug_wantlock(volatile void *lock, uintptr_t where, int shared)
if ((ld->ld_flags & LD_LOCKED) != 0 || ld->ld_shares != 0) {
if ((ld->ld_flags & LD_SLEEPER) != 0) {
if (ld->ld_lwp == l)
if (ld->ld_lwp == l && !(shared && trylock))
recurse = true;
} else if (ld->ld_cpu == (uint16_t)cpu_number())
recurse = true;

View File

@ -1,7 +1,7 @@
/* $NetBSD: lockdebug.h,v 1.8 2008/04/28 20:24:10 martin Exp $ */
/* $NetBSD: lockdebug.h,v 1.9 2008/05/06 17:11:45 ad Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -57,7 +57,7 @@ void lockdebug_lock_print(void *, void (*)(const char *, ...));
bool lockdebug_alloc(volatile void *, lockops_t *, uintptr_t);
void lockdebug_free(volatile void *);
void lockdebug_wantlock(volatile void *, uintptr_t, int);
void lockdebug_wantlock(volatile void *, uintptr_t, bool, bool);
void lockdebug_locked(volatile void *, uintptr_t, int);
void lockdebug_unlocked(volatile void *, uintptr_t, int);
void lockdebug_barrier(volatile void *, int);
@ -66,8 +66,8 @@ void lockdebug_mem_check(const char *, void *, size_t);
#define LOCKDEBUG_ALLOC(lock, ops, addr) lockdebug_alloc(lock, ops, addr)
#define LOCKDEBUG_FREE(dodebug, lock) \
if (dodebug) lockdebug_free(lock)
#define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s) \
if (dodebug) lockdebug_wantlock(lock, where, s)
#define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s, t) \
if (dodebug) lockdebug_wantlock(lock, where, s, t)
#define LOCKDEBUG_LOCKED(dodebug, lock, where, s) \
if (dodebug) lockdebug_locked(lock, where, s)
#define LOCKDEBUG_UNLOCKED(dodebug, lock, where, s) \
@ -80,7 +80,7 @@ void lockdebug_mem_check(const char *, void *, size_t);
#define LOCKDEBUG_ALLOC(lock, ops, addr) false
#define LOCKDEBUG_FREE(dodebug, lock) /* nothing */
#define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s) /* nothing */
#define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s, t) /* nothing */
#define LOCKDEBUG_LOCKED(dodebug, lock, where, s) /* nothing */
#define LOCKDEBUG_UNLOCKED(dodebug, lock, where, s) /* nothing */
#define LOCKDEBUG_BARRIER(lock, slp) /* nothing */