- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h. - add some more checks. - make it a little more lkm friendly.
This commit is contained in:
parent
1ffbab1764
commit
a67bae0b7b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_lock.c,v 1.134 2008/01/30 14:54:26 ad Exp $ */
|
||||
/* $NetBSD: kern_lock.c,v 1.135 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.134 2008/01/30 14:54:26 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.135 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
@ -64,19 +64,37 @@ bool kernel_lock_dodebug;
|
||||
__cpu_simple_lock_t kernel_lock[CACHE_LINE_SIZE / sizeof(__cpu_simple_lock_t)]
|
||||
__aligned(CACHE_LINE_SIZE);
|
||||
|
||||
#if defined(LOCKDEBUG)
|
||||
#if defined(DEBUG) || defined(LKM)
|
||||
void
|
||||
assert_sleepable(struct simplelock *interlock, const char *msg)
|
||||
assert_sleepable(void)
|
||||
{
|
||||
#if !defined(_RUMPKERNEL)
|
||||
const char *reason;
|
||||
|
||||
if (panicstr != NULL)
|
||||
if (panicstr != NULL) {
|
||||
return;
|
||||
LOCKDEBUG_BARRIER(kernel_lock, 1);
|
||||
if (CURCPU_IDLE_P() && !cold) {
|
||||
panic("assert_sleepable: idle");
|
||||
}
|
||||
|
||||
LOCKDEBUG_BARRIER(kernel_lock, 1);
|
||||
|
||||
reason = NULL;
|
||||
if (CURCPU_IDLE_P() && !cold) {
|
||||
reason = "idle";
|
||||
}
|
||||
if (cpu_intr_p()) {
|
||||
reason = "interrupt";
|
||||
}
|
||||
if ((curlwp->l_pflag & LP_INTR) != 0) {
|
||||
reason = "softint";
|
||||
}
|
||||
|
||||
if (reason) {
|
||||
panic("%s: %s caller=%p", __func__, reason,
|
||||
(void *)RETURN_ADDRESS);
|
||||
}
|
||||
#endif /* !defined(_RUMPKERNEL) */
|
||||
}
|
||||
#endif
|
||||
#endif /* defined(DEBUG) || defined(LKM) */
|
||||
|
||||
/*
|
||||
* rump doesn't need the kernel lock so force it out. We cannot
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_malloc.c,v 1.117 2008/01/03 01:21:08 yamt Exp $ */
|
||||
/* $NetBSD: kern_malloc.c,v 1.118 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1991, 1993
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.117 2008/01/03 01:21:08 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.118 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
@ -328,7 +328,7 @@ malloc(unsigned long size, struct malloc_type *ksp, int flags)
|
||||
|
||||
#ifdef LOCKDEBUG
|
||||
if ((flags & M_NOWAIT) == 0)
|
||||
ASSERT_SLEEPABLE(NULL, "malloc");
|
||||
ASSERT_SLEEPABLE();
|
||||
#endif
|
||||
#ifdef MALLOC_DEBUG
|
||||
if (debug_malloc(size, ksp, flags, (void *) &va)) {
|
||||
@ -689,7 +689,7 @@ realloc(void *curaddr, unsigned long newsize, struct malloc_type *ksp,
|
||||
|
||||
#ifdef LOCKDEBUG
|
||||
if ((flags & M_NOWAIT) == 0)
|
||||
ASSERT_SLEEPABLE(NULL, "realloc");
|
||||
ASSERT_SLEEPABLE();
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_subr.c,v 1.182 2008/02/28 14:25:12 drochner Exp $ */
|
||||
/* $NetBSD: kern_subr.c,v 1.183 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 1999, 2002, 2007, 2006 The NetBSD Foundation, Inc.
|
||||
@ -86,7 +86,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.182 2008/02/28 14:25:12 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.183 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_md.h"
|
||||
@ -160,7 +160,7 @@ uiomove(void *buf, size_t n, struct uio *uio)
|
||||
int error = 0;
|
||||
char *cp = buf;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, "uiomove");
|
||||
ASSERT_SLEEPABLE();
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (uio->uio_rw != UIO_READ && uio->uio_rw != UIO_WRITE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_extent.c,v 1.69 2007/12/05 07:06:54 ad Exp $ */
|
||||
/* $NetBSD: subr_extent.c,v 1.70 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1998, 2007 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.69 2007/12/05 07:06:54 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.70 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include "opt_lockdebug.h"
|
||||
@ -489,7 +489,7 @@ extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
|
||||
#endif
|
||||
#ifdef LOCKDEBUG
|
||||
if (flags & EX_WAITSPACE)
|
||||
ASSERT_SLEEPABLE(NULL, "extent_alloc_region(EX_WAITSPACE)");
|
||||
ASSERT_SLEEPABLE();
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -661,7 +661,7 @@ extent_alloc_subregion1(struct extent *ex, u_long substart, u_long subend,
|
||||
#endif
|
||||
#ifdef LOCKDEBUG
|
||||
if (flags & EX_WAITSPACE)
|
||||
ASSERT_SLEEPABLE(NULL, "extent_alloc_subregion1(EX_WAITSPACE)");
|
||||
ASSERT_SLEEPABLE();
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_percpu.c,v 1.2 2008/01/17 09:01:57 yamt Exp $ */
|
||||
/* $NetBSD: subr_percpu.c,v 1.3 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2007,2008 YAMAMOTO Takashi,
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.2 2008/01/17 09:01:57 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.3 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/cpu.h>
|
||||
@ -159,7 +159,7 @@ percpu_backend_alloc(vmem_t *dummy, vmem_size_t size, vmem_size_t *resultsize,
|
||||
unsigned int offset;
|
||||
unsigned int nextoff;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
KASSERT(dummy == NULL);
|
||||
|
||||
if ((vmflags & VM_NOSLEEP) != 0)
|
||||
@ -204,7 +204,7 @@ void
|
||||
percpu_init(void)
|
||||
{
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
rw_init(&percpu_swap_lock);
|
||||
mutex_init(&percpu_allocation_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
|
||||
@ -225,7 +225,7 @@ percpu_init_cpu(struct cpu_info *ci)
|
||||
percpu_cpu_t * const pcc = cpu_percpu(ci);
|
||||
size_t size = percpu_nextoff; /* XXX racy */
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
pcc->pcc_size = size;
|
||||
if (size) {
|
||||
pcc->pcc_data = kmem_zalloc(pcc->pcc_size, KM_SLEEP);
|
||||
@ -246,7 +246,7 @@ percpu_alloc(size_t size)
|
||||
unsigned int offset;
|
||||
percpu_t *pc;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
offset = vmem_alloc(percpu_offset_arena, size, VM_SLEEP | VM_BESTFIT);
|
||||
pc = (percpu_t *)(uintptr_t)offset;
|
||||
percpu_zero(pc, size);
|
||||
@ -264,7 +264,7 @@ void
|
||||
percpu_free(percpu_t *pc, size_t size)
|
||||
{
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
vmem_free(percpu_offset_arena, (vmem_addr_t)percpu_offset(pc), size);
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ void
|
||||
percpu_traverse_enter(void)
|
||||
{
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
rw_enter(&percpu_swap_lock, RW_READER);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_pool.c,v 1.153 2008/03/10 22:20:14 martin Exp $ */
|
||||
/* $NetBSD: subr_pool.c,v 1.154 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1999, 2000, 2002, 2007 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.153 2008/03/10 22:20:14 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.154 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_pool.h"
|
||||
@ -996,7 +996,7 @@ pool_get(struct pool *pp, int flags)
|
||||
#endif /* DIAGNOSTIC */
|
||||
#ifdef LOCKDEBUG
|
||||
if (flags & PR_WAITOK)
|
||||
ASSERT_SLEEPABLE(NULL, "pool_get(PR_WAITOK)");
|
||||
ASSERT_SLEEPABLE();
|
||||
#endif
|
||||
|
||||
mutex_enter(&pp->pr_lock);
|
||||
@ -2522,7 +2522,7 @@ pool_cache_get_paddr(pool_cache_t pc, int flags, paddr_t *pap)
|
||||
|
||||
#ifdef LOCKDEBUG
|
||||
if (flags & PR_WAITOK)
|
||||
ASSERT_SLEEPABLE(NULL, "pool_cache_get(PR_WAITOK)");
|
||||
ASSERT_SLEEPABLE();
|
||||
#endif
|
||||
|
||||
cc = pool_cache_cpu_enter(pc, &s);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_specificdata.c,v 1.11 2007/11/07 00:23:23 ad Exp $ */
|
||||
/* $NetBSD: subr_specificdata.c,v 1.12 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -63,11 +63,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_specificdata.c,v 1.11 2007/11/07 00:23:23 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_specificdata.c,v 1.12 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/specificdata.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/mutex.h>
|
||||
@ -193,7 +192,7 @@ specificdata_key_create(specificdata_domain_t sd, specificdata_key_t *keyp,
|
||||
specificdata_key_t key = 0;
|
||||
size_t nsz;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
|
||||
if (dtor == NULL)
|
||||
dtor = specificdata_noop_dtor;
|
||||
@ -289,7 +288,7 @@ specificdata_fini(specificdata_domain_t sd, specificdata_reference *ref)
|
||||
specificdata_container_t sc;
|
||||
specificdata_key_t key;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
|
||||
mutex_destroy(&ref->specdataref_lock);
|
||||
|
||||
@ -367,7 +366,7 @@ specificdata_setspecific(specificdata_domain_t sd,
|
||||
specificdata_container_t sc, newsc;
|
||||
size_t newnkey, sz;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
|
||||
mutex_enter(&ref->specdataref_lock);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_vmem.c,v 1.41 2008/01/24 13:57:52 ad Exp $ */
|
||||
/* $NetBSD: subr_vmem.c,v 1.42 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2006 YAMAMOTO Takashi,
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.41 2008/01/24 13:57:52 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.42 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
#define VMEM_DEBUG
|
||||
#if defined(_KERNEL)
|
||||
@ -57,7 +57,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.41 2008/01/24 13:57:52 ad Exp $");
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/pool.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vmem.h>
|
||||
#include <sys/workqueue.h>
|
||||
#else /* defined(_KERNEL) */
|
||||
@ -78,7 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.41 2008/01/24 13:57:52 ad Exp $");
|
||||
#define mutex_enter(a) /* nothing */
|
||||
#define mutex_exit(a) /* nothing */
|
||||
#define mutex_owned(a) /* nothing */
|
||||
#define ASSERT_SLEEPABLE(lk, msg) /* nothing */
|
||||
#define ASSERT_SLEEPABLE() /* nothing */
|
||||
#define IPL_VM 0
|
||||
#endif /* defined(_KERNEL) */
|
||||
|
||||
@ -857,7 +856,7 @@ vmem_alloc(vmem_t *vm, vmem_size_t size, vm_flag_t flags)
|
||||
KASSERT(size > 0);
|
||||
KASSERT(strat == VM_BESTFIT || strat == VM_INSTANTFIT);
|
||||
if ((flags & VM_SLEEP) != 0) {
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
}
|
||||
|
||||
#if defined(QCACHE)
|
||||
@ -892,7 +891,7 @@ vmem_xalloc(vmem_t *vm, vmem_size_t size0, vmem_size_t align, vmem_size_t phase,
|
||||
KASSERT(size > 0);
|
||||
KASSERT(strat == VM_BESTFIT || strat == VM_INSTANTFIT);
|
||||
if ((flags & VM_SLEEP) != 0) {
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
}
|
||||
KASSERT((align & vm->vm_quantum_mask) == 0);
|
||||
KASSERT((align & (align - 1)) == 0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_trans.c,v 1.17 2008/02/02 16:51:34 hannken Exp $ */
|
||||
/* $NetBSD: vfs_trans.c,v 1.18 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.17 2008/02/02 16:51:34 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.18 2008/03/17 08:27:50 yamt Exp $");
|
||||
|
||||
/*
|
||||
* File system transaction operations.
|
||||
@ -177,7 +177,7 @@ _fstrans_start(struct mount *mp, enum fstrans_lock_type lock_type, int wait)
|
||||
struct fstrans_lwp_info *fli, *new_fli;
|
||||
struct fstrans_mount_info *fmi;
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
ASSERT_SLEEPABLE();
|
||||
|
||||
if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0)
|
||||
return 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: proc.h,v 1.270 2008/02/19 20:27:27 ad Exp $ */
|
||||
/* $NetBSD: proc.h,v 1.271 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -579,13 +579,6 @@ _proclist_skipmarker(struct proc *p0)
|
||||
((var) = _proclist_skipmarker(var)) != NULL; \
|
||||
(var) = LIST_NEXT(var, p_list))
|
||||
|
||||
#if defined(LOCKDEBUG)
|
||||
void assert_sleepable(struct simplelock *, const char *);
|
||||
#define ASSERT_SLEEPABLE(lk, msg) assert_sleepable((lk), (msg))
|
||||
#else /* defined(LOCKDEBUG) */
|
||||
#define ASSERT_SLEEPABLE(lk, msg) /* nothing */
|
||||
#endif /* defined(LOCKDEBUG) */
|
||||
|
||||
/* Compatibility with old, non-interlocked tsleep call */
|
||||
#define tsleep(chan, pri, wmesg, timo) \
|
||||
ltsleep(chan, pri, wmesg, timo, NULL)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: systm.h,v 1.214 2008/02/06 22:12:42 dsl Exp $ */
|
||||
/* $NetBSD: systm.h,v 1.215 2008/03/17 08:27:50 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1988, 1991, 1993
|
||||
@ -484,4 +484,11 @@ do { \
|
||||
void crit_enter(void);
|
||||
void crit_exit(void);
|
||||
|
||||
void assert_sleepable(void);
|
||||
#if defined(DEBUG)
|
||||
#define ASSERT_SLEEPABLE() assert_sleepable()
|
||||
#else /* defined(DEBUG) */
|
||||
#define ASSERT_SLEEPABLE() /* nothing */
|
||||
#endif /* defined(DEBUG) */
|
||||
|
||||
#endif /* !_SYS_SYSTM_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user