From 6f84e71dcdace435e1fb27855350a0bf818df3f3 Mon Sep 17 00:00:00 2001 From: visa Date: Thu, 20 Apr 2017 14:13:00 +0000 Subject: [PATCH] Tweak lock inits to make the system runnable with witness(4) on amd64 and i386. --- sys/arch/amd64/amd64/db_interface.c | 5 +++-- sys/arch/i386/i386/db_mp.c | 5 +++-- sys/arch/i386/i386/mem.c | 4 ++-- sys/dev/pci/drm/drm_crtc.c | 4 ++-- sys/isofs/cd9660/cd9660_vfsops.c | 4 ++-- sys/isofs/udf/udf_vfsops.c | 4 ++-- sys/kern/subr_disk.c | 4 ++-- sys/kern/subr_pool.c | 6 +++--- sys/kern/subr_prf.c | 5 +++-- sys/kern/vfs_subr.c | 4 ++-- sys/miscfs/fuse/fuse_vfsops.c | 4 ++-- sys/msdosfs/msdosfs_denode.c | 4 ++-- sys/net/bpf.c | 5 +++-- sys/tmpfs/tmpfs_subr.c | 4 ++-- sys/ufs/ext2fs/ext2fs_vfsops.c | 4 ++-- sys/ufs/ffs/ffs_vfsops.c | 4 ++-- sys/uvm/uvm_map.c | 4 ++-- 17 files changed, 39 insertions(+), 35 deletions(-) diff --git a/sys/arch/amd64/amd64/db_interface.c b/sys/arch/amd64/amd64/db_interface.c index b5220d4bed9..c4050f84b97 100644 --- a/sys/arch/amd64/amd64/db_interface.c +++ b/sys/arch/amd64/amd64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.26 2017/03/03 20:49:47 bluhm Exp $ */ +/* $OpenBSD: db_interface.c,v 1.27 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: db_interface.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -70,7 +70,8 @@ extern char *trap_type[]; extern int trap_types; #ifdef MULTIPROCESSOR -struct mutex ddb_mp_mutex = MUTEX_INITIALIZER(IPL_HIGH); +struct mutex ddb_mp_mutex = + MUTEX_INITIALIZER_FLAGS(IPL_HIGH, "ddb_mp_mutex", MTX_NOWITNESS); volatile int ddb_state = DDB_STATE_NOT_RUNNING; volatile cpuid_t ddb_active_cpu; boolean_t db_switch_cpu; diff --git a/sys/arch/i386/i386/db_mp.c b/sys/arch/i386/i386/db_mp.c index d17c33c0ca7..036dc30e720 100644 --- a/sys/arch/i386/i386/db_mp.c +++ b/sys/arch/i386/i386/db_mp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_mp.c,v 1.8 2016/03/07 05:32:46 naddy Exp $ */ +/* $OpenBSD: db_mp.c,v 1.9 2017/04/20 14:13:00 visa Exp $ */ /* * Copyright (c) 2003, 2004 Andreas Gunnarsson @@ -23,7 +23,8 @@ #include -struct mutex ddb_mp_mutex = MUTEX_INITIALIZER(IPL_HIGH); +struct mutex ddb_mp_mutex = + MUTEX_INITIALIZER_FLAGS(IPL_HIGH, "ddb_mp_mutex", MTX_NOWITNESS); volatile int ddb_state = DDB_STATE_NOT_RUNNING; /* protected by ddb_mp_mutex */ volatile cpuid_t ddb_active_cpu; /* protected by ddb_mp_mutex */ diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c index 42c6282a608..1db1e6efb51 100644 --- a/sys/arch/i386/i386/mem.c +++ b/sys/arch/i386/i386/mem.c @@ -1,5 +1,5 @@ /* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */ -/* $OpenBSD: mem.c,v 1.51 2016/09/25 15:23:37 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.52 2017/04/20 14:13:00 visa Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -116,10 +116,10 @@ mmclose(dev_t dev, int flag, int mode, struct proc *p) return (0); } +static struct rwlock physlock = RWLOCK_INITIALIZER("mmrw"); int mmrw(dev_t dev, struct uio *uio, int flags) { - static struct rwlock physlock = RWLOCK_INITIALIZER("mmrw"); vaddr_t o, v; size_t c; struct iovec *iov; diff --git a/sys/dev/pci/drm/drm_crtc.c b/sys/dev/pci/drm/drm_crtc.c index a7e5bfc0d7d..f9e5ea12581 100644 --- a/sys/dev/pci/drm/drm_crtc.c +++ b/sys/dev/pci/drm/drm_crtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_crtc.c,v 1.23 2016/04/08 08:27:53 kettenis Exp $ */ +/* $OpenBSD: drm_crtc.c,v 1.24 2017/04/20 14:13:00 visa Exp $ */ /* * Copyright (c) 2006-2008 Intel Corporation * Copyright (c) 2007 Dave Airlie @@ -642,7 +642,7 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, crtc->invert_dimensions = false; drm_modeset_lock_all(dev); - rw_init(&crtc->mutex, "crtcl"); + rw_init_flags(&crtc->mutex, "crtcl", RWL_DUPOK); mutex_lock_nest_lock(&crtc->mutex, &dev->mode_config.mutex); ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 131a88a46be..1dcc256a580 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vfsops.c,v 1.83 2016/09/07 17:30:12 natano Exp $ */ +/* $OpenBSD: cd9660_vfsops.c,v 1.84 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */ /*- @@ -757,7 +757,7 @@ retry: return (error); } ip = malloc(sizeof(*ip), M_ISOFSNODE, M_WAITOK | M_ZERO); - rrw_init(&ip->i_lock, "isoinode"); + rrw_init_flags(&ip->i_lock, "isoinode", RWL_DUPOK); vp->v_data = ip; ip->i_vnode = vp; ip->i_dev = dev; diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c index 6c66b2782ba..08a592629f2 100644 --- a/sys/isofs/udf/udf_vfsops.c +++ b/sys/isofs/udf/udf_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_vfsops.c,v 1.58 2017/02/08 01:32:38 jsg Exp $ */ +/* $OpenBSD: udf_vfsops.c,v 1.59 2017/04/20 14:13:00 visa Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -638,7 +638,7 @@ udf_vget(struct mount *mp, ino_t ino, struct vnode **vpp) vp->v_data = up; vref(ump->um_devvp); - rrw_init(&up->u_lock, "unode"); + rrw_init_flags(&up->u_lock, "unode", RWL_DUPOK); /* * udf_hashins() will lock the vnode for us. diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 773eeac22d5..4d220feeae0 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.228 2016/09/02 09:44:27 tom Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.229 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -1046,7 +1046,7 @@ disk_init(void) int disk_construct(struct disk *diskp) { - rw_init(&diskp->dk_lock, "dklk"); + rw_init_flags(&diskp->dk_lock, "dklk", RWL_IS_VNODE); mtx_init(&diskp->dk_mtx, IPL_BIO); diskp->dk_flags |= DKF_CONSTRUCTED; diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index e6f67130730..ec6b290ee8b 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.207 2017/02/20 00:43:25 dlg Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.208 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -380,8 +380,8 @@ pool_init(struct pool *pp, size_t size, u_int align, int ipl, int flags, pp->pr_nidle = 0; pp->pr_ipl = ipl; - mtx_init(&pp->pr_mtx, pp->pr_ipl); - mtx_init(&pp->pr_requests_mtx, pp->pr_ipl); + mtx_init_flags(&pp->pr_mtx, pp->pr_ipl, wchan, 0); + mtx_init_flags(&pp->pr_requests_mtx, pp->pr_ipl, wchan, 0); TAILQ_INIT(&pp->pr_requests); if (phpool.pr_size == 0) { diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index bb9c8ea6716..302989ca7e1 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_prf.c,v 1.87 2016/05/17 23:43:47 bluhm Exp $ */ +/* $OpenBSD: subr_prf.c,v 1.88 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */ /*- @@ -93,7 +93,8 @@ int kprintf(const char *, int, void *, char *, va_list); void kputchar(int, int, struct tty *); -struct mutex kprintf_mutex = MUTEX_INITIALIZER(IPL_HIGH); +struct mutex kprintf_mutex = + MUTEX_INITIALIZER_FLAGS(IPL_HIGH, "kprintf", MTX_NOWITNESS); /* * globals diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 8cdeb565922..2a643bf36bb 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.258 2017/04/04 18:17:02 deraadt Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.259 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -172,7 +172,7 @@ vfs_busy(struct mount *mp, int flags) /* new mountpoints need their lock initialised */ if (mp->mnt_lock.rwl_name == NULL) - rw_init(&mp->mnt_lock, "vfslock"); + rw_init_flags(&mp->mnt_lock, "vfslock", RWL_IS_VNODE); if (flags & VB_WRITE) rwflags |= RW_WRITE; diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c index 26832b373d0..16bac9615b5 100644 --- a/sys/miscfs/fuse/fuse_vfsops.c +++ b/sys/miscfs/fuse/fuse_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vfsops.c,v 1.28 2016/09/07 17:53:35 natano Exp $ */ +/* $OpenBSD: fuse_vfsops.c,v 1.29 2017/04/20 14:13:00 visa Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon * @@ -268,7 +268,7 @@ retry: } ip = malloc(sizeof(*ip), M_FUSEFS, M_WAITOK | M_ZERO); - rrw_init(&ip->ufs_ino.i_lock, "fuseinode"); + rrw_init_flags(&ip->ufs_ino.i_lock, "fuseinode", RWL_DUPOK); nvp->v_data = ip; ip->ufs_ino.i_vnode = nvp; ip->ufs_ino.i_dev = fmp->dev; diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c index b3515e6ee54..018d4744cf7 100644 --- a/sys/msdosfs/msdosfs_denode.c +++ b/sys/msdosfs/msdosfs_denode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_denode.c,v 1.57 2016/06/19 11:54:33 natano Exp $ */ +/* $OpenBSD: msdosfs_denode.c,v 1.58 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: msdosfs_denode.c,v 1.23 1997/10/17 11:23:58 ws Exp $ */ /*- @@ -233,7 +233,7 @@ retry: return (error); } ldep = malloc(sizeof(*ldep), M_MSDOSFSNODE, M_WAITOK | M_ZERO); - rrw_init(&ldep->de_lock, "denode"); + rrw_init_flags(&ldep->de_lock, "denode", RWL_DUPOK); nvp->v_data = ldep; ldep->de_vnode = nvp; ldep->de_flag = 0; diff --git a/sys/net/bpf.c b/sys/net/bpf.c index c0bd4672ee3..f71eff16e3c 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.160 2017/01/24 22:40:55 mpi Exp $ */ +/* $OpenBSD: bpf.c,v 1.161 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -140,6 +140,8 @@ struct srpl_rc bpf_d_rc = SRPL_RC_INITIALIZER(bpf_d_ref, bpf_d_unref, NULL); void bpf_insn_dtor(void *, void *); struct srp_gc bpf_insn_gc = SRP_GC_INITIALIZER(bpf_insn_dtor, NULL); +struct rwlock bpf_sysctl_lk = RWLOCK_INITIALIZER("bpfsz"); + int bpf_movein(struct uio *uio, u_int linktype, struct mbuf **mp, struct sockaddr *sockp, struct bpf_insn *filter) @@ -1633,7 +1635,6 @@ int bpf_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { - static struct rwlock bpf_sysctl_lk = RWLOCK_INITIALIZER("bpfsz"); int flags = RW_INTR; int error; diff --git a/sys/tmpfs/tmpfs_subr.c b/sys/tmpfs/tmpfs_subr.c index 55b67df9f10..adc982184e9 100644 --- a/sys/tmpfs/tmpfs_subr.c +++ b/sys/tmpfs/tmpfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmpfs_subr.c,v 1.17 2016/09/22 10:23:27 jsg Exp $ */ +/* $OpenBSD: tmpfs_subr.c,v 1.18 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: tmpfs_subr.c,v 1.79 2012/03/13 18:40:50 elad Exp $ */ /* @@ -314,7 +314,7 @@ again: return error; } - rrw_init(&node->tn_vlock, "tnode"); + rrw_init_flags(&node->tn_vlock, "tnode", RWL_DUPOK); vp->v_type = node->tn_type; /* Type-specific initialization. */ diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 05cab5e43a6..53eaa05a32a 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.97 2016/09/15 02:00:18 dlg Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.98 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -815,7 +815,7 @@ ext2fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) } ip = pool_get(&ext2fs_inode_pool, PR_WAITOK|PR_ZERO); - rrw_init(&ip->i_lock, "inode"); + rrw_init_flags(&ip->i_lock, "inode", RWL_DUPOK); vp->v_data = ip; ip->i_vnode = vp; ip->i_ump = ump; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 99eaf527aac..0770e9aa45d 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.164 2016/09/15 02:00:18 dlg Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.165 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1266,7 +1266,7 @@ retry: vp->v_flag |= VLOCKSWORK; #endif ip = pool_get(&ffs_ino_pool, PR_WAITOK|PR_ZERO); - rrw_init(&ip->i_lock, "inode"); + rrw_init_flags(&ip->i_lock, "inode", RWL_DUPOK | RWL_IS_VNODE); ip->i_ump = ump; vref(ip->i_devvp); vp->v_data = ip; diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 689f7bf0601..564d1f645c5 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.229 2017/02/14 10:31:15 mpi Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.230 2017/04/20 14:13:00 visa Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -2407,7 +2407,7 @@ uvm_map_setup(struct vm_map *map, vaddr_t min, vaddr_t max, int flags) map->s_start = map->s_end = 0; /* Empty stack area by default. */ map->flags = flags; map->timestamp = 0; - rw_init(&map->lock, "vmmaplk"); + rw_init_flags(&map->lock, "vmmaplk", RWL_DUPOK); mtx_init(&map->mtx, IPL_VM); mtx_init(&map->flags_lock, IPL_VM); -- 2.20.1