CVS commit: src
Module Name:src Committed By: rmind Date: Fri Jun 3 18:43:39 UTC 2011 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile uvm_km.9 uvm_map.9 Log Message: Sync (mostly, not fully) uvm_km(9) and uvm_map(9) man pages with reality. To generate a diff of this commit: cvs rdiff -u -r1.1627 -r1.1628 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.347 -r1.348 src/share/man/man9/Makefile cvs rdiff -u -r1.1 -r1.2 src/share/man/man9/uvm_km.9 \ src/share/man/man9/uvm_map.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1627 src/distrib/sets/lists/comp/mi:1.1628 --- src/distrib/sets/lists/comp/mi:1.1627 Wed Jun 1 02:22:19 2011 +++ src/distrib/sets/lists/comp/mi Fri Jun 3 18:43:38 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1627 2011/06/01 02:22:19 rmind Exp $ +# $NetBSD: mi,v 1.1628 2011/06/03 18:43:38 rmind Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -10195,7 +10195,7 @@ ./usr/share/man/cat9/uvm_scheduler.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_setpagesize.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_swap_init.0 comp-sys-catman .cat -./usr/share/man/cat9/uvm_swapin.0 comp-sys-catman .cat +./usr/share/man/cat9/uvm_swapin.0 comp-obsolete obsolete ./usr/share/man/cat9/uvm_sysctl.0 comp-obsolete obsolete ./usr/share/man/cat9/uvm_unloan.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_unmap.0 comp-sys-catman .cat @@ -16127,7 +16127,7 @@ ./usr/share/man/html9/uvm_scheduler.html comp-sys-htmlman html ./usr/share/man/html9/uvm_setpagesize.html comp-sys-htmlman html ./usr/share/man/html9/uvm_swap_init.html comp-sys-htmlman html -./usr/share/man/html9/uvm_swapin.html comp-sys-htmlman html +./usr/share/man/html9/uvm_swapin.html comp-obsolete obsolete ./usr/share/man/html9/uvm_unloan.html comp-sys-htmlman html ./usr/share/man/html9/uvm_unmap.html comp-sys-htmlman html ./usr/share/man/html9/uvm_vnp_setsize.html comp-sys-htmlman html @@ -22287,7 +22287,7 @@ ./usr/share/man/man9/uvm_scheduler.9 comp-sys-man .man ./usr/share/man/man9/uvm_setpagesize.9 comp-sys-man .man ./usr/share/man/man9/uvm_swap_init.9 comp-sys-man .man -./usr/share/man/man9/uvm_swapin.9 comp-sys-man .man +./usr/share/man/man9/uvm_swapin.9 comp-obsolete obsolete ./usr/share/man/man9/uvm_sysctl.9 comp-obsolete obsolete ./usr/share/man/man9/uvm_unloan.9 comp-sys-man .man ./usr/share/man/man9/uvm_unmap.9 comp-sys-man .man Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.347 src/share/man/man9/Makefile:1.348 --- src/share/man/man9/Makefile:1.347 Wed Jun 1 02:22:18 2011 +++ src/share/man/man9/Makefile Fri Jun 3 18:43:38 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.347 2011/06/01 02:22:18 rmind Exp $ +# $NetBSD: Makefile,v 1.348 2011/06/03 18:43:38 rmind Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -742,7 +742,7 @@ uvm.9 uvm_io.9 uvm.9 uvm_pagealloc.9 \ uvm.9 uvm_pagerealloc.9 uvm.9 uvm_pagefree.9 uvm.9 uvm_pglistalloc.9 \ uvm.9 uvm_pglistfree.9 uvm.9 uvm_page_physload.9 uvm.9 uvm_pageout.9 \ - uvm.9 uvm_scheduler.9 uvm.9 uvm_swapin.9 uvm.9 uao_create.9 \ + uvm.9 uvm_scheduler.9 uvm.9 uao_create.9 \ uvm.9 uao_detach.9 uvm.9 uao_reference.9 uvm.9 uvm_chgkprot.9 \ uvm.9 uvm_kernacc.9 uvm.9 uvm_vslock.9 \ uvm.9 uvm_vsunlock.9 uvm.9 uvm_meter.9 \ Index: src/share/man/man9/uvm_km.9 diff -u src/share/man/man9/uvm_km.9:1.1 src/share/man/man9/uvm_km.9:1.2 --- src/share/man/man9/uvm_km.9:1.1 Wed Jun 1 02:22:19 2011 +++ src/share/man/man9/uvm_km.9 Fri Jun 3 18:43:38 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: uvm_km.9,v 1.1 2011/06/01 02:22:19 rmind Exp $ +.\" $NetBSD: uvm_km.9,v 1.2 2011/06/03 18:43:38 rmind Exp $ .\" .\" Copyright (c) 1998 Matthew R. Green .\" All rights reserved. @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 1, 2011 +.Dd June 3, 2011 .Dt UVM_KM 9 .Os .Sh NAME @@ -39,7 +39,7 @@ .Fn uvm_km_free "struct vm_map *map" "vaddr_t addr" "vsize_t size" "uvm_flag_t flags" .Ft struct vm_map * .Fn uvm_km_suballoc "struct vm_map *map" "vaddr_t *min" "vaddr_t *max" \ -"vsize_t size" "int flags" "bool fixed" "struct vm_map *submap" +"vsize_t size" "int flags" "bool fixed" "struct vm_map_kernel *submap" .Sh DESCRIPTION The UVM facility for allocation of kernel memory or address space in pages. Both wired and pageable memory can be allocated by this facility, as well @@ -72,8 +72,8 @@ .It UVM_KMF_VAONLY Virtual address only. No physical pages are mapped in the allocated region. -If necessary, it's the caller's responsibility to enter page mappings. -It's also the caller's responsibility to clean up the mappings before freeing +If necessary, it is the caller's responsibi
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Fri Jun 3 17:58:19 UTC 2011 Modified Files: src/sys/arch/sparc/sparc: machdep.c src/sys/kern: kern_resource.c src/sys/sys: resourcevar.h Log Message: Revert maxdmap/maxsmap constification, as it causes problems on some sparc models. Reported by tsutsui@. To generate a diff of this commit: cvs rdiff -u -r1.309 -r1.310 src/sys/arch/sparc/sparc/machdep.c cvs rdiff -u -r1.166 -r1.167 src/sys/kern/kern_resource.c cvs rdiff -u -r1.52 -r1.53 src/sys/sys/resourcevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/machdep.c diff -u src/sys/arch/sparc/sparc/machdep.c:1.309 src/sys/arch/sparc/sparc/machdep.c:1.310 --- src/sys/arch/sparc/sparc/machdep.c:1.309 Mon May 16 18:08:04 2011 +++ src/sys/arch/sparc/sparc/machdep.c Fri Jun 3 17:58:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.309 2011/05/16 18:08:04 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.310 2011/06/03 17:58:18 rmind Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.309 2011/05/16 18:08:04 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.310 2011/06/03 17:58:18 rmind Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_sunos.h" @@ -306,10 +306,10 @@ /* Clip max data & stack to avoid running into the MMU hole */ #if MAXDSIZ > 256*1024*1024 - *(rlim_t*)__UNCONST(&maxdmap) = 256*1024*1024; + maxdmap = 256*1024*1024; #endif #if MAXSSIZ > 256*1024*1024 - *(rlim_t*)__UNCONST(&maxsmap) = 256*1024*1024; + maxsmap = 256*1024*1024; #endif } Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.166 src/sys/kern/kern_resource.c:1.167 --- src/sys/kern/kern_resource.c:1.166 Tue May 31 00:15:28 2011 +++ src/sys/kern/kern_resource.c Fri Jun 3 17:58:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.166 2011/05/31 00:15:28 rmind Exp $ */ +/* $NetBSD: kern_resource.c,v 1.167 2011/06/03 17:58:18 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.166 2011/05/31 00:15:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.167 2011/06/03 17:58:18 rmind Exp $"); #include #include @@ -62,8 +62,8 @@ * Maximum process data and stack limits. * They are variables so they are patchable. */ -const rlim_t maxdmap = MAXDSIZ; -const rlim_t maxsmap = MAXSSIZ; +rlim_t maxdmap = MAXDSIZ; +rlim_t maxsmap = MAXSSIZ; static pool_cache_t plimit_cache __read_mostly; static pool_cache_t pstats_cache __read_mostly; Index: src/sys/sys/resourcevar.h diff -u src/sys/sys/resourcevar.h:1.52 src/sys/sys/resourcevar.h:1.53 --- src/sys/sys/resourcevar.h:1.52 Sat May 14 17:57:05 2011 +++ src/sys/sys/resourcevar.h Fri Jun 3 17:58:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: resourcevar.h,v 1.52 2011/05/14 17:57:05 rmind Exp $ */ +/* $NetBSD: resourcevar.h,v 1.53 2011/06/03 17:58:18 rmind Exp $ */ /* * Copyright (c) 1991, 1993 @@ -117,8 +117,8 @@ void rulwps(proc_t *, struct rusage *); struct pstats *pstatscopy(struct pstats *); void pstatsfree(struct pstats *); -extern const rlim_t maxdmap; -extern const rlim_t maxsmap; +extern rlim_t maxdmap; +extern rlim_t maxsmap; #endif
CVS commit: src
Module Name:src Committed By: rmind Date: Wed Jun 1 02:22:20 UTC 2011 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile uvm.9 Added Files: src/share/man/man9: uvm_km.9 uvm_map.9 Log Message: Split parts of uvm(9) into uvm_km(9) and uvm_map(9) man pages. OK mrg@ To generate a diff of this commit: cvs rdiff -u -r1.1626 -r1.1627 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.346 -r1.347 src/share/man/man9/Makefile cvs rdiff -u -r1.105 -r1.106 src/share/man/man9/uvm.9 cvs rdiff -u -r0 -r1.1 src/share/man/man9/uvm_km.9 \ src/share/man/man9/uvm_map.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1626 src/distrib/sets/lists/comp/mi:1.1627 --- src/distrib/sets/lists/comp/mi:1.1626 Mon May 30 02:10:25 2011 +++ src/distrib/sets/lists/comp/mi Wed Jun 1 02:22:19 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1626 2011/05/30 02:10:25 christos Exp $ +# $NetBSD: mi,v 1.1627 2011/06/01 02:22:19 rmind Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -10169,6 +10169,7 @@ ./usr/share/man/cat9/uvm_init_limits.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_io.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_kernacc.0 comp-sys-catman .cat +./usr/share/man/cat9/uvm_km.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_km_alloc.0 comp-sys-catman .cat ./usr/share/man/cat9/uvm_km_alloc1.0 comp-obsolete obsolete ./usr/share/man/cat9/uvm_km_free.0 comp-sys-catman .cat @@ -16106,6 +16107,7 @@ ./usr/share/man/html9/uvm_init_limits.html comp-sys-htmlman html ./usr/share/man/html9/uvm_io.html comp-sys-htmlman html ./usr/share/man/html9/uvm_kernacc.html comp-sys-htmlman html +./usr/share/man/html9/uvm_km.html comp-sys-htmlman html ./usr/share/man/html9/uvm_km_alloc.html comp-sys-htmlman html ./usr/share/man/html9/uvm_km_free.html comp-sys-htmlman html ./usr/share/man/html9/uvm_km_suballoc.html comp-sys-htmlman html @@ -22259,6 +22261,7 @@ ./usr/share/man/man9/uvm_init_limits.9 comp-sys-man .man ./usr/share/man/man9/uvm_io.9 comp-sys-man .man ./usr/share/man/man9/uvm_kernacc.9 comp-sys-man .man +./usr/share/man/man9/uvm_km.9 comp-sys-man .man ./usr/share/man/man9/uvm_km_alloc.9 comp-sys-man .man ./usr/share/man/man9/uvm_km_alloc1.9 comp-obsolete obsolete ./usr/share/man/man9/uvm_km_free.9 comp-sys-man .man Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.346 src/share/man/man9/Makefile:1.347 --- src/share/man/man9/Makefile:1.346 Wed Apr 6 05:40:19 2011 +++ src/share/man/man9/Makefile Wed Jun 1 02:22:18 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.346 2011/04/06 05:40:19 jruoho Exp $ +# $NetBSD: Makefile,v 1.347 2011/06/01 02:22:18 rmind Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -54,7 +54,7 @@ vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 \ video.9 vme.9 \ vnfileops.9 vnode.9 vnodeops.9 vnsubr.9 \ - ubc.9 usbdi.9 uvm.9 vmem.9 \ + ubc.9 usbdi.9 uvm.9 uvm_km.9 uvm_map.9 vmem.9 \ wdc.9 workqueue.9 \ wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \ xcall.9 @@ -734,18 +734,12 @@ tc.9 TC_PHYS_TO_UNCACHED.9 MLINKS+=todr.9 todr_gettime.9 todr.9 todr_settime.9 \ todr.9 clock_ymdhms_to_secs.9 todr.9 clock_secs_to_ymdhms.9 + MLINKS+=ubc.9 ubc_alloc.9 ubc.9 ubc_release.9 ubc.9 ubc_uiomove.9 MLINKS+=uvm.9 uvm_init.9 uvm.9 uvm_init_limits.9 uvm.9 uvm_setpagesize.9 \ - uvm.9 uvm_swap_init.9 uvm.9 uvm_map.9 uvm.9 uvm_unmap.9 \ - uvm.9 uvm_map_pageable.9 \ - uvm.9 uvm_map_checkprot.9 uvm.9 uvm_map_protect.9 \ - uvm.9 uvm_deallocate.9 uvm.9 uvmspace_alloc.9 uvm.9 uvmspace_exec.9 \ - uvm.9 uvmspace_fork.9 uvm.9 uvmspace_free.9 uvm.9 uvmspace_share.9 \ - uvm.9 uvmspace_unshare.9 uvm.9 uvm_fault.9 \ + uvm.9 uvm_swap_init.9 uvm.9 uvm_fault.9 \ uvm.9 uvm_vnp_setsize.9 \ - uvm.9 uvm_io.9 uvm.9 uvm_km_alloc.9 \ - uvm.9 uvm_km_suballoc.9 uvm.9 uvm_km_free.9 \ - uvm.9 uvm_pagealloc.9 \ + uvm.9 uvm_io.9 uvm.9 uvm_pagealloc.9 \ uvm.9 uvm_pagerealloc.9 uvm.9 uvm_pagefree.9 uvm.9 uvm_pglistalloc.9 \ uvm.9 uvm_pglistfree.9 uvm.9 uvm_page_physload.9 uvm.9 uvm_pageout.9 \ uvm.9 uvm_scheduler.9 uvm.9 uvm_swapin.9 uvm.9 uao_create.9 \ @@ -755,6 +749,15 @@ uvm.9 uvm_fork.9 uvm.9 uvm_grow.9 \ uvm.9 uvn_findpages.9 \ uvm.9 uvm_loan.9 uvm.9 uvm_unloan.9 +MLINKS+=uvm_km.9 uvm_km_alloc.9 uvm_km.9 uvm_km_free.9 \ + uvm_km.9 uvm_km_suballoc.9 +MLINKS+=uvm_map.9 uvm_unmap.9 uvm_map.9 uvm_map_pageable.9 \ + uvm_map.9 uvm_map_checkprot.9 uvm_map.9 uvm_map_protect.9 \ + uvm_map.9 uvm_deallocate.9 uvm_map.9 uvmspace_alloc.9 \ + uvm_map.9 uvmspace_exec.9 uvm_map.9 uvmspace_fork.9 \ + uvm_map.9 uvmspace_free.9 uvm_map.9 uvmspace_share.9 \ + uvm_map.9 uvmspace_unshare.9 + MLINKS+=vme.9 vme_probe.9 \ vme.9 vme_space_map.9 \ vme.9 vme_
CVS commit: [rmind-uvmplock] src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Tue May 31 01:51:58 UTC 2011 Modified Files: src/sys/fs/tmpfs [rmind-uvmplock]: tmpfs_subr.c Log Message: tmpfs_alloc_vp: perform lock sharing only for VREG. To generate a diff of this commit: cvs rdiff -u -r1.56.4.7 -r1.56.4.8 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.7 src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.8 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.7 Mon May 30 14:57:48 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Tue May 31 01:51:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.56.4.7 2011/05/30 14:57:48 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.56.4.8 2011/05/31 01:51:58 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.7 2011/05/30 14:57:48 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.8 2011/05/31 01:51:58 rmind Exp $"); #include #include @@ -344,7 +344,7 @@ int tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp) { - struct uvm_object *uobj; + kmutex_t *slock; int error; struct vnode *vp; @@ -367,16 +367,19 @@ /* * Get a new vnode and associate it with our inode. Share the - * lock with underlying UVM object. + * lock with underlying UVM object, if there is one (VREG case). */ - uobj = node->tn_spec.tn_reg.tn_aobj; - error = getnewvnode(VT_TMPFS, mp, tmpfs_vnodeop_p, - uobj->vmobjlock, &vp); + if (node->tn_type == VREG) { + struct uvm_object *uobj = node->tn_spec.tn_reg.tn_aobj; + slock = uobj->vmobjlock; + } else { + slock = NULL; + } + error = getnewvnode(VT_TMPFS, mp, tmpfs_vnodeop_p, slock, &vp); if (error != 0) { mutex_exit(&node->tn_vlock); return error; } - KASSERT(uobj->vmobjlock == vp->v_interlock); error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0) {
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Tue May 31 00:15:28 UTC 2011 Modified Files: src/sys/kern: kern_resource.c Log Message: sysctl_proc_corename: perform KAUTH_PROCESS_CORENAME check (for set case) after the new name is copied into cnbuf. Spotted by enami@. To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/sys/kern/kern_resource.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.165 src/sys/kern/kern_resource.c:1.166 --- src/sys/kern/kern_resource.c:1.165 Tue May 24 01:19:48 2011 +++ src/sys/kern/kern_resource.c Tue May 31 00:15:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.165 2011/05/24 01:19:48 mrg Exp $ */ +/* $NetBSD: kern_resource.c,v 1.166 2011/05/31 00:15:28 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.165 2011/05/24 01:19:48 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.166 2011/05/31 00:15:28 rmind Exp $"); #include #include @@ -838,15 +838,6 @@ strlcpy(cnbuf, lim->pl_corename, MAXPATHLEN); mutex_exit(&lim->pl_lock); } - if (newp) { - /* Set case: just use the temporary buffer. */ - error = kauth_authorize_process(l->l_cred, - KAUTH_PROCESS_CORENAME, p, - KAUTH_ARG(KAUTH_REQ_PROCESS_CORENAME_SET), cnbuf, NULL); - if (error) { - goto done; - } - } node = *rnode; node.sysctl_data = cnbuf; @@ -858,9 +849,14 @@ } /* - * Validate new core name. It must be either "core", "/core", - * or end in ".core". + * Set case. Check permission and then validate new core name. + * It must be either "core", "/core", or end in ".core". */ + error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CORENAME, + p, KAUTH_ARG(KAUTH_REQ_PROCESS_CORENAME_SET), cnbuf, NULL); + if (error) { + goto done; + } len = strlen(cnbuf); if ((len < 4 || strcmp(cnbuf + len - 4, "core") != 0) || (len > 4 && cnbuf[len - 5] != '/' && cnbuf[len - 5] != '.')) {
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Mon May 30 19:22:44 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: - tmpfs_getattr: perform tmpfs_update() before fetching the timestamps. - tmpfs_rmdir: detach after tn_links decrement, so that correct event i.e. NOTE_DELETE would be trigerred. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.85 src/sys/fs/tmpfs/tmpfs_vnops.c:1.86 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.85 Sun May 29 22:29:07 2011 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Mon May 30 19:22:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.85 2011/05/29 22:29:07 rmind Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.86 2011/05/30 19:22:44 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.85 2011/05/29 22:29:07 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.86 2011/05/30 19:22:44 rmind Exp $"); #include #include @@ -456,6 +456,8 @@ vattr_null(vap); + tmpfs_update(vp, NULL, NULL, NULL, 0); + vap->va_type = vp->v_type; vap->va_mode = node->tn_mode; vap->va_nlink = node->tn_links; @@ -478,7 +480,6 @@ vap->va_vaflags = 0; vap->va_spare = VNOVAL; /* XXX */ - tmpfs_update(vp, NULL, NULL, NULL, 0); return 0; } @@ -1094,13 +1095,13 @@ goto out; } - /* Detach the directory entry from the directory. */ - tmpfs_dir_detach(dvp, de); - /* Decrement the link count for the virtual '.' entry. */ node->tn_links--; node->tn_status |= TMPFS_NODE_STATUSALL; + /* Detach the directory entry from the directory. */ + tmpfs_dir_detach(dvp, de); + /* Purge the cache for parent. */ cache_purge(dvp);
CVS commit: [rmind-uvmplock] src/sys/arch/xen/xen
Module Name:src Committed By: rmind Date: Mon May 30 17:16:47 UTC 2011 Modified Files: src/sys/arch/xen/xen [rmind-uvmplock]: privcmd.c Log Message: privpgop_fault: simplify and sync with changes in the branch. To generate a diff of this commit: cvs rdiff -u -r1.41.4.2 -r1.41.4.3 src/sys/arch/xen/xen/privcmd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/privcmd.c diff -u src/sys/arch/xen/xen/privcmd.c:1.41.4.2 src/sys/arch/xen/xen/privcmd.c:1.41.4.3 --- src/sys/arch/xen/xen/privcmd.c:1.41.4.2 Thu May 19 03:43:00 2011 +++ src/sys/arch/xen/xen/privcmd.c Mon May 30 17:16:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: privcmd.c,v 1.41.4.2 2011/05/19 03:43:00 rmind Exp $ */ +/* $NetBSD: privcmd.c,v 1.41.4.3 2011/05/30 17:16:47 rmind Exp $ */ /*- * Copyright (c) 2004 Christian Limpach. @@ -27,7 +27,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.41.4.2 2011/05/19 03:43:00 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.41.4.3 2011/05/30 17:16:47 rmind Exp $"); #include #include @@ -466,6 +466,7 @@ privpgop_detach(struct uvm_object *uobj) { struct privcmd_object *pobj = (struct privcmd_object *)uobj; + mutex_enter(uobj->vmobjlock); if (uobj->uo_refs > 1) { uobj->uo_refs--; @@ -486,35 +487,30 @@ struct vm_map_entry *entry = ufi->entry; struct uvm_object *uobj = entry->object.uvm_obj; struct privcmd_object *pobj = (struct privcmd_object*)uobj; - int maddr_i; - int i, error = 0; + int maddr_i, i, error = 0; /* compute offset from start of map */ maddr_i = (entry->offset + (vaddr - entry->start)) >> PAGE_SHIFT; - if (maddr_i + npages > pobj->npages) + if (maddr_i + npages > pobj->npages) { return EINVAL; + } for (i = 0; i < npages; i++, maddr_i++, vaddr+= PAGE_SIZE) { if ((flags & PGO_ALLPAGES) == 0 && i != centeridx) continue; if (pps[i] == PGO_DONTCARE) continue; if (pobj->maddr[maddr_i] == INVALID_PAGE) { - /* this has already been flagged as error */ - uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, - uobj, NULL); - pmap_update(ufi->orig_map->pmap); - return EFAULT; + /* This has already been flagged as error. */ + error = EFAULT; + break; } error = pmap_enter_ma(ufi->orig_map->pmap, vaddr, pobj->maddr[maddr_i], 0, ufi->entry->protection, PMAP_CANFAIL | ufi->entry->protection, pobj->domid); if (error == ENOMEM) { - uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, - uobj, NULL); - pmap_update(ufi->orig_map->pmap); - uvm_wait("privpgop_fault"); - return (ERESTART); + error = ERESTART; + break; } if (error) { /* XXX for proper ptp accountings */ @@ -522,9 +518,12 @@ vaddr + PAGE_SIZE); } } - uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj, NULL); + uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj); pmap_update(ufi->orig_map->pmap); - return (error); + if (error == ERESTART) { + uvm_wait("privpgop_fault"); + } + return error; } static int
CVS commit: [rmind-uvmplock] src/sys
Module Name:src Committed By: rmind Date: Mon May 30 14:57:49 UTC 2011 Modified Files: src/sys/fs/tmpfs [rmind-uvmplock]: tmpfs_subr.c src/sys/fs/union [rmind-uvmplock]: union_subr.c src/sys/fs/unionfs [rmind-uvmplock]: unionfs_subr.c src/sys/kern [rmind-uvmplock]: vfs_vnode.c src/sys/miscfs/genfs [rmind-uvmplock]: layer_subr.c src/sys/sys [rmind-uvmplock]: vnode.h Log Message: - Amend getnewvnode(9) to take the lock for sharing, not a vnode. - Update tmpfs to perform vnode and UVM object lock sharing correctly. To generate a diff of this commit: cvs rdiff -u -r1.56.4.6 -r1.56.4.7 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.35.4.4 -r1.35.4.5 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.5.4.5 -r1.5.4.6 src/sys/fs/unionfs/unionfs_subr.c cvs rdiff -u -r1.5.2.4 -r1.5.2.5 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.28.4.4 -r1.28.4.5 src/sys/miscfs/genfs/layer_subr.c cvs rdiff -u -r1.214.2.6 -r1.214.2.7 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.6 src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.7 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.6 Sun May 22 04:29:04 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Mon May 30 14:57:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.56.4.6 2011/05/22 04:29:04 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.56.4.7 2011/05/30 14:57:48 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.6 2011/05/22 04:29:04 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.7 2011/05/30 14:57:48 rmind Exp $"); #include #include @@ -344,6 +344,7 @@ int tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp) { + struct uvm_object *uobj; int error; struct vnode *vp; @@ -364,16 +365,18 @@ break; } - /* Get a new vnode and associate it with our node. */ - error = getnewvnode(VT_TMPFS, mp, tmpfs_vnodeop_p, NULL, &vp); + /* + * Get a new vnode and associate it with our inode. Share the + * lock with underlying UVM object. + */ + uobj = node->tn_spec.tn_reg.tn_aobj; + error = getnewvnode(VT_TMPFS, mp, tmpfs_vnodeop_p, + uobj->vmobjlock, &vp); if (error != 0) { mutex_exit(&node->tn_vlock); return error; } - - /* Set UVM object to use vnode_t::v_interlock (share it). */ - uvm_obj_setlock(node->tn_spec.tn_reg.tn_aobj, vp->v_interlock); - mutex_obj_hold(vp->v_interlock); + KASSERT(uobj->vmobjlock == vp->v_interlock); error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0) { Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.35.4.4 src/sys/fs/union/union_subr.c:1.35.4.5 --- src/sys/fs/union/union_subr.c:1.35.4.4 Sat May 21 03:38:24 2011 +++ src/sys/fs/union/union_subr.c Mon May 30 14:57:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.35.4.4 2011/05/21 03:38:24 rmind Exp $ */ +/* $NetBSD: union_subr.c,v 1.35.4.5 2011/05/30 14:57:48 rmind Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.35.4.4 2011/05/21 03:38:24 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.35.4.5 2011/05/30 14:57:48 rmind Exp $"); #include #include @@ -511,8 +511,9 @@ * Get a new vnode and share the lock with upper layer vnode, * unless layers are inverted. */ + vnode_t *svp = (uppervp != NULLVP) ? uppervp : lowervp; error = getnewvnode(VT_UNION, mp, union_vnodeop_p, - (uppervp != NULLVP ? uppervp : lowervp), vpp); + svp->v_interlock, vpp); if (error) { if (uppervp) { if (dvp == uppervp) Index: src/sys/fs/unionfs/unionfs_subr.c diff -u src/sys/fs/unionfs/unionfs_subr.c:1.5.4.5 src/sys/fs/unionfs/unionfs_subr.c:1.5.4.6 --- src/sys/fs/unionfs/unionfs_subr.c:1.5.4.5 Sat May 21 03:38:25 2011 +++ src/sys/fs/unionfs/unionfs_subr.c Mon May 30 14:57:48 2011 @@ -95,8 +95,9 @@ * Get a new vnode and share the lock with upper layer vnode, * unless layers are inverted. */ + vnode_t *svp = (uppervp != NULLVP) ? uppervp : lowervp; error = getnewvnode(VT_UNION, mp, unionfs_vnodeop_p, - (uppervp != NULLVP ? uppervp : lowervp), &vp); + svp->v_interlock, &vp); if (error != 0) { return (error); } Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.5.2.4 src/sys/kern/vfs_vnode.c:1.5.2.5 --- src/sys/kern/vfs_vnode.c:1.5.2.4 Sun May 22 04:29:04 2011 +++ src/sys/kern/vfs_vnode.c Mon May 30 14:57:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.5.2.4 2011/05/22 04:29:04 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.5.2.5 2011/05/30 14:57:48 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5.2.4 2011/05/22 04:29:04 rmind
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Sun May 29 22:43:32 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Fix non-DEBUG build. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.71 src/sys/fs/tmpfs/tmpfs_subr.c:1.72 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.71 Sun May 29 22:29:06 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sun May 29 22:43:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.71 2011/05/29 22:29:06 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.72 2011/05/29 22:43:32 rmind Exp $ */ /* * Copyright (c) 2005-2011 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.71 2011/05/29 22:29:06 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.72 2011/05/29 22:43:32 rmind Exp $"); #include #include @@ -492,9 +492,9 @@ KASSERT(node->tn_links > 0); node->tn_links--; - if (node->tn_vnode) { - VN_KNOTE(node->tn_vnode, - node->tn_links ? NOTE_LINK : NOTE_DELETE); + if (vp) { + VN_KNOTE(vp, node->tn_links ? + NOTE_LINK : NOTE_DELETE); } /* If directory - decrease the link count of parent. */
CVS commit: src/sys/fs/tmpfs
**); -void tmpfs_free_dirent(tmpfs_mount_t *, tmpfs_dirent_t *, bool); -void tmpfs_dir_attach(vnode_t *, tmpfs_dirent_t *); +int tmpfs_alloc_dirent(tmpfs_mount_t *, const char *, uint16_t, + tmpfs_dirent_t **); +void tmpfs_free_dirent(tmpfs_mount_t *, tmpfs_dirent_t *); +void tmpfs_dir_attach(vnode_t *, tmpfs_dirent_t *, tmpfs_node_t *); void tmpfs_dir_detach(vnode_t *, tmpfs_dirent_t *); tmpfs_dirent_t *tmpfs_dir_lookup(tmpfs_node_t *, struct componentname *); +tmpfs_dirent_t *tmpfs_dir_cached(tmpfs_node_t *); + int tmpfs_dir_getdotdent(tmpfs_node_t *, struct uio *); int tmpfs_dir_getdotdotdent(tmpfs_node_t *, struct uio *); tmpfs_dirent_t *tmpfs_dir_lookupbycookie(tmpfs_node_t *, off_t); Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.70 src/sys/fs/tmpfs/tmpfs_subr.c:1.71 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.70 Wed May 25 02:03:22 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sun May 29 22:29:06 2011 @@ -1,12 +1,12 @@ -/* $NetBSD: tmpfs_subr.c,v 1.70 2011/05/25 02:03:22 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.71 2011/05/29 22:29:06 rmind Exp $ */ /* - * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. + * Copyright (c) 2005-2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Julio M. Merino Vidal, developed as part of Google's Summer of Code - * 2005 program. + * 2005 program, and by Mindaugas Rasiukevicius. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,12 +31,50 @@ */ /* - * Efficient memory file system: functions for inode and directory entry - * construction and destruction. + * Efficient memory file system: interfaces for inode and directory entry + * construction, destruction and manipulation. + * + * Reference counting + * + * The link count of inode (tmpfs_node_t::tn_links) is used as a + * reference counter. However, it has slightly different semantics. + * + * For directories - link count represents directory entries, which + * refer to the directories. In other words, it represents the count + * of sub-directories. It also takes into account the virtual '.' + * entry (which has no real entry in the list). For files - link count + * represents the hard links. Since only empty directories can be + * removed - link count aligns the reference counting requirements + * enough. Note: to check whether directory is not empty, the inode + * size (tmpfs_node_t::tn_size) can be used. + * + * The inode itself, as an object, gathers its first reference when + * directory entry is attached via tmpfs_dir_attach(9). For instance, + * after regular tmpfs_create(), a file would have a link count of 1, + * while directory after tmpfs_mkdir() would have 2 (due to '.'). + * + * Reclamation + * + * It should be noted that tmpfs inodes rely on a combination of vnode + * reference counting and link counting. That is, an inode can only be + * destroyed if its associated vnode is inactive. The destruction is + * done on vnode reclamation i.e. tmpfs_reclaim(). It should be noted + * that tmpfs_node_t::tn_links being 0 is a destruction criterion. + * + * If an inode has references within the file system (tn_links > 0) and + * its inactive vnode gets reclaimed/recycled - then the association is + * broken in tmpfs_reclaim(). In such case, an inode will always pass + * tmpfs_lookup() and thus tmpfs_vnode_get() to associate a new vnode. + * + * Lock order + * + * tmpfs_node_t::tn_vlock -> + * vnode_t::v_vlock -> + * vnode_t::v_interlock */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.70 2011/05/25 02:03:22 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.71 2011/05/29 22:29:06 rmind Exp $"); #include #include @@ -65,9 +103,8 @@ * insert it into the list of specified mount point. */ int -tmpfs_alloc_node(tmpfs_mount_t *tmp, enum vtype type, uid_t uid, -gid_t gid, mode_t mode, tmpfs_node_t *parent, char *target, dev_t rdev, -tmpfs_node_t **node) +tmpfs_alloc_node(tmpfs_mount_t *tmp, enum vtype type, uid_t uid, gid_t gid, +mode_t mode, char *target, dev_t rdev, tmpfs_node_t **node) { tmpfs_node_t *nnode; @@ -76,22 +113,25 @@ return ENOSPC; } + /* Initially, no references and no associations. */ + nnode->tn_links = 0; + nnode->tn_vnode = NULL; + nnode->tn_dirent_hint = NULL; + /* * XXX Where the pool is backed by a map larger than (4GB * * sizeof(*nnode)), this may produce duplicate inode numbers * for applications that do not understand 64-bit ino_t. */ nnode->tn_id = (ino_t)((uintptr_t)nnode / sizeof(*nnode)); - nnode->tn_gen = arc4random(); + nnode->tn_gen = TMPFS_NODE_GEN_MASK & arc4random(); /* Generic initialization. */ nnode->tn_type = type; nnode->tn_size = 0; nnode->tn_status = 0;
CVS commit: src
Module Name:src Committed By: rmind Date: Sun May 29 01:00:50 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs.h src/usr.bin/fstat: tmpfs.c Log Message: - Prevent tmpfs.h from inclusion in userland. - Clean up and KNF tmpfs.h a little bit. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.8 -r1.9 src/usr.bin/fstat/tmpfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs.h diff -u src/sys/fs/tmpfs/tmpfs.h:1.41 src/sys/fs/tmpfs/tmpfs.h:1.42 --- src/sys/fs/tmpfs/tmpfs.h:1.41 Tue May 24 20:17:49 2011 +++ src/sys/fs/tmpfs/tmpfs.h Sun May 29 01:00:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.41 2011/05/24 20:17:49 rmind Exp $ */ +/* $NetBSD: tmpfs.h,v 1.42 2011/05/29 01:00:50 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -30,8 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _FS_TMPFS_TMPFS_H_ -#define _FS_TMPFS_TMPFS_H_ +#ifndef _FS_TMPFS_H_ +#define _FS_TMPFS_H_ + +#if !defined(_KERNEL) && !defined(_KMEMUSER) +#error "not supposed to be exposed to userland" +#endif #include #include @@ -197,7 +201,7 @@ (TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED) /* White-out inode indicator. */ -#define TMPFS_NODE_WHITEOUT ((struct tmpfs_node *)-1) +#define TMPFS_NODE_WHITEOUT ((tmpfs_node_t *)-1) /* * Internal representation of a tmpfs mount point. @@ -237,59 +241,62 @@ * Prototypes for tmpfs_subr.c. */ -int tmpfs_alloc_node(struct tmpfs_mount *, enum vtype, - uid_t uid, gid_t gid, mode_t mode, struct tmpfs_node *, - char *, dev_t, struct tmpfs_node **); -void tmpfs_free_node(struct tmpfs_mount *, struct tmpfs_node *); -int tmpfs_alloc_dirent(struct tmpfs_mount *, struct tmpfs_node *, - const char *, uint16_t, struct tmpfs_dirent **); -void tmpfs_free_dirent(struct tmpfs_mount *, struct tmpfs_dirent *, - bool); -int tmpfs_alloc_vp(struct mount *, struct tmpfs_node *, struct vnode **); -void tmpfs_free_vp(struct vnode *); -int tmpfs_alloc_file(struct vnode *, struct vnode **, struct vattr *, - struct componentname *, char *); -void tmpfs_dir_attach(struct vnode *, struct tmpfs_dirent *); -void tmpfs_dir_detach(struct vnode *, struct tmpfs_dirent *); -struct tmpfs_dirent * tmpfs_dir_lookup(struct tmpfs_node *node, - struct componentname *cnp); -int tmpfs_dir_getdotdent(struct tmpfs_node *, struct uio *); -int tmpfs_dir_getdotdotdent(struct tmpfs_node *, struct uio *); -struct tmpfs_dirent * tmpfs_dir_lookupbycookie(struct tmpfs_node *, off_t); -int tmpfs_dir_getdents(struct tmpfs_node *, struct uio *, off_t *); -int tmpfs_reg_resize(struct vnode *, off_t); -int tmpfs_chflags(struct vnode *, int, kauth_cred_t, struct lwp *); -int tmpfs_chmod(struct vnode *, mode_t, kauth_cred_t, struct lwp *); -int tmpfs_chown(struct vnode *, uid_t, gid_t, kauth_cred_t, struct lwp *); -int tmpfs_chsize(struct vnode *, u_quad_t, kauth_cred_t, struct lwp *); -int tmpfs_chtimes(struct vnode *, const struct timespec *, -const struct timespec *, const struct timespec *, int, kauth_cred_t, -struct lwp *); -void tmpfs_update(struct vnode *, const struct timespec *, - const struct timespec *, const struct timespec *, int); -int tmpfs_truncate(struct vnode *, off_t); +int tmpfs_alloc_node(tmpfs_mount_t *, enum vtype, uid_t, gid_t, + mode_t, tmpfs_node_t *, char *, dev_t, tmpfs_node_t **); +void tmpfs_free_node(tmpfs_mount_t *, tmpfs_node_t *); + +int tmpfs_alloc_file(vnode_t *, vnode_t **, struct vattr *, + struct componentname *, char *); + +int tmpfs_alloc_vp(struct mount *, tmpfs_node_t *, vnode_t **); +void tmpfs_free_vp(vnode_t *); + +int tmpfs_alloc_dirent(tmpfs_mount_t *, tmpfs_node_t *, + const char *, uint16_t, tmpfs_dirent_t **); +void tmpfs_free_dirent(tmpfs_mount_t *, tmpfs_dirent_t *, bool); +void tmpfs_dir_attach(vnode_t *, tmpfs_dirent_t *); +void tmpfs_dir_detach(vnode_t *, tmpfs_dirent_t *); + +tmpfs_dirent_t *tmpfs_dir_lookup(tmpfs_node_t *, struct componentname *); +int tmpfs_dir_getdotdent(tmpfs_node_t *, struct uio *); +int tmpfs_dir_getdotdotdent(tmpfs_node_t *, struct uio *); +tmpfs_dirent_t *tmpfs_dir_lookupbycookie(tmpfs_node_t *, off_t); +int tmpfs_dir_getdents(tmpfs_node_t *, struct uio *, off_t *); + +int tmpfs_reg_resize(vnode_t *, off_t); +int tmpfs_truncate(vnode_t *, off_t); + +int tmpfs_chflags(vnode_t *, int, kauth_cred_t, lwp_t *); +int tmpfs_chmod(vnode_t *, mode_t, kauth_cred_t, lwp_t *); +int tmpfs_chown(vnode_t *, uid_t, gid_t, kauth_cred_t, lwp_t *); +int tmpfs_chsize(vnode_t *, u_quad_t, kauth_cred_t, lwp_t *); +int tmpfs_chtimes(vnode_t *, const struct timespec *, + const struct timespec *, const struct timespec *, int, + kauth_cred_t, lwp_t *); +void tmpfs_update(vnode_t *, const struct timespec *, + const struct timespec *, const
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Wed May 25 02:03:22 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_update: comment out assert for now. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.69 src/sys/fs/tmpfs/tmpfs_subr.c:1.70 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.69 Wed May 25 00:06:45 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Wed May 25 02:03:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.69 2011/05/25 00:06:45 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.70 2011/05/25 02:03:22 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.69 2011/05/25 00:06:45 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.70 2011/05/25 02:03:22 rmind Exp $"); #include #include @@ -1002,7 +1002,7 @@ tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); struct timespec nowtm; - KASSERT(VOP_ISLOCKED(vp)); + /* KASSERT(VOP_ISLOCKED(vp)); */ if (flags & UPDATE_CLOSE) { /* XXX Need to do anything special? */
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Wed May 25 00:06:45 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_dir_lookup: use 'name' variable in memcmp() as intended; fix warning. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.68 src/sys/fs/tmpfs/tmpfs_subr.c:1.69 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.68 Tue May 24 23:16:16 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Wed May 25 00:06:45 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.68 2011/05/24 23:16:16 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.69 2011/05/25 00:06:45 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.68 2011/05/24 23:16:16 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.69 2011/05/25 00:06:45 rmind Exp $"); #include #include @@ -494,7 +494,7 @@ TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { if (de->td_namelen != nlen) continue; - if (memcmp(de->td_name, cnp->cn_nameptr, nlen) != 0) + if (memcmp(de->td_name, name, nlen) != 0) continue; break; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Tue May 24 23:16:16 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c tmpfs_vnops.c Log Message: - tmpfs_lookup: cache (cnp->cn_flags & ISLASTCN) in const bool; de-indent. - Group tmpfs_{alloc,free}_dirent() with other dirent routines. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.83 -r1.84 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.67 src/sys/fs/tmpfs/tmpfs_subr.c:1.68 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.67 Tue May 24 20:17:49 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Tue May 24 23:16:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.67 2011/05/24 20:17:49 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.68 2011/05/24 23:16:16 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.67 2011/05/24 20:17:49 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.68 2011/05/24 23:16:16 rmind Exp $"); #include #include @@ -212,77 +212,6 @@ } /* - * tmpfs_alloc_dirent: allocates a new directory entry for the inode. - * - * The link count of node is increased by one to reflect the new object - * referencing it. This takes care of notifying kqueue listeners about - * this change. - */ -int -tmpfs_alloc_dirent(tmpfs_mount_t *tmp, tmpfs_node_t *node, -const char *name, uint16_t len, tmpfs_dirent_t **de) -{ - tmpfs_dirent_t *nde; - - nde = tmpfs_dirent_get(tmp); - if (nde == NULL) - return ENOSPC; - - nde->td_name = tmpfs_strname_alloc(tmp, len); - if (nde->td_name == NULL) { - tmpfs_dirent_put(tmp, nde); - return ENOSPC; - } - nde->td_namelen = len; - memcpy(nde->td_name, name, len); - nde->td_node = node; - - if (node != TMPFS_NODE_WHITEOUT) { - node->tn_links++; - if (node->tn_links > 1 && node->tn_vnode != NULL) - VN_KNOTE(node->tn_vnode, NOTE_LINK); - } - - *de = nde; - return 0; -} - -/* - * tmpfs_free_dirent: free a directory entry. - * - * => It is the caller's responsibility to destroy the referenced inode. - * => The link count of inode is decreased by one to reflect the removal of - * an object that referenced it. This only happens if 'node_exists' is true; - * otherwise the function will not access the node referred to by the - * directory entry, as it may already have been released from the outside. - * - * Interested parties (kqueue) are notified of the link count change; note - * that this can include both the node pointed to by the directory entry - * as well as its parent. - */ -void -tmpfs_free_dirent(tmpfs_mount_t *tmp, tmpfs_dirent_t *de, bool node_exists) -{ - - if (node_exists && de->td_node != TMPFS_NODE_WHITEOUT) { - tmpfs_node_t *node = de->td_node; - - KASSERT(node->tn_links > 0); - node->tn_links--; - if (node->tn_vnode != NULL) { - VN_KNOTE(node->tn_vnode, node->tn_links == 0 ? - NOTE_DELETE : NOTE_LINK); - } - if (node->tn_type == VDIR) { - VN_KNOTE(node->tn_spec.tn_dir.tn_parent->tn_vnode, - NOTE_LINK); - } - } - tmpfs_strname_free(tmp, de->td_name, de->td_namelen); - tmpfs_dirent_put(tmp, de); -} - -/* * tmpfs_alloc_vp: allocate or reclaim a vnode for a specified inode. * * => Returns vnode (*vpp) locked. @@ -429,10 +358,81 @@ } /* + * tmpfs_alloc_dirent: allocates a new directory entry for the inode. + * + * The link count of node is increased by one to reflect the new object + * referencing it. This takes care of notifying kqueue listeners about + * this change. + */ +int +tmpfs_alloc_dirent(tmpfs_mount_t *tmp, tmpfs_node_t *node, +const char *name, uint16_t len, tmpfs_dirent_t **de) +{ + tmpfs_dirent_t *nde; + + nde = tmpfs_dirent_get(tmp); + if (nde == NULL) + return ENOSPC; + + nde->td_name = tmpfs_strname_alloc(tmp, len); + if (nde->td_name == NULL) { + tmpfs_dirent_put(tmp, nde); + return ENOSPC; + } + nde->td_namelen = len; + memcpy(nde->td_name, name, len); + nde->td_node = node; + + if (node != TMPFS_NODE_WHITEOUT) { + node->tn_links++; + if (node->tn_links > 1 && node->tn_vnode != NULL) + VN_KNOTE(node->tn_vnode, NOTE_LINK); + } + + *de = nde; + return 0; +} + +/* + * tmpfs_free_dirent: free a directory entry. + * + * => It is the caller's responsibility to destroy the referenced inode. + * => The link count of inode is decreased by one to reflect the removal of + * an object that referenced it. This only happens if 'node_exists' is true; + * otherwise the function will not access the node referred to by the + * directory entry, as it may already have been released from the outside. + * + * Interested parties (kqueue) are notified of the link count change; note + * that this can include both the node pointed to by the directory entry + * as well
CVS commit: src/sys/arch/alpha
Module Name:src Committed By: rmind Date: Tue May 24 20:26:35 UTC 2011 Modified Files: src/sys/arch/alpha/alpha: machdep.c prom.c vm_machdep.c src/sys/arch/alpha/include: pcb.h prom.h src/sys/arch/alpha/pci: ttwoga_pci.c Log Message: Convert some simple_lock uses to mutex(9). Tested by: jak@, mhitch@ To generate a diff of this commit: cvs rdiff -u -r1.332 -r1.333 src/sys/arch/alpha/alpha/machdep.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/alpha/alpha/prom.c cvs rdiff -u -r1.105 -r1.106 src/sys/arch/alpha/alpha/vm_machdep.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/include/pcb.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/include/prom.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/pci/ttwoga_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/machdep.c diff -u src/sys/arch/alpha/alpha/machdep.c:1.332 src/sys/arch/alpha/alpha/machdep.c:1.333 --- src/sys/arch/alpha/alpha/machdep.c:1.332 Fri Apr 15 21:24:00 2011 +++ src/sys/arch/alpha/alpha/machdep.c Tue May 24 20:26:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.332 2011/04/15 21:24:00 martin Exp $ */ +/* $NetBSD: machdep.c,v 1.333 2011/05/24 20:26:34 rmind Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.332 2011/04/15 21:24:00 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.333 2011/05/24 20:26:34 rmind Exp $"); #include #include @@ -657,7 +657,7 @@ */ pcb0->pcb_hw.apcb_ksp = v + USPACE - sizeof(struct trapframe); lwp0.l_md.md_tf = (struct trapframe *)pcb0->pcb_hw.apcb_ksp; - simple_lock_init(&pcb0->pcb_fpcpu_slock); + mutex_init(&pcb0->pcb_fpcpu_lock, MUTEX_DEFAULT, IPL_HIGH); /* Indicate that lwp0 has a CPU. */ lwp0.l_cpu = ci; Index: src/sys/arch/alpha/alpha/prom.c diff -u src/sys/arch/alpha/alpha/prom.c:1.46 src/sys/arch/alpha/alpha/prom.c:1.47 --- src/sys/arch/alpha/alpha/prom.c:1.46 Sat Nov 21 05:35:40 2009 +++ src/sys/arch/alpha/alpha/prom.c Tue May 24 20:26:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: prom.c,v 1.46 2009/11/21 05:35:40 rmind Exp $ */ +/* $NetBSD: prom.c,v 1.47 2011/05/24 20:26:34 rmind Exp $ */ /* * Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University @@ -27,13 +27,12 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.46 2009/11/21 05:35:40 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.47 2011/05/24 20:26:34 rmind Exp $"); #include "opt_multiprocessor.h" #include #include -#include #include #include @@ -55,7 +54,7 @@ extern struct prom_vec prom_dispatch_v; -struct simplelock prom_slock; +static kmutex_t prom_lock; #ifdef _PMAP_MAY_USE_PROM_CONSOLE int prom_mapped = 1; /* Is PROM still mapped? */ @@ -86,7 +85,7 @@ prom_dispatch_v.routine_arg = c->crb_v_dispatch; prom_dispatch_v.routine = c->crb_v_dispatch->entry_va; - simple_lock_init(&prom_slock); + mutex_init(&prom_lock, MUTEX_DEFAULT, IPL_HIGH); } void @@ -107,13 +106,11 @@ static void prom_cache_sync(void); #endif -int +void prom_enter(void) { - int s; - s = splhigh(); - simple_lock(&prom_slock); + mutex_enter(&prom_lock); #ifdef _PMAP_MAY_USE_PROM_CONSOLE /* @@ -134,11 +131,10 @@ prom_cache_sync(); /* XXX */ } #endif - return s; } void -prom_leave(int s) +prom_leave(void) { #ifdef _PMAP_MAY_USE_PROM_CONSOLE @@ -157,8 +153,7 @@ prom_cache_sync(); /* XXX */ } #endif - simple_unlock(&prom_slock); - splx(s); + mutex_exit(&prom_lock); } #ifdef _PMAP_MAY_USE_PROM_CONSOLE @@ -185,16 +180,15 @@ { prom_return_t ret; unsigned char *to = (unsigned char *)0x2000; - int s; - s = prom_enter(); /* splhigh() and map prom */ + prom_enter(); *to = c; do { ret.bits = prom_putstr(alpha_console, to, 1); } while ((ret.u.retval & 1) == 0); - prom_leave(s); /* unmap prom and splx(s) */ + prom_leave(); } /* @@ -206,12 +200,11 @@ promcngetc(dev_t dev) { prom_return_t ret; - int s; for (;;) { - s = prom_enter(); + prom_enter(); ret.bits = prom_getc(alpha_console); - prom_leave(s); + prom_leave(); if (ret.u.status == 0 || ret.u.status == 1) return (ret.u.retval); } @@ -226,11 +219,10 @@ promcnlookc(dev_t dev, char *cp) { prom_return_t ret; - int s; - s = prom_enter(); + prom_enter(); ret.bits = prom_getc(alpha_console); - prom_leave(s); + prom_leave(); if (ret.u.status == 0 || ret.u.status == 1) { *cp = ret.u.retval; return 1; @@ -243,12 +235,11 @@ { unsigned char *to = (unsigned char *)0x2000; prom_return_t ret; - int s; - s = prom_enter(); + prom_enter(); ret.bits = prom_getenv_disp(id, to, len); memcpy(buf, to, len); - prom_leave(s); + prom_leave();
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Tue May 24 14:18:03 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_free_node: comment out assert, which can fire e.g. on shutdown. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.65 src/sys/fs/tmpfs/tmpfs_subr.c:1.66 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.65 Tue May 24 01:09:47 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Tue May 24 14:18:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.65 2011/05/24 01:09:47 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.66 2011/05/24 14:18:03 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.65 2011/05/24 01:09:47 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.66 2011/05/24 14:18:03 rmind Exp $"); #include #include @@ -201,7 +201,7 @@ } break; case VDIR: - KASSERT(TAILQ_EMPTY(&node->tn_spec.tn_dir.tn_dir)); + /* KASSERT(TAILQ_EMPTY(&node->tn_spec.tn_dir.tn_dir)); */ KASSERT(node->tn_spec.tn_dir.tn_parent || node == tmp->tm_root); break; default:
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Tue May 24 01:09:48 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c tmpfs_subr.c tmpfs_vfsops.c Log Message: - tmpfs_alloc_node/tmpfs_free_node: move inode limiting into tmpfs_node_get() and tmpfs_node_put(), update outdated/wrong comments and move/add asserts. - tmpfs_mount: check for the version of arguments a bit earlier. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.48 -r1.49 src/sys/fs/tmpfs/tmpfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.3 src/sys/fs/tmpfs/tmpfs_mem.c:1.4 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.3 Thu May 19 03:21:23 2011 +++ src/sys/fs/tmpfs/tmpfs_mem.c Tue May 24 01:09:47 2011 @@ -1,9 +1,12 @@ -/* $NetBSD: tmpfs_mem.c,v 1.3 2011/05/19 03:21:23 rmind Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.4 2011/05/24 01:09:47 rmind Exp $ */ /* - * Copyright (c) 2010 The NetBSD Foundation, Inc. + * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Mindaugas Rasiukevicius. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -32,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.3 2011/05/19 03:21:23 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.4 2011/05/24 01:09:47 rmind Exp $"); #include #include @@ -161,6 +164,10 @@ tmpfs_node_get(struct tmpfs_mount *mp) { + if (atomic_inc_uint_nv(&mp->tm_nodes_cnt) >= mp->tm_nodes_max) { + atomic_dec_uint(&mp->tm_nodes_cnt); + return NULL; + } if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_node))) { return NULL; } @@ -171,6 +178,7 @@ tmpfs_node_put(struct tmpfs_mount *mp, struct tmpfs_node *tn) { + atomic_dec_uint(&mp->tm_nodes_cnt); tmpfs_mem_decr(mp, sizeof(struct tmpfs_node)); pool_put(&tmpfs_node_pool, tn); } Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.64 src/sys/fs/tmpfs/tmpfs_subr.c:1.65 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.64 Sun May 22 04:20:50 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Tue May 24 01:09:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.64 2011/05/22 04:20:50 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.65 2011/05/24 01:09:47 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.64 2011/05/22 04:20:50 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.65 2011/05/24 01:09:47 rmind Exp $"); #include #include @@ -61,29 +61,9 @@ #include #include -/* - */ - /* - * Allocates a new node of type 'type' inside the 'tmp' mount point, with - * its owner set to 'uid', its group to 'gid' and its mode set to 'mode', - * using the credentials of the process 'p'. - * - * If the node type is set to 'VDIR', then the parent parameter must point - * to the parent directory of the node being created. It may only be NULL - * while allocating the root node. - * - * If the node type is set to 'VBLK' or 'VCHR', then the rdev parameter - * specifies the device the node represents. - * - * If the node type is set to 'VLNK', then the parameter target specifies - * the file name of the target file for the symbolic link that is being - * created. - * - * Note that new nodes are retrieved from the available list if it has - * items or, if it is empty, from the node pool as long as there is enough - * space to create them. - * - * Returns zero on success or an appropriate error code on failure. + * tmpfs_alloc_node: allocate a new inode of a specified type and + * insert it into the list of specified mount point. */ int tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type, @@ -92,24 +72,8 @@ { struct tmpfs_node *nnode; - /* If the root directory of the 'tmp' file system is not yet - * allocated, this must be the request to do it. */ - KASSERT(IMPLIES(tmp->tm_root == NULL, parent == NULL && type == VDIR)); - - KASSERT(IFF(type == VLNK, target != NULL)); - KASSERT(IFF(type == VBLK || type == VCHR, rdev != VNOVAL)); - - KASSERT(uid != VNOVAL && gid != VNOVAL && mode != VNOVAL); - - nnode = NULL; - if (atomic_inc_uint_nv(&tmp->tm_nodes_cnt) >= tmp->tm_nodes_max) { - atomic_dec_uint(&tmp->tm_nodes_cnt); - return ENOSPC; - } - nnode = tmpfs_node_get(tmp);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: rmind Date: Mon May 23 22:02:26 UTC 2011 Modified Files: src/sys/ufs/ufs: ufs_wapbl.c Log Message: ufs_wapbl_verify_inodes: update to reality (if somebody decides to use this). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/ufs/ufs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_wapbl.c diff -u src/sys/ufs/ufs/ufs_wapbl.c:1.12 src/sys/ufs/ufs/ufs_wapbl.c:1.13 --- src/sys/ufs/ufs/ufs_wapbl.c:1.12 Sun Jan 2 05:09:32 2011 +++ src/sys/ufs/ufs/ufs_wapbl.c Mon May 23 22:02:26 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_wapbl.c,v 1.12 2011/01/02 05:09:32 dholland Exp $ */ +/* $NetBSD: ufs_wapbl.c,v 1.13 2011/05/23 22:02:26 rmind Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_wapbl.c,v 1.12 2011/01/02 05:09:32 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_wapbl.c,v 1.13 2011/05/23 22:02:26 rmind Exp $"); #include #include @@ -699,8 +699,9 @@ { struct vnode *vp, *nvp; struct inode *ip; + struct buf *bp, *nbp; - simple_lock(&mntvnode_slock); + mutex_enter(&mntvnode_lock); loop: TAILQ_FOREACH_REVERSE(vp, &mp->mnt_vnodelist, vnodelst, v_mntvnodes) { /* @@ -709,11 +710,11 @@ */ if (vp->v_mount != mp) goto loop; - simple_lock(&vp->v_interlock); + mutex_enter(&vp->v_interlock); nvp = TAILQ_NEXT(vp, v_mntvnodes); ip = VTOI(vp); if (vp->v_type == VNON) { - simple_unlock(&vp->v_interlock); + mutex_exit(&vp->v_interlock); continue; } /* verify that update has been called on all inodes */ @@ -721,55 +722,36 @@ panic("wapbl_verify: mp %p: dirty vnode %p (inode %p): 0x%x\n", mp, vp, ip, ip->i_flag); } + mutex_exit(&mntvnode_lock); - simple_unlock(&mntvnode_slock); - { - int s; - struct buf *bp; - struct buf *nbp; - s = splbio(); - for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { -nbp = LIST_NEXT(bp, b_vnbufs); -simple_lock(&bp->b_interlock); -if ((bp->b_flags & B_BUSY)) { - simple_unlock(&bp->b_interlock); - continue; -} -if ((bp->b_flags & B_DELWRI) == 0) - panic("wapbl_verify: not dirty, bp %p", bp); -if ((bp->b_flags & B_LOCKED) == 0) - panic("wapbl_verify: not locked, bp %p", bp); -simple_unlock(&bp->b_interlock); + mutex_enter(&bufcache_lock); + for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { + nbp = LIST_NEXT(bp, b_vnbufs); + if ((bp->b_cflags & BC_BUSY)) { +continue; } - splx(s); + KASSERT((bp->b_oflags & BO_DELWRI) != 0); + KASSERT((bp->b_flags & B_LOCKED) != 0); } - simple_unlock(&vp->v_interlock); - simple_lock(&mntvnode_slock); + mutex_exit(&bufcache_lock); + mutex_exit(&vp->v_interlock); + + mutex_enter(&mntvnode_lock); } - simple_unlock(&mntvnode_slock); + mutex_exit(&mntvnode_lock); vp = VFSTOUFS(mp)->um_devvp; - simple_lock(&vp->v_interlock); - { - int s; - struct buf *bp; - struct buf *nbp; - s = splbio(); - for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = LIST_NEXT(bp, b_vnbufs); - simple_lock(&bp->b_interlock); - if ((bp->b_flags & B_BUSY)) { -simple_unlock(&bp->b_interlock); -continue; - } - if ((bp->b_flags & B_DELWRI) == 0) -panic("wapbl_verify: devvp not dirty, bp %p", bp); - if ((bp->b_flags & B_LOCKED) == 0) -panic("wapbl_verify: devvp not locked, bp %p", bp); - simple_unlock(&bp->b_interlock); + mutex_enter(&vp->v_interlock); + mutex_enter(&bufcache_lock); + for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { + nbp = LIST_NEXT(bp, b_vnbufs); + if ((bp->b_cflags & BC_BUSY)) { + continue; } - splx(s); + KASSERT((bp->b_oflags & BO_DELWRI) != 0); + KASSERT((bp->b_flags & B_LOCKED) != 0); } - simple_unlock(&vp->v_interlock); + mutex_exit(&bufcache_lock); + mutex_exit(&vp->v_interlock); } #endif /* WAPBL_DEBUG_INODES */
CVS commit: src/sys/fs
Module Name:src Committed By: rmind Date: Mon May 23 22:00:31 UTC 2011 Modified Files: src/sys/fs/adosfs: adutil.c advfsops.c src/sys/fs/filecorefs: filecore_extern.h filecore_node.c filecore_vfsops.c filecore_vnops.c Log Message: Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9). To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/fs/adosfs/adutil.c cvs rdiff -u -r1.60 -r1.61 src/sys/fs/adosfs/advfsops.c cvs rdiff -u -r1.19 -r1.20 src/sys/fs/filecorefs/filecore_extern.h cvs rdiff -u -r1.23 -r1.24 src/sys/fs/filecorefs/filecore_node.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/filecorefs/filecore_vfsops.c cvs rdiff -u -r1.32 -r1.33 src/sys/fs/filecorefs/filecore_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/adosfs/adutil.c diff -u src/sys/fs/adosfs/adutil.c:1.13 src/sys/fs/adosfs/adutil.c:1.14 --- src/sys/fs/adosfs/adutil.c:1.13 Wed Jul 21 17:52:09 2010 +++ src/sys/fs/adosfs/adutil.c Mon May 23 22:00:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: adutil.c,v 1.13 2010/07/21 17:52:09 hannken Exp $ */ +/* $NetBSD: adutil.c,v 1.14 2011/05/23 22:00:30 rmind Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,18 +32,16 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: adutil.c,v 1.13 2010/07/21 17:52:09 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adutil.c,v 1.14 2011/05/23 22:00:30 rmind Exp $"); #include #include #include #include #include -#include #include #include #include -#include #include /* @@ -52,7 +50,7 @@ #define AHASH(an) ((an) & (ANODEHASHSZ - 1)) static int CapitalChar(int, int); -extern struct simplelock adosfs_hashlock; +extern kmutex_t adosfs_hashlock; struct vnode * adosfs_ahashget(struct mount *mp, ino_t an) @@ -64,18 +62,18 @@ hp = &VFSTOADOSFS(mp)->anodetab[AHASH(an)]; start_over: - simple_lock(&adosfs_hashlock); + mutex_enter(&adosfs_hashlock); for (ap = hp->lh_first; ap != NULL; ap = ap->link.le_next) { if (ap->block == an) { vp = ATOV(ap); mutex_enter(&vp->v_interlock); - simple_unlock(&adosfs_hashlock); + mutex_exit(&adosfs_hashlock); if (vget(vp, LK_EXCLUSIVE)) goto start_over; return (ATOV(ap)); } } - simple_unlock(&adosfs_hashlock); + mutex_exit(&adosfs_hashlock); return (NULL); } @@ -89,17 +87,17 @@ { VOP_LOCK(ATOV(ap), LK_EXCLUSIVE); - simple_lock(&adosfs_hashlock); + mutex_enter(&adosfs_hashlock); LIST_INSERT_HEAD(&->anodetab[AHASH(ap->block)], ap, link); - simple_unlock(&adosfs_hashlock); + mutex_exit(&adosfs_hashlock); } void adosfs_aremhash(struct anode *ap) { - simple_lock(&adosfs_hashlock); + mutex_enter(&adosfs_hashlock); LIST_REMOVE(ap, link); - simple_unlock(&adosfs_hashlock); + mutex_exit(&adosfs_hashlock); } int Index: src/sys/fs/adosfs/advfsops.c diff -u src/sys/fs/adosfs/advfsops.c:1.60 src/sys/fs/adosfs/advfsops.c:1.61 --- src/sys/fs/adosfs/advfsops.c:1.60 Thu Jun 24 13:03:08 2010 +++ src/sys/fs/adosfs/advfsops.c Mon May 23 22:00:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.60 2010/06/24 13:03:08 hannken Exp $ */ +/* $NetBSD: advfsops.c,v 1.61 2011/05/23 22:00:30 rmind Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.60 2010/06/24 13:03:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.61 2011/05/23 22:00:30 rmind Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -57,7 +57,6 @@ #include #include #include -#include #include #include @@ -70,13 +69,11 @@ int adosfs_mountfs(struct vnode *, struct mount *, struct lwp *); int adosfs_loadbitmap(struct adosfsmount *); -struct simplelock adosfs_hashlock; +kmutex_t adosfs_hashlock; struct pool adosfs_node_pool; -MALLOC_JUSTDEFINE(M_ADOSFSMNT, "adosfs mount", "adosfs mount structures"); MALLOC_JUSTDEFINE(M_ANODE, "adosfs anode","adosfs anode structures and tables"); -MALLOC_JUSTDEFINE(M_ADOSFSBITMAP, "adosfs bitmap", "adosfs bitmap"); static const struct genfs_ops adosfs_genfsops = { .gop_size = genfs_size, @@ -167,6 +164,7 @@ struct adosfsmount *amp; struct buf *bp; struct vnode *rvp; + size_t bitmap_sz = 0; int error, part, i; part = DISKPART(devvp->v_rdev); @@ -185,8 +183,7 @@ goto fail; parp = &dl.d_partitions[part]; - amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK); - memset((char *)amp, 0, (u_long)sizeof(struct adosfsmount)); + amp = kmem_zalloc(sizeof(struct adosfsmount), KM_SLEEP); amp->mp = mp; if (dl.d_type == DTYPE_FLOPPY) { amp->bsize = dl.d_secsize; @@ -246,15 +243,15 @@ if ((error = VFS_ROOT(mp, &rvp)) != 0) goto fail; /* allocate and load bitmap, set free space */ - amp->bitmap = malloc(((amp->numblks + 31) / 32) * sizeof(*amp->bitmap), - M_ADOSFSBITMAP, M_WAITOK); + bitmap_sz = ((amp->numblks + 31) / 32) * sizeof(*amp-
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: rmind Date: Mon May 23 18:40:30 UTC 2011 Modified Files: src/sys/arch/sparc/sparc: intr.c Log Message: nmi_hard: convert nmi_hard_wait to use atomics. OK mrg@ To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/sparc/sparc/intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/intr.c diff -u src/sys/arch/sparc/sparc/intr.c:1.114 src/sys/arch/sparc/sparc/intr.c:1.115 --- src/sys/arch/sparc/sparc/intr.c:1.114 Tue Feb 15 10:59:25 2011 +++ src/sys/arch/sparc/sparc/intr.c Mon May 23 18:40:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.114 2011/02/15 10:59:25 mrg Exp $ */ +/* $NetBSD: intr.c,v 1.115 2011/05/23 18:40:30 rmind Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.114 2011/02/15 10:59:25 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.115 2011/05/23 18:40:30 rmind Exp $"); #include "opt_multiprocessor.h" #include "opt_sparc_arch.h" @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include @@ -187,9 +187,8 @@ int (*moduleerr_handler)(void); #if defined(MULTIPROCESSOR) -volatile int nmi_hard_wait = 0; -struct simplelock nmihard_lock = SIMPLELOCK_INITIALIZER; -int drop_into_rom_on_fatal = 1; +static volatile u_int nmi_hard_wait = 0; +int drop_into_rom_on_fatal = 1; #endif void @@ -221,9 +220,7 @@ * variable is non-zero. If we are the master, loop while this * variable is less than the number of cpus. */ - simple_lock(&nmihard_lock); - nmi_hard_wait++; - simple_unlock(&nmihard_lock); + atomic_inc_uint(&nmi_hard_wait); if (cpuinfo.master == 0) { while (nmi_hard_wait) @@ -275,9 +272,7 @@ /* * Tell everyone else we've finished dealing with the hard NMI. */ - simple_lock(&nmihard_lock); nmi_hard_wait = 0; - simple_unlock(&nmihard_lock); if (fatal && drop_into_rom_on_fatal) { prom_abort(); return;
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: rmind Date: Mon May 23 18:38:51 UTC 2011 Modified Files: src/sys/arch/sparc64/sparc64: kgdb_machdep.c Log Message: kgdb_acc: use mutex since pm_lock was converted to it. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/sparc64/kgdb_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/sparc64/kgdb_machdep.c diff -u src/sys/arch/sparc64/sparc64/kgdb_machdep.c:1.14 src/sys/arch/sparc64/sparc64/kgdb_machdep.c:1.15 --- src/sys/arch/sparc64/sparc64/kgdb_machdep.c:1.14 Wed Mar 18 10:22:37 2009 +++ src/sys/arch/sparc64/sparc64/kgdb_machdep.c Mon May 23 18:38:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_machdep.c,v 1.14 2009/03/18 10:22:37 cegger Exp $ */ +/* $NetBSD: kgdb_machdep.c,v 1.15 2011/05/23 18:38:51 rmind Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. @@ -121,7 +121,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.14 2009/03/18 10:22:37 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.15 2011/05/23 18:38:51 rmind Exp $"); #include "opt_kgdb.h" #include "opt_multiprocessor.h" @@ -385,15 +385,15 @@ eva = round_page(va + len); va = trunc_page(va); - simple_lock(&pm->pm_lock); + mutex_enter(&pm->pm_lock); for (; va < eva; va += PAGE_SIZE) { data = pseg_get(pm, va); if ((data & TLB_V) == 0) { - simple_unlock(&pm->pm_lock); + mutex_exit(&pm->pm_lock); return 0; } } - simple_unlock(&pm->pm_lock); + mutex_exit(&pm->pm_lock); return (1); }
CVS commit: [rmind-uvmplock] src/sys/nfs
Module Name:src Committed By: rmind Date: Sun May 22 21:52:12 UTC 2011 Modified Files: src/sys/nfs [rmind-uvmplock]: nfs_node.c Log Message: nfs_gop_write: acquire the lock for pmap_page_protect() operation. To generate a diff of this commit: cvs rdiff -u -r1.110.4.4 -r1.110.4.5 src/sys/nfs/nfs_node.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/nfs/nfs_node.c diff -u src/sys/nfs/nfs_node.c:1.110.4.4 src/sys/nfs/nfs_node.c:1.110.4.5 --- src/sys/nfs/nfs_node.c:1.110.4.4 Thu May 19 03:43:03 2011 +++ src/sys/nfs/nfs_node.c Sun May 22 21:52:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_node.c,v 1.110.4.4 2011/05/19 03:43:03 rmind Exp $ */ +/* $NetBSD: nfs_node.c,v 1.110.4.5 2011/05/22 21:52:12 rmind Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.110.4.4 2011/05/19 03:43:03 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.110.4.5 2011/05/22 21:52:12 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_nfs.h" @@ -346,9 +346,12 @@ { int i; + mutex_enter(vp->v_interlock); for (i = 0; i < npages; i++) { pmap_page_protect(pgs[i], VM_PROT_READ); } + mutex_exit(vp->v_interlock); + return genfs_gop_write(vp, pgs, npages, flags); }
CVS commit: [rmind-uvmplock] src/sys
Module Name:src Committed By: rmind Date: Sun May 22 04:29:04 UTC 2011 Modified Files: src/sys/fs/tmpfs [rmind-uvmplock]: tmpfs_subr.c src/sys/kern [rmind-uvmplock]: vfs_vnode.c Log Message: Fix vnode interlock sharing. To generate a diff of this commit: cvs rdiff -u -r1.56.4.5 -r1.56.4.6 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.5.2.3 -r1.5.2.4 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.5 src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.6 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.56.4.5 Thu May 19 03:43:02 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sun May 22 04:29:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.56.4.5 2011/05/19 03:43:02 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.56.4.6 2011/05/22 04:29:04 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.5 2011/05/19 03:43:02 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.6 2011/05/22 04:29:04 rmind Exp $"); #include #include @@ -373,6 +373,7 @@ /* Set UVM object to use vnode_t::v_interlock (share it). */ uvm_obj_setlock(node->tn_spec.tn_reg.tn_aobj, vp->v_interlock); + mutex_obj_hold(vp->v_interlock); error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0) { Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.5.2.3 src/sys/kern/vfs_vnode.c:1.5.2.4 --- src/sys/kern/vfs_vnode.c:1.5.2.3 Thu May 19 03:43:03 2011 +++ src/sys/kern/vfs_vnode.c Sun May 22 04:29:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.5.2.3 2011/05/19 03:43:03 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.5.2.4 2011/05/22 04:29:04 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5.2.3 2011/05/19 03:43:03 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5.2.4 2011/05/22 04:29:04 rmind Exp $"); #include #include @@ -424,6 +424,7 @@ if (svp) { /* Set the interlock and mark that it is shared. */ KASSERT(vp->v_mount == NULL); + mutex_obj_hold(svp->v_interlock); uvm_obj_setlock(&vp->v_uobj, svp->v_interlock); KASSERT(vp->v_interlock == svp->v_interlock); vp->v_iflag |= VI_LOCKSHARE;
CVS commit: src/sys/arch/xen
Module Name:src Committed By: rmind Date: Sun May 22 04:27:16 UTC 2011 Modified Files: src/sys/arch/xen/xen: xenevt.c src/sys/arch/xen/xenbus: xenbus_xs.c Log Message: - Replace uses of simple_lock and ltsleep with mutex and condvar. - Improve some parts of the code to be more MP-friendly. Tested by jakllsch@. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/xen/xen/xenevt.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/xenbus/xenbus_xs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xenevt.c diff -u src/sys/arch/xen/xen/xenevt.c:1.36 src/sys/arch/xen/xen/xenevt.c:1.37 --- src/sys/arch/xen/xen/xenevt.c:1.36 Sun Dec 20 09:36:05 2009 +++ src/sys/arch/xen/xen/xenevt.c Sun May 22 04:27:15 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xenevt.c,v 1.36 2009/12/20 09:36:05 dsl Exp $ */ +/* $NetBSD: xenevt.c,v 1.37 2011/05/22 04:27:15 rmind Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -26,12 +26,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.36 2009/12/20 09:36:05 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.37 2011/05/22 04:27:15 rmind Exp $"); #include "opt_xen.h" #include #include #include +#include #include #include #include @@ -42,7 +43,6 @@ #include #include #include -#include #include @@ -103,7 +103,8 @@ #define BYTES_PER_PORT (sizeof(evtchn_port_t) / sizeof(uint8_t)) struct xenevt_d { - struct simplelock lock; + kmutex_t lock; + kcondvar_t cv; STAILQ_ENTRY(xenevt_d) pendingq; bool pending; evtchn_port_t ring[2048]; @@ -119,9 +120,8 @@ /* pending events */ static void *devevent_sih; -struct simplelock devevent_pending_lock = SIMPLELOCK_INITIALIZER; -STAILQ_HEAD(, xenevt_d) devevent_pending = -STAILQ_HEAD_INITIALIZER(devevent_pending); +static kmutex_t devevent_lock; +static STAILQ_HEAD(, xenevt_d) devevent_pending; static void xenevt_donotify(struct xenevt_d *); static void xenevt_record(struct xenevt_d *, evtchn_port_t); @@ -142,6 +142,8 @@ bool mpsafe = (level != IPL_VM); #endif /* MULTIPROCESSOR */ + mutex_init(&devevent_lock, MUTEX_DEFAULT, IPL_HIGH); + STAILQ_INIT(&devevent_pending); devevent_sih = softint_establish(SOFTINT_SERIAL, (void (*)(void *))xenevt_notify, NULL); @@ -218,10 +220,11 @@ return; } - simple_lock(&devevent_pending_lock); + mutex_enter(&devevent_lock); STAILQ_INSERT_TAIL(&devevent_pending, d, pendingq); - simple_unlock(&devevent_pending_lock); d->pending = true; + mutex_exit(&devevent_lock); + softint_schedule(devevent_sih); } } @@ -229,43 +232,31 @@ void xenevt_notify(void) { + struct xenevt_d *d; - int s = splhigh(); - simple_lock(&devevent_pending_lock); - while (/* CONSTCOND */ 1) { - struct xenevt_d *d; - + for (;;) { + mutex_enter(&devevent_lock); d = STAILQ_FIRST(&devevent_pending); if (d == NULL) { + mutex_exit(&devevent_lock); break; } STAILQ_REMOVE_HEAD(&devevent_pending, pendingq); - simple_unlock(&devevent_pending_lock); - splx(s); - d->pending = false; - xenevt_donotify(d); + mutex_exit(&devevent_lock); - s = splhigh(); - simple_lock(&devevent_pending_lock); + xenevt_donotify(d); } - simple_unlock(&devevent_pending_lock); - splx(s); } static void xenevt_donotify(struct xenevt_d *d) { - int s; - s = splsoftserial(); - simple_lock(&d->lock); - + mutex_enter(&d->lock); selnotify(&d->sel, 0, 1); - wakeup(&d->ring_read); - - simple_unlock(&d->lock); - splx(s); + cv_broadcast(&d->cv); + mutex_exit(&d->lock); } static void @@ -303,7 +294,8 @@ return error; d = malloc(sizeof(*d), M_DEVBUF, M_WAITOK | M_ZERO); - simple_lock_init(&d->lock); + mutex_init(&d->lock, MUTEX_DEFAULT, IPL_SOFTSERIAL); + cv_init(&d->cv, "xenevt"); selinit(&d->sel); return fd_clone(fp, fd, flags, &xenevt_fileops, d); case DEV_XSD: @@ -380,8 +372,10 @@ } } seldestroy(&d->sel); - free(d, M_DEVBUF); + cv_destroy(&d->cv); + mutex_destroy(&d->lock); fp->f_data = NULL; + free(d, M_DEVBUF); return (0); } @@ -391,15 +385,11 @@ kauth_cred_t cred, int flags) { struct xenevt_d *d = fp->f_data; - int error; + int error, ring_read, ring_write; size_t len, uio_len; - int ring_read; - int ring_write; - int s; error = 0; - s = splsoftserial(); - simple_lock(&d->lock); + mutex_enter(&d->lock); while (error == 0) { ring_read = d->ring_read; ring_write = d->ring_write; @@ -411,18 +401,16 @@ } /* nothing to read */ - if (fp->f_flag & FNONBLOCK) { - error = EAGAIN; + if ((fp->f_flag & FNONBLOCK) == 0) { + error = cv_wait_sig(&d->cv, &d->lock); } else { - error = ltsleep(&d->ring_read, PRIBIO | PCATCH, - "xenevt", 0, &d->lock); + error = EAGAIN; } } if (error == 0 && (d->flags & XENEVT_F_OVERFLOW)) { error = EFBIG; } - simple_unlock(&d->lock); - splx(s); + mutex_exit(&d->loc
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Sun May 22 04:20:51 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_alloc_vp: - Do not check for vn_lock(9) error, if LK_RETRY. - Fix/improve comments. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.63 src/sys/fs/tmpfs/tmpfs_subr.c:1.64 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.63 Fri Apr 1 17:40:54 2011 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sun May 22 04:20:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.63 2011/04/01 17:40:54 hannken Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.64 2011/05/22 04:20:50 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.63 2011/04/01 17:40:54 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.64 2011/05/22 04:20:50 rmind Exp $"); #include #include @@ -332,36 +332,28 @@ tmpfs_dirent_put(tmp, de); } -/* - */ - /* - * Allocates a new vnode for the node node or returns a new reference to - * an existing one if the node had already a vnode referencing it. The - * resulting locked vnode is returned in *vpp. + * tmpfs_alloc_vp: allocate or reclaim a vnode for a specified inode. * - * Returns zero on success or an appropriate error code on failure. + * => Returns vnode (*vpp) locked. */ int tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp) { + vnode_t *vp; int error; - struct vnode *vp; - - /* If there is already a vnode, then lock it. */ - for (;;) { - mutex_enter(&node->tn_vlock); - if ((vp = node->tn_vnode) != NULL) { - mutex_enter(&vp->v_interlock); - mutex_exit(&node->tn_vlock); - error = vget(vp, LK_EXCLUSIVE); - if (error == ENOENT) { -/* vnode was reclaimed. */ -continue; - } - *vpp = vp; - return error; +again: + /* If there is already a vnode, try to reclaim it. */ + mutex_enter(&node->tn_vlock); + if ((vp = node->tn_vnode) != NULL) { + mutex_enter(&vp->v_interlock); + mutex_exit(&node->tn_vlock); + error = vget(vp, LK_EXCLUSIVE); + if (error == ENOENT) { + goto again; } - break; + *vpp = vp; + return error; } /* Get a new vnode and associate it with our node. */ @@ -371,13 +363,7 @@ return error; } - error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - if (error != 0) { - mutex_exit(&node->tn_vlock); - ungetnewvnode(vp); - return error; - } - + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); vp->v_type = node->tn_type; /* Type-specific initialization. */ @@ -421,8 +407,6 @@ return error; } -/* - */ - /* * Destroys the association between the vnode vp and the node it * references.
CVS commit: [rmind-uvmplock] src/sys/uvm
Module Name:src Committed By: rmind Date: Sat May 21 21:26:48 UTC 2011 Modified Files: src/sys/uvm [rmind-uvmplock]: uvm_fault.c Log Message: uvm_fault_lower_promote: fix assert (move a bit up, where logic applies). To generate a diff of this commit: cvs rdiff -u -r1.173.2.7 -r1.173.2.8 src/sys/uvm/uvm_fault.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_fault.c diff -u src/sys/uvm/uvm_fault.c:1.173.2.7 src/sys/uvm/uvm_fault.c:1.173.2.8 --- src/sys/uvm/uvm_fault.c:1.173.2.7 Thu May 19 03:43:05 2011 +++ src/sys/uvm/uvm_fault.c Sat May 21 21:26:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_fault.c,v 1.173.2.7 2011/05/19 03:43:05 rmind Exp $ */ +/* $NetBSD: uvm_fault.c,v 1.173.2.8 2011/05/21 21:26:48 rmind Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.173.2.7 2011/05/19 03:43:05 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.173.2.8 2011/05/21 21:26:48 rmind Exp $"); #include "opt_uvmhist.h" @@ -2039,14 +2039,12 @@ int error; UVMHIST_FUNC("uvm_fault_lower_promote"); UVMHIST_CALLED(maphist); + KASSERT(amap != NULL); + /* - * if we are going to promote the data to an anon we + * If we are going to promote the data to an anon we * allocate a blank anon here and plug it into our amap. */ -#if DIAGNOSTIC - if (amap == NULL) - panic("uvm_fault: want to promote data, but no anon"); -#endif error = uvmfault_promote(ufi, NULL, uobjpage, &anon, &flt->anon_spare); switch (error) { @@ -2061,8 +2059,9 @@ pg = anon->an_page; /* - * fill in the data + * Fill in the data. */ + KASSERT(uobj == NULL || (uobjpage->flags & PG_BUSY) != 0); if (uobjpage != PGO_DONTCARE) { uvmexp.flt_prcopy++; @@ -2107,7 +2106,6 @@ anon, pg, 0, 0); } - KASSERT(uobj == NULL || (uobjpage->flags & PG_BUSY) != 0); return uvm_fault_lower_enter(ufi, flt, uobj, anon, pg); }
CVS commit: [rmind-uvmplock] src/sys/dev
Module Name:src Committed By: rmind Date: Sat May 21 03:39:17 UTC 2011 Modified Files: src/sys/dev [rmind-uvmplock]: mm.c Log Message: - Use MIN() instead of min(). - Use __read_mostly and __cacheline_aligned. To generate a diff of this commit: cvs rdiff -u -r1.13.16.5 -r1.13.16.6 src/sys/dev/mm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/mm.c diff -u src/sys/dev/mm.c:1.13.16.5 src/sys/dev/mm.c:1.13.16.6 --- src/sys/dev/mm.c:1.13.16.5 Sun Mar 6 01:38:45 2011 +++ src/sys/dev/mm.c Sat May 21 03:39:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: mm.c,v 1.13.16.5 2011/03/06 01:38:45 rmind Exp $ */ +/* $NetBSD: mm.c,v 1.13.16.6 2011/05/21 03:39:17 rmind Exp $ */ /*- * Copyright (c) 2002, 2008, 2010 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mm.c,v 1.13.16.5 2011/03/06 01:38:45 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mm.c,v 1.13.16.6 2011/05/21 03:39:17 rmind Exp $"); #include "opt_compat_netbsd.h" @@ -49,9 +49,9 @@ #include -static void * dev_zero_page; -static kmutex_t dev_mem_lock; -static vaddr_t dev_mem_addr; +static void * dev_zero_page __read_mostly; +static kmutex_t dev_mem_lock __cacheline_aligned; +static vaddr_t dev_mem_addr __read_mostly; static dev_type_read(mm_readwrite); static dev_type_ioctl(mm_ioctl); @@ -162,7 +162,7 @@ return error; } offset = uio->uio_offset & PAGE_MASK; - len = min(uio->uio_resid, PAGE_SIZE - offset); + len = MIN(uio->uio_resid, PAGE_SIZE - offset); #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS /* Is physical address directly mapped? Return VA. */ @@ -220,7 +220,7 @@ * Otherwise, we operate in page-by-page basis. */ offset = uio->uio_offset & PAGE_MASK; - len = min(uio->uio_resid, PAGE_SIZE - offset); + len = MIN(uio->uio_resid, PAGE_SIZE - offset); prot = (uio->uio_rw == UIO_WRITE) ? VM_PROT_WRITE : VM_PROT_READ; md_kva = false; @@ -273,7 +273,7 @@ * Read in page-by-page basis, caller will continue. * Cut appropriately for a single/last-iteration cases. */ - len = min(iov->iov_len, PAGE_SIZE); + len = MIN(iov->iov_len, PAGE_SIZE); return uiomove(dev_zero_page, len, uio); }
CVS commit: [rmind-uvmplock] src/sys/fs
Module Name:src Committed By: rmind Date: Sat May 21 03:38:25 UTC 2011 Modified Files: src/sys/fs/union [rmind-uvmplock]: union_subr.c src/sys/fs/unionfs [rmind-uvmplock]: unionfs_subr.c Log Message: Finish v_interlock sharing bits for union/unionfs. To generate a diff of this commit: cvs rdiff -u -r1.35.4.3 -r1.35.4.4 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.5.4.4 -r1.5.4.5 src/sys/fs/unionfs/unionfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.35.4.3 src/sys/fs/union/union_subr.c:1.35.4.4 --- src/sys/fs/union/union_subr.c:1.35.4.3 Thu May 19 03:43:02 2011 +++ src/sys/fs/union/union_subr.c Sat May 21 03:38:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.35.4.3 2011/05/19 03:43:02 rmind Exp $ */ +/* $NetBSD: union_subr.c,v 1.35.4.4 2011/05/21 03:38:24 rmind Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.35.4.3 2011/05/19 03:43:02 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.35.4.4 2011/05/21 03:38:24 rmind Exp $"); #include #include @@ -507,7 +507,12 @@ lowersz = va.va_size; hash = UNION_HASH(uppervp, lowervp); - error = getnewvnode(VT_UNION, mp, union_vnodeop_p, NULL, vpp); /* TODO */ + /* + * Get a new vnode and share the lock with upper layer vnode, + * unless layers are inverted. + */ + error = getnewvnode(VT_UNION, mp, union_vnodeop_p, + (uppervp != NULLVP ? uppervp : lowervp), vpp); if (error) { if (uppervp) { if (dvp == uppervp) Index: src/sys/fs/unionfs/unionfs_subr.c diff -u src/sys/fs/unionfs/unionfs_subr.c:1.5.4.4 src/sys/fs/unionfs/unionfs_subr.c:1.5.4.5 --- src/sys/fs/unionfs/unionfs_subr.c:1.5.4.4 Thu May 19 03:43:02 2011 +++ src/sys/fs/unionfs/unionfs_subr.c Sat May 21 03:38:25 2011 @@ -91,12 +91,13 @@ return (EINVAL); } - unp = kmem_zalloc(sizeof(*unp), KM_SLEEP); - if (unp == NULL) - return (ENOMEM); - error = getnewvnode(VT_UNION, mp, unionfs_vnodeop_p, NULL, &vp); /* TODO */ + /* + * Get a new vnode and share the lock with upper layer vnode, + * unless layers are inverted. + */ + error = getnewvnode(VT_UNION, mp, unionfs_vnodeop_p, + (uppervp != NULLVP ? uppervp : lowervp), &vp); if (error != 0) { - kmem_free(unp, sizeof(*unp)); return (error); } if (dvp != NULLVP) @@ -106,6 +107,7 @@ if (lowervp != NULLVP) vref(lowervp); + unp = kmem_zalloc(sizeof(*unp), KM_SLEEP); unp->un_vnode = vp; unp->un_uppervp = uppervp; unp->un_lowervp = lowervp;
CVS commit: [rmind-uvmplock] src/sys
Module Name:src Committed By: rmind Date: Sat May 21 03:35:22 UTC 2011 Modified Files: src/sys/fs/hfs [rmind-uvmplock]: hfs_vfsops.c src/sys/ufs/lfs [rmind-uvmplock]: lfs_vnops.c Log Message: Fix the build. To generate a diff of this commit: cvs rdiff -u -r1.25.4.2 -r1.25.4.3 src/sys/fs/hfs/hfs_vfsops.c cvs rdiff -u -r1.226.4.5 -r1.226.4.6 src/sys/ufs/lfs/lfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/hfs/hfs_vfsops.c diff -u src/sys/fs/hfs/hfs_vfsops.c:1.25.4.2 src/sys/fs/hfs/hfs_vfsops.c:1.25.4.3 --- src/sys/fs/hfs/hfs_vfsops.c:1.25.4.2 Thu May 19 03:43:01 2011 +++ src/sys/fs/hfs/hfs_vfsops.c Sat May 21 03:35:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hfs_vfsops.c,v 1.25.4.2 2011/05/19 03:43:01 rmind Exp $ */ +/* $NetBSD: hfs_vfsops.c,v 1.25.4.3 2011/05/21 03:35:21 rmind Exp $ */ /*- * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.25.4.2 2011/05/19 03:43:01 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.25.4.3 2011/05/21 03:35:21 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -546,7 +546,7 @@ return 0; /* Allocate a new vnode/inode. */ - error = getnewvnode(VT_HFS, mp, hfs_vnodeop_p, NULL, &vp) + error = getnewvnode(VT_HFS, mp, hfs_vnodeop_p, NULL, &vp); if (error) { goto error; } Index: src/sys/ufs/lfs/lfs_vnops.c diff -u src/sys/ufs/lfs/lfs_vnops.c:1.226.4.5 src/sys/ufs/lfs/lfs_vnops.c:1.226.4.6 --- src/sys/ufs/lfs/lfs_vnops.c:1.226.4.5 Thu May 19 03:43:05 2011 +++ src/sys/ufs/lfs/lfs_vnops.c Sat May 21 03:35:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vnops.c,v 1.226.4.5 2011/05/19 03:43:05 rmind Exp $ */ +/* $NetBSD: lfs_vnops.c,v 1.226.4.6 2011/05/21 03:35:22 rmind Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.226.4.5 2011/05/19 03:43:05 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.226.4.6 2011/05/21 03:35:22 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -474,7 +474,7 @@ if (fs->lfs_ronly) return EROFS; if (vpp == NULL) { - return lfs_set_dirop(dvp, NULL) + return lfs_set_dirop(dvp, NULL); } error = getnewvnode(VT_LFS, dvp->v_mount, lfs_vnodeop_p, NULL, vpp); if (error) {
CVS commit: src/sys/uvm
Module Name:src Committed By: rmind Date: Thu May 19 03:44:19 UTC 2011 Modified Files: src/sys/uvm: uvm_bio.c Log Message: ubc_release: use voff_t for offsets, rather than int. Constify. Reviewed by matt@. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/uvm/uvm_bio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_bio.c diff -u src/sys/uvm/uvm_bio.c:1.71 src/sys/uvm/uvm_bio.c:1.72 --- src/sys/uvm/uvm_bio.c:1.71 Tue Nov 30 10:55:25 2010 +++ src/sys/uvm/uvm_bio.c Thu May 19 03:44:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_bio.c,v 1.71 2010/11/30 10:55:25 hannken Exp $ */ +/* $NetBSD: uvm_bio.c,v 1.72 2011/05/19 03:44:19 rmind Exp $ */ /* * Copyright (c) 1998 Chuck Silvers. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.71 2010/11/30 10:55:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.72 2011/05/19 03:44:19 rmind Exp $"); #include "opt_uvmhist.h" #include "opt_ubc.h" @@ -630,15 +630,12 @@ KASSERT(uobj != NULL); if (umap->flags & UMAP_PAGES_LOCKED) { - int slot_offset = umap->writeoff; - int endoff = umap->writeoff + umap->writelen; - int zerolen = round_page(endoff) - endoff; - int npages = (int)(round_page(umap->writeoff + umap->writelen) - - trunc_page(umap->writeoff)) >> PAGE_SHIFT; + const voff_t slot_offset = umap->writeoff; + const voff_t endoff = umap->writeoff + umap->writelen; + const voff_t zerolen = round_page(endoff) - endoff; + const u_int npages = (round_page(endoff) - + trunc_page(slot_offset)) >> PAGE_SHIFT; struct vm_page *pgs[npages]; - paddr_t pa; - int i; - bool rv; KASSERT((umap->flags & UMAP_MAPPING_CACHED) == 0); if (zerolen) { @@ -647,7 +644,10 @@ umap->flags &= ~UMAP_PAGES_LOCKED; mutex_enter(&uobj->vmobjlock); mutex_enter(&uvm_pageqlock); - for (i = 0; i < npages; i++) { + for (u_int i = 0; i < npages; i++) { + paddr_t pa; + bool rv; + rv = pmap_extract(pmap_kernel(), umapva + slot_offset + (i << PAGE_SHIFT), &pa); KASSERT(rv); @@ -707,8 +707,8 @@ ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice, int flags) { - voff_t off; const bool overwrite = (flags & UBC_FAULTBUSY) != 0; + voff_t off; int error; KASSERT(todo <= uio->uio_resid); @@ -745,7 +745,6 @@ return error; } - /* * uvm_vnp_zerorange: set a range of bytes in a file to zero. */
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Thu May 19 03:26:06 UTC 2011 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Add some general description of vnode life-cycle. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.7 src/sys/kern/vfs_vnode.c:1.8 --- src/sys/kern/vfs_vnode.c:1.7 Thu May 19 03:11:55 2011 +++ src/sys/kern/vfs_vnode.c Thu May 19 03:26:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.7 2011/05/19 03:11:55 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.8 2011/05/19 03:26:06 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,31 +67,61 @@ */ /* - * Note on v_usecount and locking: + * The vnode cache subsystem. * - * At nearly all points it is known that v_usecount could be zero, the - * vnode interlock will be held. + * Life-cycle * - * To change v_usecount away from zero, the interlock must be held. To - * change from a non-zero value to zero, again the interlock must be - * held. - * - * There's a flag bit, VC_XLOCK, embedded in v_usecount. - * To raise v_usecount, if the VC_XLOCK bit is set in it, the interlock - * must be held. - * To modify the VC_XLOCK bit, the interlock must be held. - * We always keep the usecount (v_usecount & VC_MASK) non-zero while the - * VC_XLOCK bit is set. - * - * Unless the VC_XLOCK bit is set, changing the usecount from a non-zero - * value to a non-zero value can safely be done using atomic operations, - * without the interlock held. - * Even if the VC_XLOCK bit is set, decreasing the usecount to a non-zero - * value can be done using atomic operations, without the interlock held. + * Normally, there are two points where new vnodes are created: + * VOP_CREATE(9) and VOP_LOOKUP(9). The life-cycle of a vnode + * starts in one of the following ways: + * + * - Allocation, via getnewvnode(9) and/or vnalloc(9). + * - Recycle from a free list, via getnewvnode(9) -> getcleanvnode(9). + * - Reclamation of inactive vnode, via vget(9). + * + * The life-cycle ends when the last reference is dropped, usually + * in VOP_REMOVE(9). In such case, VOP_INACTIVE(9) is called to inform + * the file system that vnode is inactive. Via this call, file system + * indicates whether vnode should be recycled (usually, count of links + * is checked i.e. whether file was removed). + * + * Depending on indication, vnode can be put into a free list (cache), + * or cleaned via vclean(9), which calls VOP_RECLAIM(9) to disassociate + * underlying file system from the vnode, and finally destroyed. + * + * Reference counting + * + * Vnode is considered active, if reference count (vnode_t::v_usecount) + * is non-zero. It is maintained using: vref(9) and vrele(9), as well + * as vput(9), routines. Common points holding references are e.g. + * file openings, current working directory, mount points, etc. + * + * Note on v_usecount and its locking + * + * At nearly all points it is known that v_usecount could be zero, + * the vnode_t::v_interlock will be held. To change v_usecount away + * from zero, the interlock must be held. To change from a non-zero + * value to zero, again the interlock must be held. + * + * There is a flag bit, VC_XLOCK, embedded in v_usecount. To raise + * v_usecount, if the VC_XLOCK bit is set in it, the interlock must + * be held. To modify the VC_XLOCK bit, the interlock must be held. + * We always keep the usecount (v_usecount & VC_MASK) non-zero while + * the VC_XLOCK bit is set. + * + * Unless the VC_XLOCK bit is set, changing the usecount from a non-zero + * value to a non-zero value can safely be done using atomic operations, + * without the interlock held. + * + * Even if the VC_XLOCK bit is set, decreasing the usecount to a non-zero + * value can be done using atomic operations, without the interlock held. + * + * Note: if VI_CLEAN is set, vnode_t::v_interlock will be released while + * mntvnode_lock is still held. */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.7 2011/05/19 03:11:55 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.8 2011/05/19 03:26:06 rmind Exp $"); #include #include
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Thu May 19 03:21:24 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_mem.c tmpfs_vfsops.c Log Message: - tmpfs: do not create dirent/node pools per-mount, there is no need to. - tmpfs_mount: fix a leak of mount structures in error path. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.2 -r1.3 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.47 -r1.48 src/sys/fs/tmpfs/tmpfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs.h diff -u src/sys/fs/tmpfs/tmpfs.h:1.39 src/sys/fs/tmpfs/tmpfs.h:1.40 --- src/sys/fs/tmpfs/tmpfs.h:1.39 Thu Jan 13 13:35:11 2011 +++ src/sys/fs/tmpfs/tmpfs.h Thu May 19 03:21:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.39 2011/01/13 13:35:11 pooka Exp $ */ +/* $NetBSD: tmpfs.h,v 1.40 2011/05/19 03:21:23 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -298,11 +298,6 @@ /* Node list. */ kmutex_t tm_lock; struct tmpfs_node_list tm_nodes; - - char tm_dwchan[32]; - struct pool tm_dirent_pool; - char tm_nwchan[32]; - struct pool tm_node_pool; }; /* - */ Index: src/sys/fs/tmpfs/tmpfs_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.2 src/sys/fs/tmpfs/tmpfs_mem.c:1.3 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.2 Mon Jun 28 19:32:43 2010 +++ src/sys/fs/tmpfs/tmpfs_mem.c Thu May 19 03:21:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.2 2010/06/28 19:32:43 rmind Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.3 2011/05/19 03:21:23 rmind Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.2 2010/06/28 19:32:43 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.3 2011/05/19 03:21:23 rmind Exp $"); #include #include @@ -42,18 +42,13 @@ #include +extern struct pool tmpfs_dirent_pool; +extern struct pool tmpfs_node_pool; + void tmpfs_mntmem_init(struct tmpfs_mount *mp, uint64_t memlimit) { - sprintf(mp->tm_dwchan, "tmpfs_dirent_%p", mp); - pool_init(&mp->tm_dirent_pool, sizeof(struct tmpfs_dirent), 0, 0, 0, - mp->tm_dwchan, &pool_allocator_nointr, IPL_NONE); - - sprintf(mp->tm_nwchan, "tmpfs_node_%p", mp); - pool_init(&mp->tm_node_pool, sizeof(struct tmpfs_node), 0, 0, 0, - mp->tm_dwchan, &pool_allocator_nointr, IPL_NONE); - mutex_init(&mp->tm_acc_lock, MUTEX_DEFAULT, IPL_NONE); mp->tm_mem_limit = memlimit; mp->tm_bytes_used = 0; @@ -65,8 +60,6 @@ KASSERT(mp->tm_bytes_used == 0); mutex_destroy(&mp->tm_acc_lock); - pool_destroy(&mp->tm_dirent_pool); - pool_destroy(&mp->tm_node_pool); } /* @@ -153,7 +146,7 @@ if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_dirent))) { return NULL; } - return pool_get(&mp->tm_dirent_pool, PR_WAITOK); + return pool_get(&tmpfs_dirent_pool, PR_WAITOK); } void @@ -161,7 +154,7 @@ { tmpfs_mem_decr(mp, sizeof(struct tmpfs_dirent)); - pool_put(&mp->tm_dirent_pool, de); + pool_put(&tmpfs_dirent_pool, de); } struct tmpfs_node * @@ -171,7 +164,7 @@ if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_node))) { return NULL; } - return pool_get(&mp->tm_node_pool, PR_WAITOK); + return pool_get(&tmpfs_node_pool, PR_WAITOK); } void @@ -179,7 +172,7 @@ { tmpfs_mem_decr(mp, sizeof(struct tmpfs_node)); - pool_put(&mp->tm_node_pool, tn); + pool_put(&tmpfs_node_pool, tn); } /* Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.47 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.48 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.47 Sat Apr 2 14:24:53 2011 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Thu May 19 03:21:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.47 2011/04/02 14:24:53 hannken Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.48 2011/05/19 03:21:23 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.47 2011/04/02 14:24:53 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.48 2011/05/19 03:21:23 rmind Exp $"); #include #include @@ -60,7 +60,8 @@ MODULE(MODULE_CLASS_VFS, tmpfs, NULL); -/* - */ +struct pool tmpfs_dirent_pool; +struct pool tmpfs_node_pool; static int tmpfs_mount(struct mount *, const char *, void *, size_t *); static int tmpfs_start(struct mount *, int); @@ -76,7 +77,23 @@ static int tmpfs_snapshot(struct mount *, struct vnode *, struct timespec *); -/* - */ +static void +tmpfs_init(void) +{ + + pool_init(&tmpfs_dirent_pool, sizeof(struct tmpfs_dirent), 0, 0, 0, + "tmpfs_dirent", &pool_allocator_nointr, IPL_NONE); + pool_init(&tmpfs_node_pool, sizeof(stru
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Thu May 19 03:13:58 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Add comments, clean up. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.81 src/sys/fs/tmpfs/tmpfs_vnops.c:1.82 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.81 Thu May 19 03:11:58 2011 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Thu May 19 03:13:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.81 2011/05/19 03:11:58 rmind Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.82 2011/05/19 03:13:58 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.81 2011/05/19 03:11:58 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.82 2011/05/19 03:13:58 rmind Exp $"); #include #include @@ -115,7 +115,7 @@ { &tmpfs_vnodeop_p, tmpfs_vnodeop_entries }; /* - * tmpfs_lookup: lookup routine. + * tmpfs_lookup: path name traversal routine. * * Arguments: dvp (directory being searched), vpp (result), * cnp (component name - path). @@ -163,25 +163,30 @@ * directory/name couple is already in the cache. */ error = cache_lookup(dvp, vpp, cnp); - if (error >= 0) + if (error >= 0) { + /* Both cache-hit or an error case. */ goto out; - - /* We cannot be requesting the parent directory of the root node. */ - KASSERT(IMPLIES(dnode->tn_type == VDIR && - dnode->tn_spec.tn_dir.tn_parent == dnode, - !(cnp->cn_flags & ISDOTDOT))); + } if (cnp->cn_flags & ISDOTDOT) { + struct tmpfs_node *pnode; + /* + * Lookup of ".." case. + */ + pnode = dnode->tn_spec.tn_dir.tn_parent; + KASSERT(dnode->tn_type == VDIR && pnode != dnode); VOP_UNLOCK(dvp); /* Allocate a new vnode on the matching entry. */ - error = tmpfs_alloc_vp(dvp->v_mount, - dnode->tn_spec.tn_dir.tn_parent, vpp); + error = tmpfs_alloc_vp(dvp->v_mount, pnode, vpp); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); - goto done; + goto out; } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { + /* + * Lookup of "." case. + */ if ((cnp->cn_flags & ISLASTCN) && (cnp->cn_nameiop == RENAME)) { error = EISDIR; @@ -193,6 +198,9 @@ goto done; } + /* + * Other lookup cases: perform directory scan. + */ de = tmpfs_dir_lookup(dnode, cnp); if (de == NULL || de->td_node == TMPFS_NODE_WHITEOUT) { /* @@ -263,14 +271,12 @@ } done: /* - * Store the result of this lookup in the cache. Avoid this if the - * request was for creation, as it does not improve timings on - * emprical tests. + * Cache the result, unless request was for creation (as it does + * not improve the performance). */ - if ((cnp->cn_flags & MAKEENTRY) && cnp->cn_nameiop != CREATE && - (cnp->cn_flags & ISDOTDOT) == 0) + if ((cnp->cn_flags & MAKEENTRY) != 0 && cnp->cn_nameiop != CREATE) { cache_enter(dvp, *vpp, cnp); - + } out: KASSERT(IFF(error == 0, *vpp != NULL && VOP_ISLOCKED(*vpp))); KASSERT(VOP_ISLOCKED(dvp)); @@ -680,20 +686,20 @@ return 0; } -/* - */ - int tmpfs_remove(void *v) { - struct vnode *dvp = ((struct vop_remove_args *)v)->a_dvp; - struct vnode *vp = ((struct vop_remove_args *)v)->a_vp; - struct componentname *cnp = (((struct vop_remove_args *)v)->a_cnp); - - int error; + struct vop_remove_args /* { + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; + } */ *ap = v; + struct vnode *dvp = ap->a_dvp, *vp = ap->a_vp; + struct componentname *cnp = ap->a_cnp; struct tmpfs_dirent *de; struct tmpfs_mount *tmp; - struct tmpfs_node *dnode; - struct tmpfs_node *node; + struct tmpfs_node *dnode, *node; + int error; KASSERT(VOP_ISLOCKED(dvp)); KASSERT(VOP_ISLOCKED(vp)); @@ -703,12 +709,7 @@ goto out; } - dnode = VP_TO_TMPFS_DIR(dvp); node = VP_TO_TMPFS_NODE(vp); - tmp = VFS_TO_TMPFS(vp->v_mount); - de = tmpfs_dir_lookup(dnode, cnp); - KASSERT(de); - KASSERT(de->td_node == node); /* Files marked as immutable or append-only cannot be deleted. */ if (node->tn_flags & (IMMUTABLE | APPEND)) { @@ -716,17 +717,22 @@ goto out; } - /* Remove the entry from the directory; as it is a file, we do not - * have to change the number of hard links of the directory. */ + /* + * Lookup and remove the entry from the directory. Note that since + * it is a file, we do not need to change the number of hard links. + */ + dnode = VP_TO_TMPFS_DIR(dvp); + de = tmpfs_dir_lookup(dnode, cnp); + KASSERT(de && de->td_node == node); tmpfs_dir_detach(dvp, de); - /* Free the directory entry we just deleted. Note that the node - * referred by it will not be removed until the vnode is real
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Thu May 19 03:11:59 UTC 2011 Modified Files: src/sys/coda: coda_vnops.c src/sys/fs/adosfs: advnops.c src/sys/fs/cd9660: cd9660_node.c src/sys/fs/efs: efs_vnops.c src/sys/fs/filecorefs: filecore_node.c src/sys/fs/hfs: hfs_vnops.c src/sys/fs/msdosfs: msdosfs_denode.c src/sys/fs/nilfs: nilfs_vnops.c src/sys/fs/ntfs: ntfs_vnops.c src/sys/fs/puffs: puffs_vnops.c src/sys/fs/smbfs: smbfs_node.c src/sys/fs/sysvbfs: sysvbfs_vnops.c src/sys/fs/tmpfs: tmpfs_vnops.c src/sys/fs/udf: udf_vnops.c src/sys/kern: vfs_vnode.c src/sys/nfs: nfs_node.c src/sys/ufs/ufs: ufs_inode.c Log Message: Remove cache_purge(9) calls from reclamation routines in the file systems, as vclean(9) performs it for us since Lite2 merge. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/coda/coda_vnops.c cvs rdiff -u -r1.37 -r1.38 src/sys/fs/adosfs/advnops.c cvs rdiff -u -r1.27 -r1.28 src/sys/fs/cd9660/cd9660_node.c cvs rdiff -u -r1.23 -r1.24 src/sys/fs/efs/efs_vnops.c cvs rdiff -u -r1.22 -r1.23 src/sys/fs/filecorefs/filecore_node.c cvs rdiff -u -r1.22 -r1.23 src/sys/fs/hfs/hfs_vnops.c cvs rdiff -u -r1.43 -r1.44 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.10 -r1.11 src/sys/fs/nilfs/nilfs_vnops.c cvs rdiff -u -r1.48 -r1.49 src/sys/fs/ntfs/ntfs_vnops.c cvs rdiff -u -r1.151 -r1.152 src/sys/fs/puffs/puffs_vnops.c cvs rdiff -u -r1.45 -r1.46 src/sys/fs/smbfs/smbfs_node.c cvs rdiff -u -r1.37 -r1.38 src/sys/fs/sysvbfs/sysvbfs_vnops.c cvs rdiff -u -r1.80 -r1.81 src/sys/fs/tmpfs/tmpfs_vnops.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/udf/udf_vnops.c cvs rdiff -u -r1.6 -r1.7 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.114 -r1.115 src/sys/nfs/nfs_node.c cvs rdiff -u -r1.84 -r1.85 src/sys/ufs/ufs/ufs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/coda/coda_vnops.c diff -u src/sys/coda/coda_vnops.c:1.78 src/sys/coda/coda_vnops.c:1.79 --- src/sys/coda/coda_vnops.c:1.78 Tue Nov 30 10:43:01 2010 +++ src/sys/coda/coda_vnops.c Thu May 19 03:11:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: coda_vnops.c,v 1.78 2010/11/30 10:43:01 dholland Exp $ */ +/* $NetBSD: coda_vnops.c,v 1.79 2011/05/19 03:11:55 rmind Exp $ */ /* * @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.78 2010/11/30 10:43:01 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.79 2011/05/19 03:11:55 rmind Exp $"); #include #include @@ -1735,7 +1735,6 @@ } #endif } -cache_purge(vp); coda_free(VTOC(vp)); SET_VTOC(vp) = NULL; return (0); Index: src/sys/fs/adosfs/advnops.c diff -u src/sys/fs/adosfs/advnops.c:1.37 src/sys/fs/adosfs/advnops.c:1.38 --- src/sys/fs/adosfs/advnops.c:1.37 Thu Jun 24 13:03:09 2010 +++ src/sys/fs/adosfs/advnops.c Thu May 19 03:11:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: advnops.c,v 1.37 2010/06/24 13:03:09 hannken Exp $ */ +/* $NetBSD: advnops.c,v 1.38 2011/05/19 03:11:55 rmind Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.37 2010/06/24 13:03:09 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.38 2011/05/19 03:11:55 rmind Exp $"); #include #include @@ -881,7 +881,6 @@ vp = sp->a_vp; ap = VTOA(vp); LIST_REMOVE(ap, link); - cache_purge(vp); if (vp->v_type == VDIR && ap->tab) free(ap->tab, M_ANODE); else if (vp->v_type == VLNK && ap->slinkto) Index: src/sys/fs/cd9660/cd9660_node.c diff -u src/sys/fs/cd9660/cd9660_node.c:1.27 src/sys/fs/cd9660/cd9660_node.c:1.28 --- src/sys/fs/cd9660/cd9660_node.c:1.27 Wed Jul 21 17:52:09 2010 +++ src/sys/fs/cd9660/cd9660_node.c Thu May 19 03:11:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_node.c,v 1.27 2010/07/21 17:52:09 hannken Exp $ */ +/* $NetBSD: cd9660_node.c,v 1.28 2011/05/19 03:11:55 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1994 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.27 2010/07/21 17:52:09 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.28 2011/05/19 03:11:55 rmind Exp $"); #include #include @@ -239,7 +239,6 @@ /* * Purge old data structures associated with the inode. */ - cache_purge(vp); if (ip->i_devvp) { vrele(ip->i_devvp); ip->i_devvp = 0; Index: src/sys/fs/efs/efs_vnops.c diff -u src/sys/fs/efs/efs_vnops.c:1.23 src/sys/fs/efs/efs_vnops.c:1.24 --- src/sys/fs/efs/efs_vnops.c:1.23 Tue Nov 30 10:43:02 2010 +++ src/sys/fs/efs/efs_vnops.c Thu May 19 03:11:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: efs_vnops.c,v 1.23 2010/11/30 10:43:02 dholland Exp $ */ +/* $NetBSD: efs_vnops.c,v 1.24 2011/05/19 03:11:56 rmind Exp $ */ /* * Copyright (c) 2006 Stephen M. Rumble @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.
CVS commit: src
Module Name:src Committed By: rmind Date: Thu May 19 03:07:30 UTC 2011 Modified Files: src/share/man/man9: kthread.9 src/sys/kern: init_main.c kern_kthread.c src/sys/sys: kthread.h lwp.h Log Message: Re-implement kthread_join(9), so that it actually works (hi haad@). To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/share/man/man9/kthread.9 cvs rdiff -u -r1.428 -r1.429 src/sys/kern/init_main.c cvs rdiff -u -r1.32 -r1.33 src/sys/kern/kern_kthread.c cvs rdiff -u -r1.9 -r1.10 src/sys/sys/kthread.h cvs rdiff -u -r1.151 -r1.152 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/kthread.9 diff -u src/share/man/man9/kthread.9:1.24 src/share/man/man9/kthread.9:1.25 --- src/share/man/man9/kthread.9:1.24 Thu Dec 2 12:54:13 2010 +++ src/share/man/man9/kthread.9 Thu May 19 03:07:30 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: kthread.9,v 1.24 2010/12/02 12:54:13 wiz Exp $ +.\" $NetBSD: kthread.9,v 1.25 2011/05/19 03:07:30 rmind Exp $ .\" .\" Copyright (c) 2000, 2007, 2008 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 13, 2010 +.Dd May 19, 2011 .Dt KTHREAD 9 .Os .Sh NAME @@ -89,16 +89,13 @@ .Dv NULL if not required. .It Fa newlp -A pointer to receive the new lwp structure for the kernel thread. -May not be -.Dv NULL -if +A pointer to receive the new LWP structure for the kernel thread. +May be +.Dv NULL , +unless .Dv KTHREAD_JOINABLE is specified in -.Fa flags ; -otherwise may be -.Dv NULL -if not required. +.Fa flags . .It Fa fmt A string containing format information used to display the kernel thread name. @@ -129,7 +126,7 @@ Causes the kthread to be created in the .Dv SCHED_OTHER class (timeshared). -The threads' priority will be dynamically adjusted by the scheduler. +The priority of thread will be dynamically adjusted by the scheduler. Increased activity by the kthread will cause its priority to fall; decreased activity will cause its priority to rise. By default, kthreads are created in the @@ -143,10 +140,11 @@ adjusted by the scheduler. .It Dv KTHREAD_JOINABLE Requests creation of joinable kthread. -When this flag is specified, the +In such case +.Fn kthread_exit +will wait until .Fn kthread_join -function can be called only once for the lwp structure returned in -.Fa newlp . +will be called. .El .It Fn kthread_destroy "l" From another thread executing in the kernel, cause a kthread to exit. @@ -157,9 +155,13 @@ Exit from a kernel thread. Must only be called by a kernel thread. .It Fn kthread_join "l" -Suspend execution of the LWP until the target kthread terminates. +Suspend execution of calling thread until the target kthread terminates. Conceptually the function can be compared to the user space -.Xr pthread_join 3 . +.Xr pthread_join 3 , +however it must be called only once for kernel thread which was created using +.Dv KTHREAD_JOIN +flag and would wait on +.Fa kthread_exit . .El .Sh RETURN VALUES Upon successful completion, Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.428 src/sys/kern/init_main.c:1.429 --- src/sys/kern/init_main.c:1.428 Thu Apr 14 16:20:52 2011 +++ src/sys/kern/init_main.c Thu May 19 03:07:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.428 2011/04/14 16:20:52 yamt Exp $ */ +/* $NetBSD: init_main.c,v 1.429 2011/05/19 03:07:29 rmind Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.428 2011/04/14 16:20:52 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.429 2011/05/19 03:07:29 rmind Exp $"); #include "opt_ddb.h" #include "opt_ipsec.h" @@ -304,6 +304,7 @@ once_init(); mutex_init(&cpu_lock, MUTEX_DEFAULT, IPL_NONE); kernconfig_lock_init(); + kthread_sysinit(); /* Initialize the device switch tables. */ devsw_init(); Index: src/sys/kern/kern_kthread.c diff -u src/sys/kern/kern_kthread.c:1.32 src/sys/kern/kern_kthread.c:1.33 --- src/sys/kern/kern_kthread.c:1.32 Tue Apr 26 17:40:38 2011 +++ src/sys/kern/kern_kthread.c Thu May 19 03:07:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_kthread.c,v 1.32 2011/04/26 17:40:38 ahoka Exp $ */ +/* $NetBSD: kern_kthread.c,v 1.33 2011/05/19 03:07:29 rmind Exp $ */ /*- * Copyright (c) 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. @@ -31,45 +31,45 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.32 2011/04/26 17:40:38 ahoka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.33 2011/05/19 03:07:29 rmind Exp $"); #include #include #include #include -#include +#include #include #include #include - -/* - * note that stdarg.h and the ansi style va_start macro is used for both - * ansi and traditiona
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: rmind Date: Mon May 16 18:08:04 UTC 2011 Modified Files: src/sys/arch/sparc/sparc: machdep.c Log Message: Hack-around sparc/sun4c case, which modifies const maxdmap/maxsmap. >From he@. OK mrg@. To generate a diff of this commit: cvs rdiff -u -r1.308 -r1.309 src/sys/arch/sparc/sparc/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/machdep.c diff -u src/sys/arch/sparc/sparc/machdep.c:1.308 src/sys/arch/sparc/sparc/machdep.c:1.309 --- src/sys/arch/sparc/sparc/machdep.c:1.308 Mon Apr 18 00:26:11 2011 +++ src/sys/arch/sparc/sparc/machdep.c Mon May 16 18:08:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.308 2011/04/18 00:26:11 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.309 2011/05/16 18:08:04 rmind Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.308 2011/04/18 00:26:11 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.309 2011/05/16 18:08:04 rmind Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_sunos.h" @@ -306,10 +306,10 @@ /* Clip max data & stack to avoid running into the MMU hole */ #if MAXDSIZ > 256*1024*1024 - maxdmap = 256*1024*1024; + *(rlim_t*)__UNCONST(&maxdmap) = 256*1024*1024; #endif #if MAXSSIZ > 256*1024*1024 - maxsmap = 256*1024*1024; + *(rlim_t*)__UNCONST(&maxsmap) = 256*1024*1024; #endif }
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat May 14 18:50:08 UTC 2011 Modified Files: src/sys/kern: kern_fork.c Log Message: fork1: fix stop-on-fork case, lend a correct lock to LWP for LSSTOP state. Fixes PR/44935. To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/sys/kern/kern_fork.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_fork.c diff -u src/sys/kern/kern_fork.c:1.183 src/sys/kern/kern_fork.c:1.184 --- src/sys/kern/kern_fork.c:1.183 Sun May 1 01:15:18 2011 +++ src/sys/kern/kern_fork.c Sat May 14 18:50:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.183 2011/05/01 01:15:18 rmind Exp $ */ +/* $NetBSD: kern_fork.c,v 1.184 2011/05/14 18:50:07 rmind Exp $ */ /*- * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.183 2011/05/01 01:15:18 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.184 2011/05/14 18:50:07 rmind Exp $"); #include "opt_ktrace.h" @@ -506,12 +506,14 @@ lwp_lock(l2); KASSERT(p2->p_nrlwps == 1); if (p2->p_sflag & PS_STOPFORK) { + struct schedstate_percpu *spc = &l2->l_cpu->ci_schedstate; p2->p_nrlwps = 0; p2->p_stat = SSTOP; p2->p_waited = 0; p1->p_nstopchild++; l2->l_stat = LSSTOP; - lwp_unlock(l2); + KASSERT(l2->l_wchan == NULL); + lwp_unlock_to(l2, spc->spc_lwplock); } else { p2->p_nrlwps = 1; p2->p_stat = SACTIVE; @@ -519,7 +521,6 @@ sched_enqueue(l2, false); lwp_unlock(l2); } - mutex_exit(p2->p_lock); /*
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sat May 14 17:57:05 UTC 2011 Modified Files: src/sys/kern: kern_resource.c src/sys/sys: resource.h resourcevar.h Log Message: - Sprinkle __read_mostly, consitify maxdmap and maxsmap. - Prevent sys/resourcevar.h from inclusion in userland. - sys_{set,get}priority: use id_t for 'who', not int. - Make donice() routine static. - Remove trailing spaces, KNF. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/kern/kern_resource.c cvs rdiff -u -r1.31 -r1.32 src/sys/sys/resource.h cvs rdiff -u -r1.51 -r1.52 src/sys/sys/resourcevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.163 src/sys/kern/kern_resource.c:1.164 --- src/sys/kern/kern_resource.c:1.163 Sat May 14 17:12:28 2011 +++ src/sys/kern/kern_resource.c Sat May 14 17:57:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.163 2011/05/14 17:12:28 rmind Exp $ */ +/* $NetBSD: kern_resource.c,v 1.164 2011/05/14 17:57:05 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.163 2011/05/14 17:12:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.164 2011/05/14 17:57:05 rmind Exp $"); #include #include @@ -62,15 +62,17 @@ * Maximum process data and stack limits. * They are variables so they are patchable. */ -rlim_t maxdmap = MAXDSIZ; -rlim_t maxsmap = MAXSSIZ; +const rlim_t maxdmap = MAXDSIZ; +const rlim_t maxsmap = MAXSSIZ; -static pool_cache_t plimit_cache; -static pool_cache_t pstats_cache; +static pool_cache_t plimit_cache __read_mostly; +static pool_cache_t pstats_cache __read_mostly; static kauth_listener_t resource_listener; +static struct sysctllog *proc_sysctllog; -static void sysctl_proc_setup(void); +static int donice(struct lwp *, struct proc *, int); +static void sysctl_proc_setup(void); static int resource_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie, @@ -85,12 +87,12 @@ switch (action) { case KAUTH_PROCESS_NICE: if (kauth_cred_geteuid(cred) != kauth_cred_geteuid(p->p_cred) && -kauth_cred_getuid(cred) != kauth_cred_geteuid(p->p_cred)) { -break; -} + kauth_cred_getuid(cred) != kauth_cred_geteuid(p->p_cred)) { + break; + } -if ((u_long)arg1 >= p->p_nice) -result = KAUTH_RESULT_ALLOW; + if ((u_long)arg1 >= p->p_nice) + result = KAUTH_RESULT_ALLOW; break; @@ -163,8 +165,8 @@ syscallarg(id_t) who; } */ struct proc *curp = l->l_proc, *p; + id_t who = SCARG(uap, who); int low = NZERO + PRIO_MAX + 1; - int who = SCARG(uap, who); mutex_enter(proc_lock); switch (SCARG(uap, which)) { @@ -202,17 +204,17 @@ default: mutex_exit(proc_lock); - return (EINVAL); + return EINVAL; } mutex_exit(proc_lock); - if (low == NZERO + PRIO_MAX + 1) - return (ESRCH); + if (low == NZERO + PRIO_MAX + 1) { + return ESRCH; + } *retval = low - NZERO; - return (0); + return 0; } -/* ARGSUSED */ int sys_setpriority(struct lwp *l, const struct sys_setpriority_args *uap, register_t *retval) @@ -223,8 +225,8 @@ syscallarg(int) prio; } */ struct proc *curp = l->l_proc, *p; + id_t who = SCARG(uap, who); int found = 0, error = 0; - int who = SCARG(uap, who); mutex_enter(proc_lock); switch (SCARG(uap, which)) { @@ -277,9 +279,8 @@ return EINVAL; } mutex_exit(proc_lock); - if (found == 0) - return ESRCH; - return error; + + return (found == 0) ? ESRCH : error; } /* @@ -287,7 +288,7 @@ * * Call with the target process' credentials locked. */ -int +static int donice(struct lwp *l, struct proc *chgp, int n) { kauth_cred_t cred = l->l_cred; @@ -297,21 +298,25 @@ if (kauth_cred_geteuid(cred) && kauth_cred_getuid(cred) && kauth_cred_geteuid(cred) != kauth_cred_geteuid(chgp->p_cred) && kauth_cred_getuid(cred) != kauth_cred_geteuid(chgp->p_cred)) - return (EPERM); + return EPERM; - if (n > PRIO_MAX) + if (n > PRIO_MAX) { n = PRIO_MAX; - if (n < PRIO_MIN) + } + if (n < PRIO_MIN) { n = PRIO_MIN; + } n += NZERO; + if (kauth_authorize_process(cred, KAUTH_PROCESS_NICE, chgp, - KAUTH_ARG(n), NULL, NULL)) - return (EACCES); + KAUTH_ARG(n), NULL, NULL)) { + return EACCES; + } + sched_nice(chgp, n); - return (0); + return 0; } -/* ARGSUSED */ int sys_setrlimit(struct lwp *l, const struct sys_setrlimit_args *uap, register_t *retval) @@ -320,14 +325,14 @@ syscallarg(int) which; syscallarg(const struct rlimit *) rlp; } */ - int which = SCARG(uap, which); + int error, which = SCARG(uap, which); struct rlimit alim; - int error; error = copyin(SCARG(uap, rlp), &alim, sizeof(struct rlimit)); - if (error) - return (error); - return (doset
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat May 14 17:12:28 UTC 2011 Modified Files: src/sys/kern: kern_resource.c Log Message: Improve/fix comments, give more meaningful names for variables. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/kern/kern_resource.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.162 src/sys/kern/kern_resource.c:1.163 --- src/sys/kern/kern_resource.c:1.162 Sun May 1 02:46:19 2011 +++ src/sys/kern/kern_resource.c Sat May 14 17:12:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.162 2011/05/01 02:46:19 christos Exp $ */ +/* $NetBSD: kern_resource.c,v 1.163 2011/05/14 17:12:28 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,14 +37,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.162 2011/05/01 02:46:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.163 2011/05/14 17:12:28 rmind Exp $"); #include #include #include #include #include -#include #include #include #include @@ -763,10 +762,6 @@ } /* - * sysctl interface in five parts - */ - -/* * sysctl_proc_findproc: a routine for sysctl proc subtree helpers that * need to pick a valid process by PID. * @@ -855,7 +850,7 @@ node.sysctl_data = cnbuf; error = sysctl_lookup(SYSCTLFN_CALL(&node)); - /* Return if error, or if we are only retrieving the core name. */ + /* Return if error, or if caller is only getting the core name. */ if (error || newp == NULL) { goto done; } @@ -886,129 +881,137 @@ } /* - * sysctl helper routine for checking/setting a process's stop flags, - * one for fork and one for exec. + * sysctl_proc_stop: helper routine for checking/setting the stop flags. */ static int sysctl_proc_stop(SYSCTLFN_ARGS) { - struct proc *ptmp; - int i, f, error = 0; + struct proc *p; + int isset, flag, error = 0; struct sysctlnode node; if (namelen != 0) - return (EINVAL); + return EINVAL; /* Find the process. Hold a reference (p_reflock), if found. */ - error = sysctl_proc_findproc(l, (pid_t)name[-2], &ptmp); + error = sysctl_proc_findproc(l, (pid_t)name[-2], &p); if (error) return error; /* XXX-elad */ - error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, ptmp, + error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, p, KAUTH_ARG(KAUTH_REQ_PROCESS_CANSEE_ENTRY), NULL, NULL); - if (error) + if (error) { goto out; + } + /* Determine the flag. */ switch (rnode->sysctl_num) { case PROC_PID_STOPFORK: - f = PS_STOPFORK; + flag = PS_STOPFORK; break; case PROC_PID_STOPEXEC: - f = PS_STOPEXEC; + flag = PS_STOPEXEC; break; case PROC_PID_STOPEXIT: - f = PS_STOPEXIT; + flag = PS_STOPEXIT; break; default: error = EINVAL; goto out; } - - i = (ptmp->p_flag & f) ? 1 : 0; + isset = (p->p_flag & flag) ? 1 : 0; node = *rnode; - node.sysctl_data = &i; + node.sysctl_data = &isset; error = sysctl_lookup(SYSCTLFN_CALL(&node)); - if (error || newp == NULL) + + /* Return if error, or if callers is only getting the flag. */ + if (error || newp == NULL) { goto out; + } - mutex_enter(ptmp->p_lock); + /* Check if caller can set the flags. */ error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_STOPFLAG, - ptmp, KAUTH_ARG(f), NULL, NULL); - if (!error) { - if (i) { - ptmp->p_sflag |= f; - } else { - ptmp->p_sflag &= ~f; - } + p, KAUTH_ARG(flag), NULL, NULL); + if (error) { + goto out; + } + mutex_enter(p->p_lock); + if (isset) { + p->p_sflag |= flag; + } else { + p->p_sflag &= ~flag; } - mutex_exit(ptmp->p_lock); + mutex_exit(p->p_lock); out: - rw_exit(&ptmp->p_reflock); + rw_exit(&p->p_reflock); return error; } /* - * sysctl helper routine for a process's rlimits as exposed by sysctl. + * sysctl_proc_plimit: helper routine to get/set rlimits of a process. */ static int sysctl_proc_plimit(SYSCTLFN_ARGS) { - struct proc *ptmp; + struct proc *p; u_int limitno; int which, error = 0; struct rlimit alim; struct sysctlnode node; if (namelen != 0) - return (EINVAL); + return EINVAL; which = name[-1]; if (which != PROC_PID_LIMIT_TYPE_SOFT && which != PROC_PID_LIMIT_TYPE_HARD) - return (EINVAL); + return EINVAL; limitno = name[-2] - 1; if (limitno >= RLIM_NLIMITS) - return (EINVAL); + return EINVAL; if (name[-3] != PROC_PID_LIMIT) - return (EINVAL); + return EINVAL; /* Find the process. Hold a reference (p_reflock), if found. */ - error = sysctl_proc_findproc(l, (pid_t)name[-4], &ptmp); + error = sysctl_proc_findproc(l, (pid_t)name[-4], &p); if (error) return error; /* XXX-elad */ - error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, ptmp, + error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, p, KAUTH_ARG(KAUTH_REQ_PRO
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sat May 14 12:44:16 UTC 2011 Modified Files: src/sys/compat/ndis: kern_ndis.c nbcompat.c nbcompat.h ndis_var.h subr_ndis.c subr_ntoskrnl.c src/sys/dev/if_ndis: if_ndis.c if_ndisvar.h Log Message: Replace simple_lock(9) with mutex(9), clean up. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/compat/ndis/kern_ndis.c cvs rdiff -u -r1.10 -r1.11 src/sys/compat/ndis/nbcompat.c cvs rdiff -u -r1.14 -r1.15 src/sys/compat/ndis/nbcompat.h cvs rdiff -u -r1.5 -r1.6 src/sys/compat/ndis/ndis_var.h cvs rdiff -u -r1.23 -r1.24 src/sys/compat/ndis/subr_ndis.c cvs rdiff -u -r1.18 -r1.19 src/sys/compat/ndis/subr_ntoskrnl.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/if_ndis/if_ndis.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/if_ndis/if_ndisvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ndis/kern_ndis.c diff -u src/sys/compat/ndis/kern_ndis.c:1.21 src/sys/compat/ndis/kern_ndis.c:1.22 --- src/sys/compat/ndis/kern_ndis.c:1.21 Mon May 11 21:31:29 2009 +++ src/sys/compat/ndis/kern_ndis.c Sat May 14 12:44:16 2011 @@ -1,3 +1,5 @@ +/* $NetBSD: kern_ndis.c,v 1.22 2011/05/14 12:44:16 rmind Exp $ */ + /*- * Copyright (c) 2003 * Bill Paul . All rights reserved. @@ -35,7 +37,7 @@ __FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.60.2.5 2005/04/01 17:14:20 wpaul Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: kern_ndis.c,v 1.21 2009/05/11 21:31:29 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ndis.c,v 1.22 2011/05/14 12:44:16 rmind Exp $"); #endif #include @@ -50,9 +52,7 @@ #include #include #include -#ifdef __FreeBSD__ #include -#endif #include #include @@ -134,9 +134,6 @@ struct proc *np_p; int np_state; uint8_t np_stack[PAGE_SIZE*NDIS_KSTACK_PAGES]; -#ifdef __NetBSD__ - int np_needs_wakeup; -#endif }; static void ndis_return(void *); @@ -152,9 +149,7 @@ #ifdef __FreeBSD__ static struct mtx ndis_thr_mtx; #else /* __NetBSD__ */ -static struct simplelock ndis_thr_mtx; -#define THR_LOCK() do {old_ipl = splnet(); simple_lock(&ndis_thr_mtx);} while(0) -#define THR_UNLOCK() do {simple_unlock(&ndis_thr_mtx); splx(old_ipl);} while(0) +static kmutex_t ndis_thr_mtx; #endif static struct mtx ndis_req_mtx; @@ -338,44 +333,18 @@ { struct ndis_req *r = NULL, *die = NULL; struct ndisproc *p; -#ifdef __NetBSD__ - int old_ipl; -#endif p = arg; - while (1) { + for (;;) { + mtx_lock_spin(&ndis_thr_mtx); + ndis_thsuspend(p->np_p, &ndis_thr_mtx, 0); - /* Protect against interrupts between checking if the queue is empty, and going to sleep - * to avoid a wakeup before sleep. - */ - old_ipl = splnet(); - /* Sleep, but preserve our original priority. */ - if(STAILQ_EMPTY(p->np_q)) { - /* TODO: If we get an interrupt between checking if the queue is empty, - * TODO: and sleeping, then in the interrupt, an item could be placed - * TODO: on the queue, and we could be woken up before we sleep. - * - */ - ndis_thsuspend(p->np_p, NULL, 0); - } - splx(old_ipl); - -#ifdef __NetBSD__ - p->np_needs_wakeup = FALSE; -#endif - /* Look for any jobs on the work queue. */ -#ifdef __FreeBSD__ - mtx_lock_spin(&ndis_thr_mtx); -#else /* __NetBSD__ */ - THR_LOCK(); -#endif - p->np_state = NDIS_PSTATE_RUNNING; - while(!STAILQ_EMPTY(p->np_q)/*STAILQ_FIRST(p->np_q) != NULL*/) { + while (!STAILQ_EMPTY(p->np_q)) { r = STAILQ_FIRST(p->np_q); - STAILQ_REMOVE_HEAD(p->np_q, link); + STAILQ_REMOVE_HEAD(p->np_q, link); /* for debugging */ @@ -388,11 +357,8 @@ _ndis_swi_req = r; r->area = 2; } -#ifdef __FreeBSD__ mtx_unlock_spin(&ndis_thr_mtx); -#else /* __NetBSD__ */ - THR_UNLOCK(); -#endif + /* Just for debugging */ if(p == &ndis_tproc) { @@ -412,11 +378,7 @@ calling_in_swi = FALSE; } -#ifdef __FreeBSD__ mtx_lock_spin(&ndis_thr_mtx); -#else /* __NetBSD__ */ - THR_LOCK(); -#endif /* Zeroing out the ndis_req is just for debugging */ //memset(r, 0, sizeof(struct ndis_req)); @@ -428,11 +390,7 @@ } p->np_state = NDIS_PSTATE_SLEEPING; -#ifdef __FreeBSD__ mtx_unlock_spin(&ndis_thr_mtx); -#else /* __NetBSD__ */ - THR_UNLOCK(); -#endif /* Bail if we were told to shut down. */ @@ -441,18 +399,9 @@ } wakeup(die); -#ifdef __FreeBSD__ -#if __FreeBSD_version < 502113 - mtx_lock(&Giant); -#endif -#endif - if(p == &ndis_tproc) { - printf("taskqueue thread exiting!\n"); - } else if(p == &ndis_iproc) { - printf("swi thread exiting!\n"); - } + kthread_exit(0); - return; /* notreached */ + /* NOTREACHED */ } /*static*/ int @@ -466,9 +415,8 @@ #ifdef __FreeBSD__ mtx_init(&ndis_thr_mtx, "NDIS thread lock", NULL, MTX_SPIN); #else /* __NetBSD__ */ - simple_lock_init(&ndis_thr_mtx); - //lockinit(&ndis_thr_mtx, PWAIT, "NDIS thread lock", 0
CVS commit: src/sys/dev/ic
Module Name:src Committed By: rmind Date: Sat May 14 02:58:27 UTC 2011 Modified Files: src/sys/dev/ic: lcdkp_subr.c lcdkp_subr.h Log Message: Convert to mutex(9). Replace ltsleep with mtsleep. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/lcdkp_subr.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/lcdkp_subr.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/lcdkp_subr.c diff -u src/sys/dev/ic/lcdkp_subr.c:1.6 src/sys/dev/ic/lcdkp_subr.c:1.7 --- src/sys/dev/ic/lcdkp_subr.c:1.6 Sat Mar 14 15:36:17 2009 +++ src/sys/dev/ic/lcdkp_subr.c Sat May 14 02:58:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lcdkp_subr.c,v 1.6 2009/03/14 15:36:17 dsl Exp $ */ +/* $NetBSD: lcdkp_subr.c,v 1.7 2011/05/14 02:58:27 rmind Exp $ */ /* * Copyright (c) 2002 Dennis I. Chernoivanov @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lcdkp_subr.c,v 1.6 2009/03/14 15:36:17 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lcdkp_subr.c,v 1.7 2011/05/14 02:58:27 rmind Exp $"); #include #include @@ -58,8 +58,9 @@ void lcdkp_attach_subr(struct lcdkp_chip *sc) { + sc->sc_flags = 0x0; - lcdkp_lock_init(sc); + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); } /* @@ -73,7 +74,7 @@ if ((sc->sc_knum == 0) || (sc->sc_kpad == NULL)) return 0; - lcdkp_lock(sc); + mutex_enter(&sc->sc_lock); if (!(sc->sc_flags & LCDKP_HAS_BUF)) { u_int8_t b; if (lcdkp_scan(sc, &b) != 0) { @@ -82,7 +83,7 @@ } } ret = (sc->sc_flags & LCDKP_HAS_BUF); - lcdkp_unlock(sc); + mutex_exit(&sc->sc_lock); return ret; } @@ -98,12 +99,12 @@ if ((sc->sc_knum == 0) || (sc->sc_kpad == NULL)) return EIO; - lcdkp_lock(sc); + mutex_enter(&sc->sc_lock); if ( (error = lcdkp_poll(sc)) == 0) { *result = sc->sc_buf; sc->sc_flags &= ~LCDKP_HAS_BUF; } - lcdkp_unlock(sc); + mutex_exit(&sc->sc_lock); return 0; } @@ -133,19 +134,24 @@ static int lcdkp_poll(struct lcdkp_chip *sc) { - if (!(sc->sc_flags & LCDKP_HAS_BUF)) { - u_int8_t b; - while(lcdkp_scan(sc, &b) == 0) { - int err = ltsleep((void*)sc, PRIBIO | PCATCH, "kppoll", - HD_POLL_RATE, lcdkp_lockaddr(sc)); - if (err != EWOULDBLOCK) { -if (lcdkp_scan(sc, &b) != 0) - break; -return EINTR; - } + int error; + uint8_t b; + + KASSERT(mutex_owned(&sc->sc_lock)); + + if (sc->sc_flags & LCDKP_HAS_BUF) { + return 0; + } + while (lcdkp_scan(sc, &b) == 0) { + error = mtsleep((void*)sc, PRIBIO | PCATCH, "kppoll", + HD_POLL_RATE, &sc->sc_lock); + if (error != EWOULDBLOCK) { + if (lcdkp_scan(sc, &b) != 0) +break; + return EINTR; } - sc->sc_buf = b; - sc->sc_flags |= LCDKP_HAS_BUF; } + sc->sc_buf = b; + sc->sc_flags |= LCDKP_HAS_BUF; return 0; } Index: src/sys/dev/ic/lcdkp_subr.h diff -u src/sys/dev/ic/lcdkp_subr.h:1.2 src/sys/dev/ic/lcdkp_subr.h:1.3 --- src/sys/dev/ic/lcdkp_subr.h:1.2 Mon Jun 23 11:01:58 2003 +++ src/sys/dev/ic/lcdkp_subr.h Sat May 14 02:58:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lcdkp_subr.h,v 1.2 2003/06/23 11:01:58 martin Exp $ */ +/* $NetBSD: lcdkp_subr.h,v 1.3 2011/05/14 02:58:27 rmind Exp $ */ /* * Copyright (c) 2002 Dennis I. Chernoivanov @@ -31,8 +31,6 @@ #define _DEV_IC_LCDKP_SUBR_H_ #ifdef _KERNEL -#include "opt_multiprocessor.h" -#include /* Key code translation */ struct lcdkp_xlate { @@ -54,26 +52,12 @@ u_int8_t (* sc_rread)(bus_space_tag_t, bus_space_handle_t); -#if defined(MULTIPROCESSOR) - struct simplelock sc_lock; -#endif + kmutex_t sc_lock; }; #define lcdkp_dr_read(sc) \ (sc)->sc_rread((sc)->sc_iot, (sc)->sc_ioh); -#if defined(MULTIPROCESSOR) -#define lcdkp_lock(sc) simple_lock(&(sc)->sc_lock) -#define lcdkp_unlock(sc) simple_unlock(&(sc)->sc_lock) -#define lcdkp_lockaddr(sc) (&(sc)->sc_lock) -#define lcdkp_lock_init(sc) simple_lock_init(&(sc)->sc_lock) -#else -#define lcdkp_lock(sc) ((void)0) -#define lcdkp_unlock(sc) ((void)0) -#define lcdkp_lockaddr(sc) (NULL) -#define lcdkp_lock_init(sc) ((void)0) -#endif - void lcdkp_attach_subr(struct lcdkp_chip *); int lcdkp_scankey(struct lcdkp_chip *); int lcdkp_readkey(struct lcdkp_chip *, u_int8_t *);
CVS commit: src/sys/arch/landisk/dev
Module Name:src Committed By: rmind Date: Sat May 14 02:27:35 UTC 2011 Modified Files: src/sys/arch/landisk/dev: button.c Log Message: Convert to mutex(9)/condvar(9). Use RUN_ONCE(9) to avoid racy init. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/landisk/dev/button.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/landisk/dev/button.c diff -u src/sys/arch/landisk/dev/button.c:1.5 src/sys/arch/landisk/dev/button.c:1.6 --- src/sys/arch/landisk/dev/button.c:1.5 Sat Mar 1 14:16:49 2008 +++ src/sys/arch/landisk/dev/button.c Sat May 14 02:27:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: button.c,v 1.5 2008/03/01 14:16:49 rmind Exp $ */ +/* $NetBSD: button.c,v 1.6 2011/05/14 02:27:35 rmind Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -36,20 +36,18 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.5 2008/03/01 14:16:49 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.6 2011/05/14 02:27:35 rmind Exp $"); #include #include #include -#include -#include #include -#include -#include +#include #include #include #include #include +#include #include #include #include @@ -61,17 +59,17 @@ /* * event handler */ -static LIST_HEAD(, btn_event) btn_event_list = -LIST_HEAD_INITIALIZER(btn_event_list); -static struct simplelock btn_event_list_slock = -SIMPLELOCK_INITIALIZER; +static ONCE_DECL(btn_once); +static LIST_HEAD(, btn_event) btn_event_list; +static kmutex_t btn_event_list_lock; static struct lwp *btn_daemon; #define BTN_MAX_EVENTS 32 -static struct simplelock btn_event_queue_slock = -SIMPLELOCK_INITIALIZER; +static kmutex_t btn_event_queue_lock; +static kcondvar_t btn_event_queue_cv; + static button_event_t btn_event_queue[BTN_MAX_EVENTS]; static int btn_event_queue_head; static int btn_event_queue_tail; @@ -98,6 +96,19 @@ }; static int +btn_init(void) +{ + + LIST_INIT(&btn_event_list); + mutex_init(&btn_event_list_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&btn_event_queue_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(&btn_event_queue_cv, "btncv"); + selinit(&btn_event_queue_selinfo); + + return 0; +} + +static int btn_queue_event(button_event_t *bev) { @@ -138,19 +149,18 @@ int btnopen(dev_t dev, int flag, int mode, struct lwp *l) { - static bool btn_event_queue_selinfo_init; /* XXX */ int error; - if (!btn_event_queue_selinfo_init) { - selinit(&btn_event_queue_selinfo); - btn_event_queue_selinfo_init = true; + error = RUN_ONCE(&btn_once, btn_init); + if (error) { + return error; } if (minor(dev) != 0) { return (ENODEV); } - simple_lock(&btn_event_queue_slock); + mutex_enter(&btn_event_queue_lock); if (btn_daemon != NULL) { error = EBUSY; } else { @@ -158,7 +168,7 @@ btn_daemon = l; btn_event_queue_flush(); } - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); return (error); } @@ -172,11 +182,11 @@ return (ENODEV); } - simple_lock(&btn_event_queue_slock); + mutex_enter(&btn_event_queue_lock); count = btn_event_queue_count; btn_daemon = NULL; btn_event_queue_flush(); - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); if (count) { printf("WARNING: %d events lost by exiting daemon\n", count); @@ -224,23 +234,22 @@ return (EINVAL); } - simple_lock(&btn_event_queue_slock); + mutex_enter(&btn_event_queue_lock); for (;;) { if (btn_get_event(&bev)) { - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); return (uiomove(&bev, BUTTON_EVENT_MSG_SIZE, uio)); } if (flags & IO_NDELAY) { - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); return (EWOULDBLOCK); } btn_event_queue_flags |= BEVQ_F_WAITING; - error = ltsleep(&btn_event_queue_count, - (PRIBIO|PCATCH), "btnread", 0, &btn_event_queue_slock); + error = cv_wait_sig(&btn_event_queue_cv, &btn_event_queue_lock); if (error) { - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); return (error); } } @@ -261,13 +270,13 @@ if ((events & (POLLIN | POLLRDNORM)) == 0) return (revents); - simple_lock(&btn_event_queue_slock); + mutex_enter(&btn_event_queue_lock); if (btn_event_queue_count) { revents |= events & (POLLIN | POLLRDNORM); } else { selrecord(l, &btn_event_queue_selinfo); } - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); return (revents); } @@ -276,19 +285,19 @@ filt_btn_rdetach(struct knote *kn) { - simple_lock(&btn_event_queue_slock); + mutex_enter(&btn_event_queue_lock); SLIST_REMOVE(&btn_event_queue_selinfo.sel_klist, kn, knote, kn_selnext); - simple_unlock(&btn_event_queue_slock); + mutex_exit(&btn_event_queue_lock); } static int filt_btn_read(struct knote *kn, long hint) { - simple_lock(&btn_event
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Fri May 13 22:35:51 UTC 2011 Modified Files: src/sys/arch/evbarm/mpcsa: mpcsa_usart.c src/sys/arch/mac68k/nubus: cpi_nubus.c src/sys/dev/ppbus: ppbus_base.c Log Message: Replace some ltsleep() uses with kpause() and tsleep(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/mpcsa/mpcsa_usart.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mac68k/nubus/cpi_nubus.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ppbus/ppbus_base.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/mpcsa/mpcsa_usart.c diff -u src/sys/arch/evbarm/mpcsa/mpcsa_usart.c:1.2 src/sys/arch/evbarm/mpcsa/mpcsa_usart.c:1.3 --- src/sys/arch/evbarm/mpcsa/mpcsa_usart.c:1.2 Thu Jul 3 01:15:39 2008 +++ src/sys/arch/evbarm/mpcsa/mpcsa_usart.c Fri May 13 22:35:50 2011 @@ -1,5 +1,5 @@ -/* $Id: mpcsa_usart.c,v 1.2 2008/07/03 01:15:39 matt Exp $ */ -/* $NetBSD: mpcsa_usart.c,v 1.2 2008/07/03 01:15:39 matt Exp $ */ +/* $Id: mpcsa_usart.c,v 1.3 2011/05/13 22:35:50 rmind Exp $ */ +/* $NetBSD: mpcsa_usart.c,v 1.3 2011/05/13 22:35:50 rmind Exp $ */ /* * Copyright (c) 2007 Embedtronics Oy. All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mpcsa_usart.c,v 1.2 2008/07/03 01:15:39 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpcsa_usart.c,v 1.3 2011/05/13 22:35:50 rmind Exp $"); #include #include @@ -221,9 +221,9 @@ case PID_US3: /* turn gsm on */ at91pio_clear(sc->sc_pioa, PA_GSMOFF); - ltsleep(sc, 0, "gsmond", 4 * hz, NULL); + kpause("gsmond", false, 4 * hz, NULL); at91pio_set(sc->sc_pioa, PA_GSMON); - ltsleep(sc, 0, "gsmon", 2 * hz, NULL); + kpause("gsmon", false, 2 * hz, NULL); at91pio_clear(sc->sc_pioa, PA_GSMON); /* then attach pins to devices etc */ at91pio_per(sc->sc_pioa, PA_TXD4, 1); @@ -253,14 +253,14 @@ at91pio_intr_disestablish(sc->sc_piob, PB_CTS4, sc->sc_cts_ih); at91pio_clear(sc->sc_pioa, PA_GSMON); - ltsleep(sc, 0, "gsmoffd", (hz * 350 + 999) / 1000, NULL); + kpause("gsmoffd", false, (hz * 350 + 999) / 1000, NULL); at91pio_per(sc->sc_pioa, PA_TXD4, -1); at91pio_in(sc->sc_piob, PB_RTS4); at91pio_in(sc->sc_piod, PD_DTR4); at91pio_set(sc->sc_pioa, PA_GSMOFF); - ltsleep(sc, 0, "gsmoff", hz * 4, NULL); + kpause("gsmoff", false, hz * 4, NULL); at91pio_clear(sc->sc_pioa, PA_GSMOFF); break; Index: src/sys/arch/mac68k/nubus/cpi_nubus.c diff -u src/sys/arch/mac68k/nubus/cpi_nubus.c:1.4 src/sys/arch/mac68k/nubus/cpi_nubus.c:1.5 --- src/sys/arch/mac68k/nubus/cpi_nubus.c:1.4 Wed Sep 10 19:20:06 2008 +++ src/sys/arch/mac68k/nubus/cpi_nubus.c Fri May 13 22:35:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpi_nubus.c,v 1.4 2008/09/10 19:20:06 christos Exp $ */ +/* $NetBSD: cpi_nubus.c,v 1.5 2011/05/13 22:35:50 rmind Exp $ */ /*- * Copyright (c) 2008 Hauke Fath @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpi_nubus.c,v 1.4 2008/09/10 19:20:06 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpi_nubus.c,v 1.5 2011/05/13 22:35:50 rmind Exp $"); #include #include @@ -386,7 +386,7 @@ return EBUSY; } /* sleep for a second, unless we get a signal */ - err = ltsleep(sc, PZERO | PCATCH, "cpi_open", hz, NULL); + err = tsleep(sc, PZERO | PCATCH, "cpi_open", hz); if (err != EWOULDBLOCK) { sc->sc_lpstate = LP_INITIAL; return err; @@ -530,8 +530,8 @@ splx(s); } /* XXX Sure we want to wait forever for the printer? */ - err = ltsleep((void *)sc, PZERO | PCATCH, - "cpi_flush", (60 * hz), NULL); + err = tsleep((void *)sc, PZERO | PCATCH, + "cpi_flush", (60 * hz)); } return err; } Index: src/sys/dev/ppbus/ppbus_base.c diff -u src/sys/dev/ppbus/ppbus_base.c:1.17 src/sys/dev/ppbus/ppbus_base.c:1.18 --- src/sys/dev/ppbus/ppbus_base.c:1.17 Tue Apr 15 15:02:29 2008 +++ src/sys/dev/ppbus/ppbus_base.c Fri May 13 22:35:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ppbus_base.c,v 1.17 2008/04/15 15:02:29 cegger Exp $ */ +/* $NetBSD: ppbus_base.c,v 1.18 2011/05/13 22:35:51 rmind Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ppbus_base.c,v 1.17 2008/04/15 15:02:29 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ppbus_base.c,v 1.18 2011/05/13 22:35:51 rmind Exp $"); #include "opt_ppbus_1284.h" #include "opt_ppbus.h" @@ -143,15 +143,15 @@ switch (how) { case PPBUS_NOINTR: /* wait 10 ms */ - tsleep((void *)dev, PPBUSPRI, "ppbuspoll", hz/100); + kpause("ppbuspoll", false, hz / 100, NULL); break; case PPBUS_INTR: default: /* wait 10 ms */ - if (((error = tsleep((void *)dev, PPBUSPRI | PCATCH, - "ppbuspoll", hz/100)) != EWOULDBLOCK) != 0) { -return (error); + error = kpause("ppbuspoll", true, hz / 100, NULL); + if (error != EWOULDBLOCK) { +return error; } break; } @@ -362,19
CVS commit: src/sys/dev/filemon
Module Name:src Committed By: rmind Date: Fri May 13 22:31:08 UTC 2011 Modified Files: src/sys/dev/filemon: filemon.c Log Message: filemon_open: remove unnecessary check (which has a leak in error path). To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/filemon/filemon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/filemon/filemon.c diff -u src/sys/dev/filemon/filemon.c:1.1 src/sys/dev/filemon/filemon.c:1.2 --- src/sys/dev/filemon/filemon.c:1.1 Thu Sep 9 00:10:16 2010 +++ src/sys/dev/filemon/filemon.c Fri May 13 22:31:08 2011 @@ -24,7 +24,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.1 2010/09/09 00:10:16 sjg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.2 2011/05/13 22:31:08 rmind Exp $"); #include #include @@ -195,20 +195,16 @@ return error; filemon = kmem_alloc(sizeof(struct filemon), KM_SLEEP); - if (!filemon) - return ENOMEM; - rw_init(&filemon->fm_mtx); filemon->fm_fd = -1; filemon->fm_fp = NULL; filemon->fm_pid = curproc->p_pid; rw_enter(&filemon_mtx, RW_WRITER); - n_open++; - TAILQ_INSERT_TAIL(&filemons_inuse, filemon, fm_link); - + n_open++; rw_exit(&filemon_mtx); + return fd_clone(fp, fd, oflags, &filemon_fileops, filemon); }
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Fri May 13 22:28:40 UTC 2011 Modified Files: src/sys/arch/arm/xscale: ixp425_npe.c src/sys/dev/ppbus: ppbus_conf.c Log Message: Eliminate few references to ltsleep. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/xscale/ixp425_npe.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ppbus/ppbus_conf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/xscale/ixp425_npe.c diff -u src/sys/arch/arm/xscale/ixp425_npe.c:1.6 src/sys/arch/arm/xscale/ixp425_npe.c:1.7 --- src/sys/arch/arm/xscale/ixp425_npe.c:1.6 Mon Oct 26 19:16:55 2009 +++ src/sys/arch/arm/xscale/ixp425_npe.c Fri May 13 22:28:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ixp425_npe.c,v 1.6 2009/10/26 19:16:55 cegger Exp $ */ +/* $NetBSD: ixp425_npe.c,v 1.7 2011/05/13 22:28:40 rmind Exp $ */ /*- * Copyright (c) 2006 Sam Leffler, Errno Consulting @@ -62,7 +62,7 @@ #if 0 __FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/ixp425_npe.c,v 1.1 2006/11/19 23:55:23 sam Exp $"); #endif -__KERNEL_RCSID(0, "$NetBSD: ixp425_npe.c,v 1.6 2009/10/26 19:16:55 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixp425_npe.c,v 1.7 2011/05/13 22:28:40 rmind Exp $"); /* * Intel XScale Network Processing Engine (NPE) support. @@ -1384,15 +1384,8 @@ { if (!sc->sc_msgwaiting) { -#if 0 - /* - * This ltsleep() is dangerous because this function may be - * called under interrupt context. - */ - ltsleep(sc, 0, "npemh", 0, &sc->sc_lock); -#else + /* XXX interrupt context - cannot sleep */ delay(1000); /* wait 1ms (is it ok?)*/ -#endif } memcpy(msg, sc->sc_msg, sizeof(sc->sc_msg)); /* NB: sc_msgwaiting != 1 means the ack fetch failed */ Index: src/sys/dev/ppbus/ppbus_conf.c diff -u src/sys/dev/ppbus/ppbus_conf.c:1.18 src/sys/dev/ppbus/ppbus_conf.c:1.19 --- src/sys/dev/ppbus/ppbus_conf.c:1.18 Wed Nov 11 15:34:37 2009 +++ src/sys/dev/ppbus/ppbus_conf.c Fri May 13 22:28:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ppbus_conf.c,v 1.18 2009/11/11 15:34:37 he Exp $ */ +/* $NetBSD: ppbus_conf.c,v 1.19 2011/05/13 22:28:40 rmind Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ppbus_conf.c,v 1.18 2009/11/11 15:34:37 he Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ppbus_conf.c,v 1.19 2011/05/13 22:28:40 rmind Exp $"); #include "opt_ppbus.h" #include "opt_ppbus_1284.h" @@ -155,7 +155,7 @@ printf("%s: IEEE1284 device found.\n", device_xname(self)); /* * Detect device ID (interrupts must be disabled because we - * cannot do a ltsleep() to wait for it - no context) + * cannot do a block to wait for it - no context) */ if (args.capabilities & PPBUS_HAS_INTR) { int val = 0;
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Fri May 13 22:22:56 UTC 2011 Modified Files: src/sys/kern: sysv_shm.c Log Message: - Replace shmmap_entry_pool with kmem(9), as pool is not worth. - Sprinkle __cacheline_aligned and __read_mostly. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/kern/sysv_shm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sysv_shm.c diff -u src/sys/kern/sysv_shm.c:1.118 src/sys/kern/sysv_shm.c:1.119 --- src/sys/kern/sysv_shm.c:1.118 Tue Jul 27 14:25:23 2010 +++ src/sys/kern/sysv_shm.c Fri May 13 22:22:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sysv_shm.c,v 1.118 2010/07/27 14:25:23 jakllsch Exp $ */ +/* $NetBSD: sysv_shm.c,v 1.119 2011/05/13 22:22:55 rmind Exp $ */ /*- * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.118 2010/07/27 14:25:23 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.119 2011/05/13 22:22:55 rmind Exp $"); #define SYSVSHM @@ -76,26 +76,25 @@ #include /* XXX for */ #include #include -#include #include #include #include -int shm_nused; -struct shmid_ds *shmsegs; - struct shmmap_entry { SLIST_ENTRY(shmmap_entry) next; vaddr_t va; int shmid; }; -static kmutex_t shm_lock; -static kcondvar_t * shm_cv; -static struct pool shmmap_entry_pool; -static int shm_last_free, shm_use_phys; -static size_t shm_committed; +int shm_nused __cacheline_aligned; +struct shmid_ds * shmsegs __read_mostly; + +static kmutex_t shm_lock __cacheline_aligned; +static kcondvar_t * shm_cv __cacheline_aligned; +static int shm_last_free __cacheline_aligned; +static size_t shm_committed __cacheline_aligned; +static int shm_use_phys __read_mostly; static kcondvar_t shm_realloc_cv; static bool shm_realloc_state; @@ -230,7 +229,7 @@ /* 3. A shared shm map, copy to a fresh one and adjust refcounts */ SLIST_FOREACH(oshmmap_se, &oshmmap_s->entries, next) { - shmmap_se = pool_get(&shmmap_entry_pool, PR_WAITOK); + shmmap_se = kmem_alloc(sizeof(struct shmmap_entry), KM_SLEEP); shmmap_se->va = oshmmap_se->va; shmmap_se->shmid = oshmmap_se->shmid; SLIST_INSERT_HEAD(&shmmap_s->entries, shmmap_se, next); @@ -354,9 +353,10 @@ mutex_exit(&shm_lock); uvm_deallocate(&p->p_vmspace->vm_map, shmmap_se->va, size); - if (uobj != NULL) + if (uobj != NULL) { uao_detach(uobj); - pool_put(&shmmap_entry_pool, shmmap_se); + } + kmem_free(shmmap_se, sizeof(struct shmmap_entry)); return 0; } @@ -385,7 +385,7 @@ vsize_t size; /* Allocate a new map entry and set it */ - shmmap_se = pool_get(&shmmap_entry_pool, PR_WAITOK); + shmmap_se = kmem_alloc(sizeof(struct shmmap_entry), KM_SLEEP); shmmap_se->shmid = SCARG(uap, shmid); mutex_enter(&shm_lock); @@ -475,8 +475,9 @@ err: cv_broadcast(&shm_realloc_cv); mutex_exit(&shm_lock); - if (error && shmmap_se) - pool_put(&shmmap_entry_pool, shmmap_se); + if (error && shmmap_se) { + kmem_free(shmmap_se, sizeof(struct shmmap_entry)); + } return error; err_detach: @@ -486,9 +487,10 @@ shm_realloc_disable--; cv_broadcast(&shm_realloc_cv); mutex_exit(&shm_lock); - if (uobj != NULL) + if (uobj != NULL) { uao_detach(uobj); - pool_put(&shmmap_entry_pool, shmmap_se); + } + kmem_free(shmmap_se, sizeof(struct shmmap_entry)); return error; } @@ -847,7 +849,7 @@ if (uobj != NULL) { uao_detach(uobj); } - pool_put(&shmmap_entry_pool, shmmap_se); + kmem_free(shmmap_se, sizeof(struct shmmap_entry)); if (SLIST_EMPTY(&shmmap_s->entries)) { break; @@ -945,8 +947,6 @@ int i; mutex_init(&shm_lock, MUTEX_DEFAULT, IPL_NONE); - pool_init(&shmmap_entry_pool, sizeof(struct shmmap_entry), 0, 0, 0, - "shmmp", &pool_allocator_nointr, IPL_NONE); cv_init(&shm_realloc_cv, "shmrealc"); /* Allocate the wired memory for our structures */
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Fri May 13 22:22:03 UTC 2011 Modified Files: src/sys/kern: kern_proc.c Log Message: Sprinkle __cacheline_aligned and __read_mostly, also const-ify. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/sys/kern/kern_proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.179 src/sys/kern/kern_proc.c:1.180 --- src/sys/kern/kern_proc.c:1.179 Sun May 1 01:15:18 2011 +++ src/sys/kern/kern_proc.c Fri May 13 22:22:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.179 2011/05/01 01:15:18 rmind Exp $ */ +/* $NetBSD: kern_proc.c,v 1.180 2011/05/13 22:22:03 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.179 2011/05/01 01:15:18 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.180 2011/05/13 22:22:03 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -110,13 +110,13 @@ #endif /* - * Other process lists + * Process lists. */ -struct proclist allproc; -struct proclist zombproc; /* resources have been freed */ +struct proclist allproc __cacheline_aligned; +struct proclist zombproc __cacheline_aligned; -kmutex_t *proc_lock; +kmutex_t * proc_lock __cacheline_aligned; /* * pid to proc lookup is done by indexing the pid_table array. @@ -144,15 +144,22 @@ #define P_NEXT(p) (p2u(p) >> 1) #define P_FREE(pid) ((struct proc *)(uintptr_t)((pid) << 1 | 1)) -#define INITIAL_PID_TABLE_SIZE (1 << 5) -static struct pid_table *pid_table; -static uint pid_tbl_mask = INITIAL_PID_TABLE_SIZE - 1; -static uint pid_alloc_lim; /* max we allocate before growing table */ -static uint pid_alloc_cnt; /* number of allocated pids */ - -/* links through free slots - never empty! */ -static uint next_free_pt, last_free_pt; -static pid_t pid_max = PID_MAX; /* largest value we allocate */ +/* + * Table of process IDs (PIDs). + */ +static struct pid_table *pid_table __read_mostly; + +#define INITIAL_PID_TABLE_SIZE (1 << 5) + +/* Table mask, threshold for growing and number of allocated PIDs. */ +static u_int pid_tbl_mask __read_mostly; +static u_int pid_alloc_lim __read_mostly; +static u_int pid_alloc_cnt __cacheline_aligned; + +/* Next free, last free and maximum PIDs. */ +static u_int next_free_pt __cacheline_aligned; +static u_int last_free_pt __cacheline_aligned; +static pid_t pid_max __read_mostly; /* Components of the first process -- never freed. */ @@ -200,9 +207,9 @@ }; kauth_cred_t cred0; -int nofile = NOFILE; -int maxuprc = MAXUPRC; -int cmask = CMASK; +static const int nofile = NOFILE; +static const int maxuprc = MAXUPRC; +static const int cmask = CMASK; static int sysctl_doeproc(SYSCTLFN_PROTO); static int sysctl_kern_proc_args(SYSCTLFN_PROTO); @@ -317,6 +324,8 @@ proc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); pid_table = kmem_alloc(INITIAL_PID_TABLE_SIZE * sizeof(struct pid_table), KM_SLEEP); + pid_tbl_mask = INITIAL_PID_TABLE_SIZE - 1; + pid_max = PID_MAX; /* Set free list running through table... Preset 'use count' above PID_MAX so we allocate pid 1 next. */
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Fri May 13 22:19:41 UTC 2011 Modified Files: src/sys/kern: kern_sleepq.c kern_turnstile.c Log Message: Sprinkle __cacheline_aligned and __read_mostly, make some functions static. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/kern/kern_sleepq.c cvs rdiff -u -r1.28 -r1.29 src/sys/kern/kern_turnstile.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_sleepq.c diff -u src/sys/kern/kern_sleepq.c:1.38 src/sys/kern/kern_sleepq.c:1.39 --- src/sys/kern/kern_sleepq.c:1.38 Wed Apr 27 08:32:42 2011 +++ src/sys/kern/kern_sleepq.c Fri May 13 22:19:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sleepq.c,v 1.38 2011/04/27 08:32:42 plunky Exp $ */ +/* $NetBSD: kern_sleepq.c,v 1.39 2011/05/13 22:19:41 rmind Exp $ */ /*- * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.38 2011/04/27 08:32:42 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.39 2011/05/13 22:19:41 rmind Exp $"); #include #include @@ -54,10 +54,10 @@ #include "opt_sa.h" -int sleepq_sigtoerror(lwp_t *, int); +static int sleepq_sigtoerror(lwp_t *, int); /* General purpose sleep table, used by ltsleep() and condition variables. */ -sleeptab_t sleeptab; +sleeptab_t sleeptab __cacheline_aligned; /* * sleeptab_init: @@ -378,7 +378,7 @@ * * Given a signal number, interpret and return an error code. */ -int +static int sleepq_sigtoerror(lwp_t *l, int sig) { struct proc *p = l->l_proc; Index: src/sys/kern/kern_turnstile.c diff -u src/sys/kern/kern_turnstile.c:1.28 src/sys/kern/kern_turnstile.c:1.29 --- src/sys/kern/kern_turnstile.c:1.28 Wed Nov 18 12:26:22 2009 +++ src/sys/kern/kern_turnstile.c Fri May 13 22:19:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_turnstile.c,v 1.28 2009/11/18 12:26:22 yamt Exp $ */ +/* $NetBSD: kern_turnstile.c,v 1.29 2011/05/13 22:19:41 rmind Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.28 2009/11/18 12:26:22 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.29 2011/05/13 22:19:41 rmind Exp $"); #include #include @@ -75,12 +75,12 @@ #define TS_HASH_MASK (TS_HASH_SIZE - 1) #define TS_HASH(obj) (((uintptr_t)(obj) >> 3) & TS_HASH_MASK) -tschain_t turnstile_tab[TS_HASH_SIZE]; -pool_cache_t turnstile_cache; +static tschain_t turnstile_tab[TS_HASH_SIZE] __cacheline_aligned; +pool_cache_t turnstile_cache __read_mostly; -int turnstile_ctor(void *, void *, int); +static int turnstile_ctor(void *, void *, int); -extern turnstile_t turnstile0; +extern turnstile_t turnstile0; /* * turnstile_init: @@ -111,7 +111,7 @@ * * Constructor for turnstiles. */ -int +static int turnstile_ctor(void *arg, void *obj, int flags) { turnstile_t *ts = obj;
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Fri May 13 22:16:44 UTC 2011 Modified Files: src/sys/kern: kern_cpu.c kern_mutex_obj.c kern_rwlock_obj.c kern_synch.c subr_percpu.c subr_xcall.c sysv_sem.c vfs_vnode.c Log Message: Sprinkle __cacheline_aligned and __read_mostly. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/kern/kern_cpu.c cvs rdiff -u -r1.2 -r1.3 src/sys/kern/kern_mutex_obj.c \ src/sys/kern/kern_rwlock_obj.c cvs rdiff -u -r1.288 -r1.289 src/sys/kern/kern_synch.c cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_percpu.c \ src/sys/kern/subr_xcall.c cvs rdiff -u -r1.86 -r1.87 src/sys/kern/sysv_sem.c cvs rdiff -u -r1.5 -r1.6 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_cpu.c diff -u src/sys/kern/kern_cpu.c:1.45 src/sys/kern/kern_cpu.c:1.46 --- src/sys/kern/kern_cpu.c:1.45 Wed Dec 22 02:43:23 2010 +++ src/sys/kern/kern_cpu.c Fri May 13 22:16:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_cpu.c,v 1.45 2010/12/22 02:43:23 matt Exp $ */ +/* $NetBSD: kern_cpu.c,v 1.46 2011/05/13 22:16:43 rmind Exp $ */ /*- * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.45 2010/12/22 02:43:23 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.46 2011/05/13 22:16:43 rmind Exp $"); #include #include @@ -103,13 +103,14 @@ D_OTHER | D_MPSAFE }; -kmutex_t cpu_lock; -int ncpu; -int ncpuonline; -bool mp_online; -struct cpuqueue cpu_queue = CIRCLEQ_HEAD_INITIALIZER(cpu_queue); +kmutex_t cpu_lock __cacheline_aligned; +int ncpu __read_mostly; +int ncpuonline __read_mostly; +bool mp_online __read_mostly; +struct cpuqueue cpu_queue __cacheline_aligned += CIRCLEQ_HEAD_INITIALIZER(cpu_queue); -static struct cpu_info **cpu_infos; +static struct cpu_info **cpu_infos __read_mostly; int mi_cpu_attach(struct cpu_info *ci) Index: src/sys/kern/kern_mutex_obj.c diff -u src/sys/kern/kern_mutex_obj.c:1.2 src/sys/kern/kern_mutex_obj.c:1.3 --- src/sys/kern/kern_mutex_obj.c:1.2 Wed Mar 31 19:59:39 2010 +++ src/sys/kern/kern_mutex_obj.c Fri May 13 22:16:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $ */ +/* $NetBSD: kern_mutex_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $"); #include #include @@ -47,7 +47,7 @@ static int mutex_obj_ctor(void *, void *, int); -static pool_cache_t mutex_obj_cache; +static pool_cache_t mutex_obj_cache __read_mostly; /* * mutex_obj_init: Index: src/sys/kern/kern_rwlock_obj.c diff -u src/sys/kern/kern_rwlock_obj.c:1.2 src/sys/kern/kern_rwlock_obj.c:1.3 --- src/sys/kern/kern_rwlock_obj.c:1.2 Wed Mar 31 19:59:39 2010 +++ src/sys/kern/kern_rwlock_obj.c Fri May 13 22:16:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rwlock_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $ */ +/* $NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $"); #include #include @@ -47,7 +47,7 @@ static int rw_obj_ctor(void *, void *, int); -static pool_cache_t rw_obj_cache; +static pool_cache_t rw_obj_cache __read_mostly; /* * rw_obj_init: Index: src/sys/kern/kern_synch.c diff -u src/sys/kern/kern_synch.c:1.288 src/sys/kern/kern_synch.c:1.289 --- src/sys/kern/kern_synch.c:1.288 Mon May 2 00:29:53 2011 +++ src/sys/kern/kern_synch.c Fri May 13 22:16:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $ */ +/* $NetBSD: kern_synch.c,v 1.289 2011/05/13 22:16:43 rmind Exp $ */ /*- * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.289 2011/05/13 22:16:43 rmind Exp $"); #include "opt_kstack.h" #include "opt_perfctrs.h" @@ -128,13 +128,15 @@ syncobj_noowner, }; -unsigned sched_pstats_ticks; -kcondvar_t lbolt; /* once a second sleep address */ +/* "Lightning bolt": once a second sleep address. */ +kcondvar_t lbolt __cacheline_aligned; -/* Preemption event counters */ -static struct evcnt kpreempt_ev_crit; -static struct evcnt kpreempt_ev_klock; -static struct evcnt kpreempt_ev_immed; +u_int sched_pstats_ticks __cacheline_aligned; + +/* Preemption event counters. */ +static struct evcnt kpreempt_ev_crit
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Mon May 2 23:42:10 UTC 2011 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Constify, update some comments, use memset() to clear pgs. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.77 src/sys/fs/tmpfs/tmpfs_vnops.c:1.78 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.77 Sun Apr 24 21:35:29 2011 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Mon May 2 23:42:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.77 2011/04/24 21:35:29 rmind Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.78 2011/05/02 23:42:10 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.77 2011/04/24 21:35:29 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.78 2011/05/02 23:42:10 rmind Exp $"); #include #include @@ -738,7 +738,7 @@ } /* - * tmpfs:link: create hard link. + * tmpfs_link: create hard link. */ int tmpfs_link(void *v) @@ -1395,25 +1395,29 @@ return lf_advlock(v, &node->tn_lockf, node->tn_size); } -/* - */ - int tmpfs_getpages(void *v) { - struct vnode *vp = ((struct vop_getpages_args *)v)->a_vp; - voff_t offset = ((struct vop_getpages_args *)v)->a_offset; - struct vm_page **m = ((struct vop_getpages_args *)v)->a_m; - int *count = ((struct vop_getpages_args *)v)->a_count; - int centeridx = ((struct vop_getpages_args *)v)->a_centeridx; - vm_prot_t access_type = ((struct vop_getpages_args *)v)->a_access_type; - int advice = ((struct vop_getpages_args *)v)->a_advice; - int flags = ((struct vop_getpages_args *)v)->a_flags; - - int error; - int i; + struct vop_getpages_args /* { + struct vnode *a_vp; + voff_t a_offset; + struct vm_page **a_m; + int *a_count; + int a_centeridx; + vm_prot_t a_access_type; + int a_advice; + int a_flags; + } */ * const ap = v; + struct vnode *vp = ap->a_vp; + const voff_t offset = ap->a_offset; + struct vm_page **pgs = ap->a_m; + const int centeridx = ap->a_centeridx; + const vm_prot_t access_type = ap->a_access_type; + const int advice = ap->a_advice; + const int flags = ap->a_flags; + int error, npages = *ap->a_count; struct tmpfs_node *node; struct uvm_object *uobj; - int npages = *count; KASSERT(vp->v_type == VREG); KASSERT(mutex_owned(&vp->v_interlock)); @@ -1421,8 +1425,9 @@ node = VP_TO_TMPFS_NODE(vp); uobj = node->tn_spec.tn_reg.tn_aobj; - /* We currently don't rely on PGO_PASTEOF. */ - + /* + * Currently, PGO_PASTEOF is not supported. + */ if (vp->v_size <= offset + (centeridx << PAGE_SHIFT)) { if ((flags & PGO_LOCKED) == 0) mutex_exit(&vp->v_interlock); @@ -1447,47 +1452,44 @@ mutex_exit(&vp->v_interlock); /* - * Make sure that the array on which we will store the - * gotten pages is clean. Otherwise uao_get (pointed to by - * the pgo_get below) gets confused and does not return the - * appropriate pages. + * Invoke the pager. * - * XXX This shall be revisited when kern/32166 is addressed - * because the loop to clean m[i] will most likely be redundant - * as well as the PGO_ALLPAGES flag. + * Clean the array of pages before. XXX: PR/32166 + * Note that vnode lock is shared with underlying UVM object. */ - if (m != NULL) - for (i = 0; i < npages; i++) - m[i] = NULL; + if (pgs) { + memset(pgs, 0, sizeof(struct vm_pages *) * npages); + } mutex_enter(&uobj->vmobjlock); - error = (*uobj->pgops->pgo_get)(uobj, offset, m, &npages, centeridx, + error = (*uobj->pgops->pgo_get)(uobj, offset, pgs, &npages, centeridx, access_type, advice, flags | PGO_ALLPAGES); + #if defined(DEBUG) - { - /* Make sure that all the pages we return are valid. */ - int dbgi; - if (error == 0 && m != NULL) - for (dbgi = 0; dbgi < npages; dbgi++) -KASSERT(m[dbgi] != NULL); + if (!error && pgs) { + for (int i = 0; i < npages; i++) { + KASSERT(pgs[i] != NULL); + } } #endif - return error; } -/* - */ - int tmpfs_putpages(void *v) { - struct vnode *vp = ((struct vop_putpages_args *)v)->a_vp; - voff_t offlo = ((struct vop_putpages_args *)v)->a_offlo; - voff_t offhi = ((struct vop_putpages_args *)v)->a_offhi; - int flags = ((struct vop_putpages_args *)v)->a_flags; - - int error; + struct vop_putpages_args /* { + struct vnode *a_vp; + voff_t a_offlo; + voff_t a_offhi; + int a_flags; + } */ * const ap = v; + struct vnode *vp = ap->a_vp; + const voff_t offlo = ap->a_offlo; + const voff_t offhi = ap->a_offhi; + const int flags = ap->a_flags; struct tmpfs_node *node; struct uvm_object *uobj; + int error; KASSERT(mutex_owned(&vp->v_interlock))
CVS commit: src/sys/sys
Module Name:src Committed By: rmind Date: Mon May 2 22:27:53 UTC 2011 Modified Files: src/sys/sys: proc.h Log Message: Update few comments. To generate a diff of this commit: cvs rdiff -u -r1.306 -r1.307 src/sys/sys/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/proc.h diff -u src/sys/sys/proc.h:1.306 src/sys/sys/proc.h:1.307 --- src/sys/sys/proc.h:1.306 Sun May 1 01:15:18 2011 +++ src/sys/sys/proc.h Mon May 2 22:27:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.306 2011/05/01 01:15:18 rmind Exp $ */ +/* $NetBSD: proc.h,v 1.307 2011/05/02 22:27:53 rmind Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -194,15 +194,14 @@ * which might be addressible only on a processor on which the process * is running. * - * Field markings and the corresponding locks (not yet fully implemented, - * more a statement of intent): + * Field markings and the corresponding locks: * * a: p_auxlock * k: ktrace_mutex * l: proc_lock * t: p_stmutex * p: p_lock - * q: mqlist_mtx + * (: updated atomically * :: unlocked, stable */ struct proc { @@ -224,7 +223,7 @@ struct vmspace *p_vmspace; /* :: Address space */ struct sigacts *p_sigacts; /* :: Process sigactions */ struct aioproc *p_aio; /* p: Asynchronous I/O data */ - u_int p_mqueue_cnt; /* q: Count of open mqueues */ + u_int p_mqueue_cnt; /* (: Count of open message queues */ specificdata_reference p_specdataref; /*subsystem proc-specific data */
CVS commit: src/doc
Module Name:src Committed By: rmind Date: Mon May 2 21:00:46 UTC 2011 Modified Files: src/doc: CHANGES Log Message: Mention POSIX semaphore improvements and PowerPC conversion to use PCU. To generate a diff of this commit: cvs rdiff -u -r1.1543 -r1.1544 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1543 src/doc/CHANGES:1.1544 --- src/doc/CHANGES:1.1543 Fri Apr 29 20:33:42 2011 +++ src/doc/CHANGES Mon May 2 21:00:46 2011 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1543 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1544 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -943,7 +943,7 @@ more efficient, added "fast" software interrupts and kernel preemption. Added support for RMI (NetLogic) XLS/XLR models. Major clean up for MIPS port. [matt 20110220] - mips: Converted MIPS to use PCU. [matt 20110220] + mips: Converted MIPS to use PCU to manage FPU. [matt 20110220] ath(4): Add support for AR9285 devices. [cegger 20110221] libsaslc(3): Complete integration of libsaslc written for GSoC 2010 by Mateusz Kocielski, improved and integrated with Postfix @@ -996,7 +996,10 @@ dhcpcd(8): Import dhcpcd-5.2.12. [roy 20110406] sparc64: Add EDID (Extended Display Identification Data) reading, and video mode setting support, to ffb(4). [jdc 20110408] + kernel: Bug fixes and improvements to POSIX semaphore. [rmind 20110411] kernel: Support for Darwin, Mach, IRIX and PECOFF emulation was retired. [joerg 20110426] balloon(4): Balloon driver now enabled for all Xen kernels. [jym 20110429] + powerpc: Converted PowerPC to use PCU to manage FPU/AltiVec/SPE. + [matt 20110502]
CVS commit: src/doc
Module Name:src Committed By: rmind Date: Mon May 2 20:48:28 UTC 2011 Modified Files: src/doc: BRANCHES Log Message: Update description of rmind-uvmplock branch. To generate a diff of this commit: cvs rdiff -u -r1.305 -r1.306 src/doc/BRANCHES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/BRANCHES diff -u src/doc/BRANCHES:1.305 src/doc/BRANCHES:1.306 --- src/doc/BRANCHES:1.305 Mon Feb 21 02:35:55 2011 +++ src/doc/BRANCHES Mon May 2 20:48:27 2011 @@ -1,4 +1,4 @@ -# $NetBSD: BRANCHES,v 1.305 2011/02/21 02:35:55 itohy Exp $ +# $NetBSD: BRANCHES,v 1.306 2011/05/02 20:48:27 rmind Exp $ # # This file contains a list of branches that exist in the NetBSD CVS # tree and their current state. @@ -486,7 +486,7 @@ within the same tree Branch: rmind-uvmplock -Description: Reorganize locking in UVM for pmap(9) +Description: Reorganize locking in UVM and improve x86 pmap(9) Status: Active Start Date: 15 March 2010 End Date: @@ -501,9 +501,13 @@ - Simplify locking in pmap(9) modules by removing P->V locking. - Use mutex_obj(9) on vmobjlock (and thus vnode_t::v_interlock) to share locks among UVM objects where necessary. - - Optimize pmap_remove() with tracking in struct vm_map_entry. + - Rewrite and optimize x86 TLB shootdown code. - Unify /dev/mem et al in MI code and provide required locking. + Future work: + + - Optimize pmap_remove() with tracking in struct vm_map_entry. + Branch: rpaulo-netinet-merge-pcb Description: merge in6pcb with inpcb Status: Dormant
CVS commit: src/sys/sys
Module Name:src Committed By: rmind Date: Mon May 2 02:28:58 UTC 2011 Modified Files: src/sys/sys: lwp.h pcu.h Log Message: Limit sys/pcu.h inclusion within _KERNEL scope, plus _KMEMUSER. To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/sys/sys/lwp.h cvs rdiff -u -r1.5 -r1.6 src/sys/sys/pcu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/lwp.h diff -u src/sys/sys/lwp.h:1.150 src/sys/sys/lwp.h:1.151 --- src/sys/sys/lwp.h:1.150 Tue Mar 8 12:39:29 2011 +++ src/sys/sys/lwp.h Mon May 2 02:28:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lwp.h,v 1.150 2011/03/08 12:39:29 pooka Exp $ */ +/* $NetBSD: lwp.h,v 1.151 2011/05/02 02:28:57 rmind Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010 @@ -44,7 +44,6 @@ #include #include #include -#include #if defined(_KERNEL) #include /* curcpu() and cpu_info */ @@ -68,6 +67,9 @@ * of cache hits) and by size (to reduce dead space in the structure). */ #if defined(_KERNEL) || defined(_KMEMUSER) + +#include + struct lockdebug; struct sadata_vp; struct sysent; Index: src/sys/sys/pcu.h diff -u src/sys/sys/pcu.h:1.5 src/sys/sys/pcu.h:1.6 --- src/sys/sys/pcu.h:1.5 Mon May 2 00:29:53 2011 +++ src/sys/sys/pcu.h Mon May 2 02:28:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pcu.h,v 1.5 2011/05/02 00:29:53 rmind Exp $ */ +/* $NetBSD: pcu.h,v 1.6 2011/05/02 02:28:57 rmind Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #ifndef _SYS_PCU_H_ #define _SYS_PCU_H_ -#if !defined(_KERNEL) +#if !defined(_KERNEL) && !defined(_KMEMUSER) #error "not supposed to be exposed to userland" #endif
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Mon May 2 00:29:54 UTC 2011 Modified Files: src/sys/arch/mips/include: cpu.h src/sys/arch/mips/mips: compat_16_machdep.c cpu_subr.c mips_fpu.c netbsd32_machdep.c process_machdep.c vm_machdep.c src/sys/kern: kern_synch.c subr_pcu.c src/sys/sys: pcu.h Log Message: Extend PCU: - Add pcu_ops_t::pcu_state_release() operation for PCU_RELEASE case. - Add pcu_switchpoint() to perform release operation on context switch. - Sprinkle const, misc. Also, sync MIPS with changes. Per discussions with matt@. To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/arch/mips/include/cpu.h cvs rdiff -u -r1.19 -r1.20 src/sys/arch/mips/mips/compat_16_machdep.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/mips/cpu_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/mips/mips_fpu.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/mips/netbsd32_machdep.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/mips/mips/process_machdep.c cvs rdiff -u -r1.137 -r1.138 src/sys/arch/mips/mips/vm_machdep.c cvs rdiff -u -r1.287 -r1.288 src/sys/kern/kern_synch.c cvs rdiff -u -r1.3 -r1.4 src/sys/kern/subr_pcu.c cvs rdiff -u -r1.4 -r1.5 src/sys/sys/pcu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/include/cpu.h diff -u src/sys/arch/mips/include/cpu.h:1.101 src/sys/arch/mips/include/cpu.h:1.102 --- src/sys/arch/mips/include/cpu.h:1.101 Thu Apr 14 05:07:30 2011 +++ src/sys/arch/mips/include/cpu.h Mon May 2 00:29:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.101 2011/04/14 05:07:30 cliff Exp $ */ +/* $NetBSD: cpu.h,v 1.102 2011/05/02 00:29:54 rmind Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -624,8 +624,7 @@ void fpu_discard(void); void fpu_load(void); void fpu_save(void); -void fpu_save_lwp(struct lwp *); -bool fpu_used_p(struct lwp *); +bool fpu_used_p(void); /* mips_machdep.c */ void dumpsys(void); Index: src/sys/arch/mips/mips/compat_16_machdep.c diff -u src/sys/arch/mips/mips/compat_16_machdep.c:1.19 src/sys/arch/mips/mips/compat_16_machdep.c:1.20 --- src/sys/arch/mips/mips/compat_16_machdep.c:1.19 Fri Apr 29 22:11:15 2011 +++ src/sys/arch/mips/mips/compat_16_machdep.c Mon May 2 00:29:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_16_machdep.c,v 1.19 2011/04/29 22:11:15 matt Exp $ */ +/* $NetBSD: compat_16_machdep.c,v 1.20 2011/05/02 00:29:54 rmind Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.19 2011/04/29 22:11:15 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.20 2011/05/02 00:29:54 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_cputype.h" @@ -131,7 +131,7 @@ #endif /* Save the FP state, if necessary, then copy it. */ - ksc.sc_fpused = fpu_used_p(l); + ksc.sc_fpused = fpu_used_p(); #if !defined(NOFPU) if (ksc.sc_fpused) { /* if FPU has current state, save it first */ Index: src/sys/arch/mips/mips/cpu_subr.c diff -u src/sys/arch/mips/mips/cpu_subr.c:1.12 src/sys/arch/mips/mips/cpu_subr.c:1.13 --- src/sys/arch/mips/mips/cpu_subr.c:1.12 Mon May 2 00:17:35 2011 +++ src/sys/arch/mips/mips/cpu_subr.c Mon May 2 00:29:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.12 2011/05/02 00:17:35 matt Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.13 2011/05/02 00:29:54 rmind Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.12 2011/05/02 00:17:35 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.13 2011/05/02 00:29:54 rmind Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -395,7 +395,8 @@ *flags |= _UC_CPU | _UC_TLSBASE; /* Save floating point register context, if any. */ - if (fpu_used_p(l)) { + KASSERT(l == curlwp); + if (fpu_used_p()) { size_t fplen; /* * If this process is the current FP owner, dump its Index: src/sys/arch/mips/mips/mips_fpu.c diff -u src/sys/arch/mips/mips/mips_fpu.c:1.4 src/sys/arch/mips/mips/mips_fpu.c:1.5 --- src/sys/arch/mips/mips/mips_fpu.c:1.4 Fri Apr 29 22:18:16 2011 +++ src/sys/arch/mips/mips/mips_fpu.c Mon May 2 00:29:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: mips_fpu.c,v 1.4 2011/04/29 22:18:16 matt Exp $ */ +/* $NetBSD: mips_fpu.c,v 1.5 2011/05/02 00:29:54 rmind Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mips_fpu.c,v 1.4 2011/04/29 22:18:16 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mips_fpu.c,v 1.5 2011/05/02 00:29:54 rmind Exp $"); #include "opt_multiprocessor.h" @@ -46,20 +46,26 @@ #include #include -static void mips_fpu_state_save(lwp_t *, bool); +static void mips_fpu_state_save(lwp_t *); static void mips_fpu_state_load(lwp_t *, bool); +static void mips_fpu_state_release(lwp_t
CVS commit: src/sys/dev/nand
Module Name:src Committed By: rmind Date: Sun May 1 13:20:29 UTC 2011 Modified Files: src/sys/dev/nand: nand.c nand_bbt.c nand_io.c nand_micron.c Log Message: Remove trailing tabs, add RCS IDs. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nand/nand.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/nand/nand_bbt.c \ src/sys/dev/nand/nand_micron.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/nand/nand_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nand/nand.c diff -u src/sys/dev/nand/nand.c:1.10 src/sys/dev/nand/nand.c:1.11 --- src/sys/dev/nand/nand.c:1.10 Tue Apr 26 17:31:57 2011 +++ src/sys/dev/nand/nand.c Sun May 1 13:20:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nand.c,v 1.10 2011/04/26 17:31:57 ahoka Exp $ */ +/* $NetBSD: nand.c,v 1.11 2011/05/01 13:20:28 rmind Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -34,7 +34,7 @@ /* Common driver for NAND chips implementing the ONFI 2.2 specification */ #include -__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.10 2011/04/26 17:31:57 ahoka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.11 2011/05/01 13:20:28 rmind Exp $"); #include "locators.h" @@ -343,7 +343,7 @@ default: return 1; } - + return 0; } @@ -375,9 +375,9 @@ if (onfi_signature[0] != 'O' || onfi_signature[1] != 'N' || onfi_signature[2] != 'F' || onfi_signature[3] != 'I') { chip->nc_isonfi = false; - + aprint_normal(": Legacy NAND Flash\n"); - + nand_read_id(self, &chip->nc_manf_id, &chip->nc_dev_id); if (nand_fill_chip_structure_legacy(self, chip)) { @@ -391,11 +391,10 @@ aprint_normal(": ONFI NAND Flash\n"); nand_read_id(self, &chip->nc_manf_id, &chip->nc_dev_id); - + if (nand_fill_chip_structure(self, chip)) { aprint_error_dev(self, "can't read device parameters\n"); - return 1; } } @@ -488,10 +487,10 @@ nand_select(self, true); nand_command(self, ONFI_READ_ID); nand_address(self, 0x00); - + nand_read_byte(self, manf); nand_read_byte(self, dev); - + nand_select(self, false); } @@ -1300,9 +1299,7 @@ addr += chip->nc_page_size; } - KASSERT(*retlen == len); - out: mutex_exit(&sc->sc_device_lock); @@ -1341,7 +1338,6 @@ if (len < chip->nc_page_size) panic("TODO page size is larger than read size"); #endif - if (len % chip->nc_page_size != 0 || offset % chip->nc_page_size != 0) { @@ -1369,7 +1365,6 @@ addr += chip->nc_page_size; *retlen += chip->nc_page_size; } - out: mutex_exit(&sc->sc_device_lock); @@ -1402,7 +1397,7 @@ mutex_exit(&sc->sc_device_lock); *isbad = result; - + return 0; } @@ -1473,7 +1468,6 @@ if (nand_isbad(self, addr)) { aprint_error_dev(self, "bad block encountered\n"); ei->ei_state = FLASH_ERASE_FAILED; - error = EIO; goto out; } @@ -1481,7 +1475,6 @@ error = nand_erase_block(self, addr); if (error) { ei->ei_state = FLASH_ERASE_FAILED; - goto out; } Index: src/sys/dev/nand/nand_bbt.c diff -u src/sys/dev/nand/nand_bbt.c:1.3 src/sys/dev/nand/nand_bbt.c:1.4 --- src/sys/dev/nand/nand_bbt.c:1.3 Tue Apr 26 13:38:13 2011 +++ src/sys/dev/nand/nand_bbt.c Sun May 1 13:20:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nand_bbt.c,v 1.3 2011/04/26 13:38:13 ahoka Exp $ */ +/* $NetBSD: nand_bbt.c,v 1.4 2011/05/01 13:20:28 rmind Exp $ */ /*- * Copyright (c) 2011 Department of Software Engineering, @@ -31,7 +31,12 @@ * SUCH DAMAGE. */ -/* Support for Bad Block Tables (BBTs) */ +/* + * Implementation of Bad Block Tables (BBTs). + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: nand_bbt.c,v 1.4 2011/05/01 13:20:28 rmind Exp $"); #include #include @@ -95,9 +100,9 @@ struct nand_softc *sc = device_private(self); struct nand_chip *chip = &sc->sc_chip; uint8_t *oob = chip->nc_oob_cache; - + nand_read_oob(self, addr, oob); - + if (oob[NAND_BBT_OFFSET] == 'B' && oob[NAND_BBT_OFFSET + 1] == 'b' && oob[NAND_BBT_OFFSET + 2] == 't') { @@ -123,26 +128,26 @@ if (nand_isbad(self, addr)) { return false; } - + if (nand_bbt_page_has_bbt(self, addr)) { bbtp = bbt->nbbt_bitmap; left = bbt->nbbt_size; - + for (i = 0; i < bbt_pages; i++) { nand_read_page(self, addr, buf); - + if (i == bbt_pages - 1) { KASSERT(left <= chip->nc_page_size); memcpy(bbtp, buf, left); } else { memcpy(bbtp, buf, chip->nc_page_size); } - + bbtp += chip->nc_page_size; left -= chip->nc_page_size; addr += chip->nc_page_size; } - + return true; } else { return false; Index: src/sys/dev/nand/nand_micron.c diff -u src/sys/dev/nand/nand_micron.c:1.3 src/sys/dev/nand/nand_micron.c:1.4 --- src/sys/dev/nand/nand_micron.c:1.3 Fri Mar 18 16:46:04 2011 +++ src/sys/dev/nand/nand_micron.c Sun May 1 13:20:28 2011 @@ -1,4 +1,5 @@ -/* $NetBSD: nand_micron.c,v 1.3 2011/03/18 16:46:04 a
CVS commit: src/sys/compat/netbsd32
Module Name:src Committed By: rmind Date: Sun May 1 02:08:15 UTC 2011 Modified Files: src/sys/compat/netbsd32: netbsd32_netbsd.c Log Message: Catch up with lim_privatise() change (missed in previous commit). To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/compat/netbsd32/netbsd32_netbsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/netbsd32/netbsd32_netbsd.c diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.169 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.170 --- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.169 Sun Mar 6 17:08:34 2011 +++ src/sys/compat/netbsd32/netbsd32_netbsd.c Sun May 1 02:08:15 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_netbsd.c,v 1.169 2011/03/06 17:08:34 bouyer Exp $ */ +/* $NetBSD: netbsd32_netbsd.c,v 1.170 2011/05/01 02:08:15 rmind Exp $ */ /* * Copyright (c) 1998, 2001, 2008 Matthew R. Green @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.169 2011/03/06 17:08:34 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.170 2011/05/01 02:08:15 rmind Exp $"); #if defined(_KERNEL_OPT) #include "opt_ddb.h" @@ -1950,7 +1950,7 @@ break; } - lim_privatise(p, false); + lim_privatise(p); lim = p->p_limit; for (i = 0; i < __arraycount(lm); i++) {
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun May 1 01:15:18 UTC 2011 Modified Files: src/sys/kern: kern_acct.c kern_fork.c kern_proc.c kern_resource.c src/sys/sys: proc.h resourcevar.h Log Message: - Remove FORK_SHARELIMIT and PL_SHAREMOD, simplify lim_privatise(). - Use kmem(9) for struct plimit::pl_corename. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/kern/kern_acct.c cvs rdiff -u -r1.182 -r1.183 src/sys/kern/kern_fork.c cvs rdiff -u -r1.178 -r1.179 src/sys/kern/kern_proc.c cvs rdiff -u -r1.160 -r1.161 src/sys/kern/kern_resource.c cvs rdiff -u -r1.305 -r1.306 src/sys/sys/proc.h cvs rdiff -u -r1.50 -r1.51 src/sys/sys/resourcevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_acct.c diff -u src/sys/kern/kern_acct.c:1.91 src/sys/kern/kern_acct.c:1.92 --- src/sys/kern/kern_acct.c:1.91 Sat Mar 26 21:31:23 2011 +++ src/sys/kern/kern_acct.c Sun May 1 01:15:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_acct.c,v 1.91 2011/03/26 21:31:23 dholland Exp $ */ +/* $NetBSD: kern_acct.c,v 1.92 2011/05/01 01:15:18 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.91 2011/03/26 21:31:23 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.92 2011/05/01 01:15:18 rmind Exp $"); #include #include @@ -423,7 +423,7 @@ * * XXX We should think about the CPU limit, too. */ - lim_privatise(p, false); + lim_privatise(p); orlim = p->p_rlimit[RLIMIT_FSIZE]; /* Set current and max to avoid illegal values */ p->p_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; Index: src/sys/kern/kern_fork.c diff -u src/sys/kern/kern_fork.c:1.182 src/sys/kern/kern_fork.c:1.183 --- src/sys/kern/kern_fork.c:1.182 Tue Apr 26 16:36:42 2011 +++ src/sys/kern/kern_fork.c Sun May 1 01:15:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.182 2011/04/26 16:36:42 joerg Exp $ */ +/* $NetBSD: kern_fork.c,v 1.183 2011/05/01 01:15:18 rmind Exp $ */ /*- * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.182 2011/04/26 16:36:42 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.183 2011/05/01 01:15:18 rmind Exp $"); #include "opt_ktrace.h" @@ -358,20 +358,15 @@ p2->p_cwdi = cwdinit(); /* - * p_limit (rlimit stuff) is usually copy-on-write, so we just need - * to bump pl_refcnt. - * However in some cases like clone the parent and child - * share limits - in which case nothing else must have a copy - * of the limits (PL_SHAREMOD is set). + * Note: p_limit (rlimit stuff) is copy-on-write, so normally + * we just need increase pl_refcnt. */ - if (__predict_false(flags & FORK_SHARELIMIT)) - lim_privatise(p1, 1); p1_lim = p1->p_limit; - if (p1_lim->pl_flags & PL_WRITEABLE && !(flags & FORK_SHARELIMIT)) - p2->p_limit = lim_copy(p1_lim); - else { + if (!p1_lim->pl_writeable) { lim_addref(p1_lim); p2->p_limit = p1_lim; + } else { + p2->p_limit = lim_copy(p1_lim); } p2->p_lflag = ((flags & FORK_PPWAIT) ? PL_PPWAIT : 0); Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.178 src/sys/kern/kern_proc.c:1.179 --- src/sys/kern/kern_proc.c:1.178 Sun May 1 00:22:36 2011 +++ src/sys/kern/kern_proc.c Sun May 1 01:15:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.178 2011/05/01 00:22:36 rmind Exp $ */ +/* $NetBSD: kern_proc.c,v 1.179 2011/05/01 01:15:18 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.178 2011/05/01 00:22:36 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.179 2011/05/01 01:15:18 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -453,8 +453,11 @@ rlim[RLIMIT_MEMLOCK].rlim_max = lim; rlim[RLIMIT_MEMLOCK].rlim_cur = lim / 3; + /* Note that default core name has zero length. */ limit0.pl_corename = defcorename; + limit0.pl_cnlen = 0; limit0.pl_refcnt = 1; + limit0.pl_writeable = false; limit0.pl_sv_limit = NULL; /* Configure virtual memory system, set vm rlimits. */ Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.160 src/sys/kern/kern_resource.c:1.161 --- src/sys/kern/kern_resource.c:1.160 Sun May 1 00:22:36 2011 +++ src/sys/kern/kern_resource.c Sun May 1 01:15:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.160 2011/05/01 00:22:36 rmind Exp $ */ +/* $NetBSD: kern_resource.c,v 1.161 2011/05/01 01:15:18 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.160 2011/05/01 00:22:36 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.161 2011/05/01 01:15:18 rmind Exp $"); #include #include @@
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun May 1 00:22:37 UTC 2011 Modified Files: src/sys/kern: kern_proc.c kern_resource.c src/sys/sys: resourcevar.h Log Message: Merge duplicate code fragments into a new lim_setcorename() routine. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/kern/kern_proc.c cvs rdiff -u -r1.159 -r1.160 src/sys/kern/kern_resource.c cvs rdiff -u -r1.49 -r1.50 src/sys/sys/resourcevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.177 src/sys/kern/kern_proc.c:1.178 --- src/sys/kern/kern_proc.c:1.177 Sun May 1 00:11:52 2011 +++ src/sys/kern/kern_proc.c Sun May 1 00:22:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $ */ +/* $NetBSD: kern_proc.c,v 1.178 2011/05/01 00:22:36 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.178 2011/05/01 00:22:36 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -1337,20 +1337,11 @@ { struct lwp *l = curlwp; struct proc *p = l->l_proc; - struct plimit *lim; kauth_cred_t oc; - char *cn; /* Reset what needs to be reset in plimit. */ if (p->p_limit->pl_corename != defcorename) { - lim_privatise(p, false); - lim = p->p_limit; - mutex_enter(&lim->pl_lock); - cn = lim->pl_corename; - lim->pl_corename = defcorename; - mutex_exit(&lim->pl_lock); - if (cn != defcorename) - free(cn, M_TEMP); + lim_setcorename(p, defcorename, 0); } mutex_enter(p->p_lock); Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.159 src/sys/kern/kern_resource.c:1.160 --- src/sys/kern/kern_resource.c:1.159 Sun May 1 00:11:52 2011 +++ src/sys/kern/kern_resource.c Sun May 1 00:22:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $ */ +/* $NetBSD: kern_resource.c,v 1.160 2011/05/01 00:22:36 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.160 2011/05/01 00:22:36 rmind Exp $"); #include #include @@ -699,6 +699,25 @@ } void +lim_setcorename(proc_t *p, char *name, size_t len) +{ + struct plimit *lim; + char *oname; + + lim_privatise(p, false); + lim = p->p_limit; + + mutex_enter(&lim->pl_lock); + oname = lim->pl_corename; + lim->pl_corename = name; + mutex_exit(&lim->pl_lock); + + if (oname != defcorename) { + free(oname, M_TEMP); + } +} + +void lim_free(struct plimit *lim) { struct plimit *sv_lim; @@ -858,17 +877,7 @@ goto done; } memcpy(cname, cnbuf, len); - - char *ocname; - lim_privatise(p, false); - lim = p->p_limit; - mutex_enter(&lim->pl_lock); - ocname = lim->pl_corename; - lim->pl_corename = cname; - mutex_exit(&lim->pl_lock); - if (ocname != defcorename) - free(ocname, M_TEMP); - + lim_setcorename(p, cname, len); done: rw_exit(&p->p_reflock); PNBUF_PUT(cnbuf); Index: src/sys/sys/resourcevar.h diff -u src/sys/sys/resourcevar.h:1.49 src/sys/sys/resourcevar.h:1.50 --- src/sys/sys/resourcevar.h:1.49 Sun May 1 00:11:52 2011 +++ src/sys/sys/resourcevar.h Sun May 1 00:22:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: resourcevar.h,v 1.49 2011/05/01 00:11:52 rmind Exp $ */ +/* $NetBSD: resourcevar.h,v 1.50 2011/05/01 00:22:36 rmind Exp $ */ /* * Copyright (c) 1991, 1993 @@ -110,6 +110,7 @@ struct plimit *lim_copy(struct plimit *lim); void lim_addref(struct plimit *lim); void lim_privatise(struct proc *p, bool set_shared); +void lim_setcorename(struct proc *, char *, size_t); void lim_free(struct plimit *); void resource_init(void);
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun May 1 00:11:52 UTC 2011 Modified Files: src/sys/kern: kern_exit.c kern_proc.c kern_resource.c src/sys/sys: resourcevar.h Log Message: Rename limfree() to lim_free(), misc clean up. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.232 -r1.233 src/sys/kern/kern_exit.c cvs rdiff -u -r1.176 -r1.177 src/sys/kern/kern_proc.c cvs rdiff -u -r1.158 -r1.159 src/sys/kern/kern_resource.c cvs rdiff -u -r1.48 -r1.49 src/sys/sys/resourcevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_exit.c diff -u src/sys/kern/kern_exit.c:1.232 src/sys/kern/kern_exit.c:1.233 --- src/sys/kern/kern_exit.c:1.232 Mon Feb 21 20:23:28 2011 +++ src/sys/kern/kern_exit.c Sun May 1 00:11:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.232 2011/02/21 20:23:28 pooka Exp $ */ +/* $NetBSD: kern_exit.c,v 1.233 2011/05/01 00:11:52 rmind Exp $ */ /*- * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.232 2011/02/21 20:23:28 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.233 2011/05/01 00:11:52 rmind Exp $"); #include "opt_ktrace.h" #include "opt_perfctrs.h" @@ -970,7 +970,7 @@ * Release substructures. */ - limfree(p->p_limit); + lim_free(p->p_limit); pstatsfree(p->p_stats); kauth_cred_free(cred1); kauth_cred_free(cred2); Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.176 src/sys/kern/kern_proc.c:1.177 --- src/sys/kern/kern_proc.c:1.176 Wed Apr 27 00:36:47 2011 +++ src/sys/kern/kern_proc.c Sun May 1 00:11:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.176 2011/04/27 00:36:47 rmind Exp $ */ +/* $NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.176 2011/04/27 00:36:47 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -399,6 +399,7 @@ { struct proc *p; struct pgrp *pg; + struct rlimit *rlim; rlim_t lim; int i; @@ -434,24 +435,26 @@ /* Create the limits structures. */ mutex_init(&limit0.pl_lock, MUTEX_DEFAULT, IPL_NONE); - for (i = 0; i < __arraycount(limit0.pl_rlimit); i++) - limit0.pl_rlimit[i].rlim_cur = - limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY; - - limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = maxfiles; - limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = - maxfiles < nofile ? maxfiles : nofile; - - limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc; - limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = - maxproc < maxuprc ? maxproc : maxuprc; + + rlim = limit0.pl_rlimit; + for (i = 0; i < __arraycount(limit0.pl_rlimit); i++) { + rlim[i].rlim_cur = RLIM_INFINITY; + rlim[i].rlim_max = RLIM_INFINITY; + } + + rlim[RLIMIT_NOFILE].rlim_max = maxfiles; + rlim[RLIMIT_NOFILE].rlim_cur = maxfiles < nofile ? maxfiles : nofile; + + rlim[RLIMIT_NPROC].rlim_max = maxproc; + rlim[RLIMIT_NPROC].rlim_cur = maxproc < maxuprc ? maxproc : maxuprc; lim = MIN(VM_MAXUSER_ADDRESS, ctob((rlim_t)uvmexp.free)); - limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim; - limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim; - limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3; - limit0.pl_corename = defcorename; - limit0.pl_refcnt = 1; + rlim[RLIMIT_RSS].rlim_max = lim; + rlim[RLIMIT_MEMLOCK].rlim_max = lim; + rlim[RLIMIT_MEMLOCK].rlim_cur = lim / 3; + + limit0.pl_corename = defcorename; + limit0.pl_refcnt = 1; limit0.pl_sv_limit = NULL; /* Configure virtual memory system, set vm rlimits. */ @@ -1358,7 +1361,6 @@ l->l_cred = p->p_cred; kauth_cred_free(oc); } - } /* Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.158 src/sys/kern/kern_resource.c:1.159 --- src/sys/kern/kern_resource.c:1.158 Sat Apr 30 23:41:17 2011 +++ src/sys/kern/kern_resource.c Sun May 1 00:11:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.158 2011/04/30 23:41:17 rmind Exp $ */ +/* $NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.158 2011/04/30 23:41:17 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $"); #include #include @@ -680,7 +680,7 @@ if (p->p_limit->pl_flags & PL_WRITEABLE) { /* Someone crept in while we were busy */ mutex_exit(p->p_lock); - limfree(newlim); + lim_free(newlim); if (set_shared) p->p_limit->pl_flags |= PL_SHAREMOD; return; @@ -699,15 +699,17 @@ } void -limfree(struct plimit *lim) +lim_free(struct plimit *lim) { struct plimit *sv_lim; d
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat Apr 30 23:41:17 UTC 2011 Modified Files: src/sys/kern: kern_resource.c Log Message: sysctl_proc_corename: improve comments, clean up, move a check for KAUTH_REQ_PROCESS_CORENAME_SET earlier, do not bother to strcmp(). To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 src/sys/kern/kern_resource.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.157 src/sys/kern/kern_resource.c:1.158 --- src/sys/kern/kern_resource.c:1.157 Thu Jul 1 02:38:30 2010 +++ src/sys/kern/kern_resource.c Sat Apr 30 23:41:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.157 2010/07/01 02:38:30 rmind Exp $ */ +/* $NetBSD: kern_resource.c,v 1.158 2011/04/30 23:41:17 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.157 2010/07/01 02:38:30 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.158 2011/04/30 23:41:17 rmind Exp $"); #include #include @@ -775,121 +775,101 @@ } /* - * sysctl helper routine for setting a process's specific corefile - * name. picks the process based on the given pid and checks the - * correctness of the new value. + * sysctl_proc_corename: helper routine to get or set the core file name + * for a process specified by PID. */ static int sysctl_proc_corename(SYSCTLFN_ARGS) { - struct proc *ptmp; + struct proc *p; struct plimit *lim; - char *cname, *ocore, *tmp; + char *cnbuf, *cname; struct sysctlnode node; - int error = 0, len; + size_t len; + int error; - /* - * is this all correct? - */ - if (namelen != 0) - return (EINVAL); - if (name[-1] != PROC_PID_CORENAME) - return (EINVAL); + /* First, validate the request. */ + if (namelen != 0 || name[-1] != PROC_PID_CORENAME) + return EINVAL; /* Find the process. Hold a reference (p_reflock), if found. */ - error = sysctl_proc_findproc(l, (pid_t)name[-2], &ptmp); + error = sysctl_proc_findproc(l, (pid_t)name[-2], &p); if (error) return error; /* XXX-elad */ - error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, ptmp, + error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, p, KAUTH_ARG(KAUTH_REQ_PROCESS_CANSEE_ENTRY), NULL, NULL); if (error) { - rw_exit(&ptmp->p_reflock); + rw_exit(&p->p_reflock); return error; } + cnbuf = PNBUF_GET(); + if (newp == NULL) { + /* Get case: copy the core name into the buffer. */ error = kauth_authorize_process(l->l_cred, - KAUTH_PROCESS_CORENAME, ptmp, + KAUTH_PROCESS_CORENAME, p, KAUTH_ARG(KAUTH_REQ_PROCESS_CORENAME_GET), NULL, NULL); if (error) { - rw_exit(&ptmp->p_reflock); - return error; + goto done; + } + lim = p->p_limit; + mutex_enter(&lim->pl_lock); + strlcpy(cnbuf, lim->pl_corename, MAXPATHLEN); + mutex_exit(&lim->pl_lock); + } else { + /* Set case: just use the temporary buffer. */ + error = kauth_authorize_process(l->l_cred, + KAUTH_PROCESS_CORENAME, p, + KAUTH_ARG(KAUTH_REQ_PROCESS_CORENAME_SET), cnbuf, NULL); + if (error) { + goto done; } } - /* - * let them modify a temporary copy of the core name - */ - cname = PNBUF_GET(); - lim = ptmp->p_limit; - mutex_enter(&lim->pl_lock); - strlcpy(cname, lim->pl_corename, MAXPATHLEN); - mutex_exit(&lim->pl_lock); - node = *rnode; - node.sysctl_data = cname; + node.sysctl_data = cnbuf; error = sysctl_lookup(SYSCTLFN_CALL(&node)); - /* - * if that failed, or they have nothing new to say, or we've - * heard it before... - */ - if (error || newp == NULL) - goto done; - lim = ptmp->p_limit; - mutex_enter(&lim->pl_lock); - error = strcmp(cname, lim->pl_corename); - mutex_exit(&lim->pl_lock); - if (error == 0) { - /* Unchanged */ + /* Return if error, or if we are only retrieving the core name. */ + if (error || newp == NULL) { goto done; } - error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CORENAME, - ptmp, KAUTH_ARG(KAUTH_REQ_PROCESS_CORENAME_SET), cname, NULL); - if (error) - goto done; /* - * no error yet and cname now has the new core name in it. - * let's see if it looks acceptable. it must be either "core" - * or end in ".core" or "/core". + * Validate new core name. It must be either "core", "/core", + * or end in ".core". */ - len = strlen(cname); - if (len < 4) { - error = EINVAL; - } else if (strcmp(cname + len - 4, "core") != 0) { + len = strlen(cnbuf); + if ((len < 4 || strcmp(cnbuf + len - 4, "core") != 0) || + (len > 4 && cnbuf[len - 5] != '/' && cnbuf[len - 5] != '.')) { error = EINVAL; - } else if (len > 4 && cname[len - 5] != '/' && cname[len - 5] != '.') { - error = EINVAL; - } - if (error != 0) { goto done; } - /* - * hmm...looks good. now...where do we put it? - */ - tmp = malloc(len + 1, M_TEMP, M_WAITOK|M_CANFAIL)
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Fri Apr 29 22:57:54 UTC 2011 Modified Files: src/sys/kern: kern_core.c Log Message: Small comment improvement. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/kern/kern_core.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_core.c diff -u src/sys/kern/kern_core.c:1.17 src/sys/kern/kern_core.c:1.18 --- src/sys/kern/kern_core.c:1.17 Fri Nov 19 06:44:42 2010 +++ src/sys/kern/kern_core.c Fri Apr 29 22:57:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_core.c,v 1.17 2010/11/19 06:44:42 dholland Exp $ */ +/* $NetBSD: kern_core.c,v 1.18 2011/04/29 22:57:54 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.17 2010/11/19 06:44:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.18 2011/04/29 22:57:54 rmind Exp $"); #include #include @@ -164,17 +164,20 @@ pattern = security_setidcore_path; } - /* It is (just) possible for p_limit and pl_corename to change */ + /* Lock, as p_limit and pl_corename might change. */ lim = p->p_limit; mutex_enter(&lim->pl_lock); - if (pattern == NULL) + if (pattern == NULL) { pattern = lim->pl_corename; + } error = coredump_buildname(p, name, pattern, MAXPATHLEN); mutex_exit(&lim->pl_lock); + mutex_exit(p->p_lock); mutex_exit(proc_lock); - if (error) + if (error) { goto done; + } pb = pathbuf_create(name); if (pb == NULL) {
CVS commit: src/doc
Module Name:src Committed By: rmind Date: Fri Apr 29 20:33:43 UTC 2011 Modified Files: src/doc: CHANGES Log Message: Mention PowerPC BookE support and addition of PCU. To generate a diff of this commit: cvs rdiff -u -r1.1542 -r1.1543 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1542 src/doc/CHANGES:1.1543 --- src/doc/CHANGES:1.1542 Fri Apr 29 01:53:36 2011 +++ src/doc/CHANGES Fri Apr 29 20:33:42 2011 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1542 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1543 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -887,6 +887,10 @@ rump(3): Rework rump syscall compat. The interface provided by a newer NetBSD version is now always compatible with a client compiled on an older version. [pooka 20110117] + powerpc: Added support for Book E Freescale MPC85xx (e500 core) + processors. Added "fast" software interrupts support and + SOFTFLOAT for PowerPC (Book E only), reworked FPU/VEC support + for e500 SPE, other improvements. [matt 20110118] atactl(8): Fix mislabelled S.M.A.R.T. lifetime temperature record reading. [nisimura 20110119] rump.dhcpclient(1): Add a very simple DHCP client for rump kernels. @@ -925,6 +929,8 @@ hp700: Add support for HIL devices. From OpenBSD. [tsutsui 20110215] bind: Update to 9.8.0rc1: Response policy zones (RPZ) and DNS64 support. [christos 20110215] + kernel: Add PCU (Per-CPU Unit) interface to unify synchronization of + per CPU context, like lazy FPU management. [rmind 20110217] acpi(4): Updated ACPICA to 20110211. [jruoho 20110217] rumphijack(3): Support hijacking of pathname-based system calls. [pooka 20110217] @@ -937,6 +943,7 @@ more efficient, added "fast" software interrupts and kernel preemption. Added support for RMI (NetLogic) XLS/XLR models. Major clean up for MIPS port. [matt 20110220] + mips: Converted MIPS to use PCU. [matt 20110220] ath(4): Add support for AR9285 devices. [cegger 20110221] libsaslc(3): Complete integration of libsaslc written for GSoC 2010 by Mateusz Kocielski, improved and integrated with Postfix
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Wed Apr 27 00:38:37 UTC 2011 Modified Files: src/sys/kern: kern_sig.c src/sys/sys: signalvar.h Log Message: Make stopsigmask static, sprinkle __cacheline_aligned and __read_mostly. To generate a diff of this commit: cvs rdiff -u -r1.307 -r1.308 src/sys/kern/kern_sig.c cvs rdiff -u -r1.78 -r1.79 src/sys/sys/signalvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.307 src/sys/kern/kern_sig.c:1.308 --- src/sys/kern/kern_sig.c:1.307 Mon Jan 17 07:13:31 2011 +++ src/sys/kern/kern_sig.c Wed Apr 27 00:38:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.307 2011/01/17 07:13:31 uebayasi Exp $ */ +/* $NetBSD: kern_sig.c,v 1.308 2011/04/27 00:38:37 rmind Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -65,8 +65,12 @@ * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95 */ +/* + * Signal subsystem. + */ + #include -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.307 2011/01/17 07:13:31 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.308 2011/04/27 00:38:37 rmind Exp $"); #include "opt_ptrace.h" #include "opt_compat_sunos.h" @@ -105,6 +109,18 @@ #include #include +static pool_cache_t sigacts_cache __read_mostly; +static pool_cache_t ksiginfo_cache __read_mostly; +static callout_t proc_stop_ch __cacheline_aligned; + +#ifdef KERN_SA +static pool_cache_t siginfo_cache; +#endif + +sigset_t contsigmask __cacheline_aligned; +static sigset_t stopsigmask __cacheline_aligned; +sigset_t sigcantmask __cacheline_aligned; + static void ksiginfo_exechook(struct proc *, void *); static void proc_stop_callout(void *); static int sigchecktrace(void); @@ -113,13 +129,8 @@ static int sigunwait(struct proc *, const ksiginfo_t *); static void sigswitch(bool, int, int); -sigset_t contsigmask, stopsigmask, sigcantmask; -static pool_cache_t sigacts_cache; /* memory pool for sigacts structures */ static void sigacts_poolpage_free(struct pool *, void *); static void *sigacts_poolpage_alloc(struct pool *, int); -static callout_t proc_stop_ch; -static pool_cache_t siginfo_cache; -static pool_cache_t ksiginfo_cache; void (*sendsig_sigcontext_vec)(const struct ksiginfo *, const sigset_t *); int (*coredump_vec)(struct lwp *, const char *) = @@ -202,10 +213,10 @@ sigacts_cache = pool_cache_init(sizeof(struct sigacts), 0, 0, 0, "sigacts", sizeof(struct sigacts) > PAGE_SIZE ? &sigactspool_allocator : NULL, IPL_NONE, NULL, NULL, NULL); - +#ifdef KERN_SA siginfo_cache = pool_cache_init(sizeof(siginfo_t), 0, 0, 0, "siginfo", NULL, IPL_NONE, NULL, NULL, NULL); - +#endif ksiginfo_cache = pool_cache_init(sizeof(ksiginfo_t), 0, 0, 0, "ksiginfo", NULL, IPL_VM, NULL, NULL, NULL); Index: src/sys/sys/signalvar.h diff -u src/sys/sys/signalvar.h:1.78 src/sys/sys/signalvar.h:1.79 --- src/sys/sys/signalvar.h:1.78 Fri Jan 14 02:06:34 2011 +++ src/sys/sys/signalvar.h Wed Apr 27 00:38:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: signalvar.h,v 1.78 2011/01/14 02:06:34 rmind Exp $ */ +/* $NetBSD: signalvar.h,v 1.79 2011/04/27 00:38:37 rmind Exp $ */ /* * Copyright (c) 1991, 1993 @@ -120,7 +120,7 @@ #include /* for copyin_t/copyout_t */ -extern sigset_t contsigmask, stopsigmask, sigcantmask; +extern sigset_t contsigmask, sigcantmask; struct vnode;
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Wed Apr 27 00:36:48 UTC 2011 Modified Files: src/sys/kern: kern_pmf.c kern_proc.c src/sys/netbt: bluetooth.h src/sys/sys: proc.h Log Message: G/C M_EMULDATA To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/kern/kern_pmf.c cvs rdiff -u -r1.175 -r1.176 src/sys/kern/kern_proc.c cvs rdiff -u -r1.10 -r1.11 src/sys/netbt/bluetooth.h cvs rdiff -u -r1.304 -r1.305 src/sys/sys/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_pmf.c diff -u src/sys/kern/kern_pmf.c:1.33 src/sys/kern/kern_pmf.c:1.34 --- src/sys/kern/kern_pmf.c:1.33 Wed Feb 24 22:38:09 2010 +++ src/sys/kern/kern_pmf.c Wed Apr 27 00:36:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_pmf.c,v 1.33 2010/02/24 22:38:09 dyoung Exp $ */ +/* $NetBSD: kern_pmf.c,v 1.34 2011/04/27 00:36:47 rmind Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.33 2010/02/24 22:38:09 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.34 2011/04/27 00:36:47 rmind Exp $"); #include #include @@ -82,6 +82,7 @@ /* #define PMF_DEBUG */ +#include MALLOC_DEFINE(M_PMF, "pmf", "device pmf messaging memory"); static prop_dictionary_t pmf_platform = NULL; Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.175 src/sys/kern/kern_proc.c:1.176 --- src/sys/kern/kern_proc.c:1.175 Mon Apr 18 00:26:11 2011 +++ src/sys/kern/kern_proc.c Wed Apr 27 00:36:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.175 2011/04/18 00:26:11 rmind Exp $ */ +/* $NetBSD: kern_proc.c,v 1.176 2011/04/27 00:36:47 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.175 2011/04/18 00:26:11 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.176 2011/04/27 00:36:47 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -204,8 +204,6 @@ int maxuprc = MAXUPRC; int cmask = CMASK; -MALLOC_DEFINE(M_EMULDATA, "emuldata", "Per-process emulation data"); - static int sysctl_doeproc(SYSCTLFN_PROTO); static int sysctl_kern_proc_args(SYSCTLFN_PROTO); static void fill_kproc2(struct proc *, struct kinfo_proc2 *, bool); Index: src/sys/netbt/bluetooth.h diff -u src/sys/netbt/bluetooth.h:1.10 src/sys/netbt/bluetooth.h:1.11 --- src/sys/netbt/bluetooth.h:1.10 Wed Mar 16 21:35:30 2011 +++ src/sys/netbt/bluetooth.h Wed Apr 27 00:36:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bluetooth.h,v 1.10 2011/03/16 21:35:30 plunky Exp $ */ +/* $NetBSD: bluetooth.h,v 1.11 2011/04/27 00:36:48 rmind Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. @@ -103,6 +103,7 @@ #ifdef _KERNEL +#include MALLOC_DECLARE(M_BLUETOOTH); /* Index: src/sys/sys/proc.h diff -u src/sys/sys/proc.h:1.304 src/sys/sys/proc.h:1.305 --- src/sys/sys/proc.h:1.304 Mon Apr 18 00:26:11 2011 +++ src/sys/sys/proc.h Wed Apr 27 00:36:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.304 2011/04/18 00:26:11 rmind Exp $ */ +/* $NetBSD: proc.h,v 1.305 2011/04/27 00:36:48 rmind Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -411,8 +411,6 @@ }; #ifdef _KERNEL -#include -MALLOC_DECLARE(M_EMULDATA); /* * We use process IDs <= PID_MAX until there are > 16k processes.
CVS commit: src
Module Name:src Committed By: rmind Date: Wed Apr 27 00:35:53 UTC 2011 Modified Files: src/share/man/man9: uvm.9 src/sys/uvm: uvm_swap.c uvm_swap.h uvm_swapstub.c Log Message: Remove public uvm_swap_stats() routine, keep it internal. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/share/man/man9/uvm.9 cvs rdiff -u -r1.154 -r1.155 src/sys/uvm/uvm_swap.c cvs rdiff -u -r1.17 -r1.18 src/sys/uvm/uvm_swap.h cvs rdiff -u -r1.6 -r1.7 src/sys/uvm/uvm_swapstub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/uvm.9 diff -u src/share/man/man9/uvm.9:1.103 src/share/man/man9/uvm.9:1.104 --- src/share/man/man9/uvm.9:1.103 Mon Nov 8 02:56:12 2010 +++ src/share/man/man9/uvm.9 Wed Apr 27 00:35:53 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: uvm.9,v 1.103 2010/11/08 02:56:12 dholland Exp $ +.\" $NetBSD: uvm.9,v 1.104 2011/04/27 00:35:53 rmind Exp $ .\" .\" Copyright (c) 1998 Matthew R. Green .\" All rights reserved. @@ -772,8 +772,6 @@ .Fn uvn_findpages "struct uvm_object *uobj" "voff_t offset" "int *npagesp" "struct vm_page **pps" "int flags" ; .It Ft void .Fn uvm_vnp_setsize "struct vnode *vp" "voff_t newsize" ; -.It Ft void -.Fn uvm_swap_stats "int cmd" "struct swapent *sep" "int sec" "register_t *retval" ; .El .Pp The @@ -894,26 +892,6 @@ Caller must hold a reference to the vnode. If the vnode shrinks, pages no longer used are discarded. .Pp -.Fn uvm_swap_stats -implements the -.Dv SWAP_STATS -and -.Dv SWAP_OSTATS -operation of the -.Xr swapctl 2 -system call. -.Fa cmd -is the requested command, -.Dv SWAP_STATS -or -.Dv SWAP_OSTATS . -The function will copy no more than -.Fa sec -entries in the array pointed by -.Fa sep . -On return, -.Fa retval -holds the actual number of entries copied in the array. .Sh SYSCTL UVM provides support for the .Dv CTL_VM Index: src/sys/uvm/uvm_swap.c diff -u src/sys/uvm/uvm_swap.c:1.154 src/sys/uvm/uvm_swap.c:1.155 --- src/sys/uvm/uvm_swap.c:1.154 Sat Apr 23 18:14:13 2011 +++ src/sys/uvm/uvm_swap.c Wed Apr 27 00:35:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_swap.c,v 1.154 2011/04/23 18:14:13 rmind Exp $ */ +/* $NetBSD: uvm_swap.c,v 1.155 2011/04/27 00:35:52 rmind Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.154 2011/04/23 18:14:13 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.155 2011/04/27 00:35:52 rmind Exp $"); #include "opt_uvmhist.h" #include "opt_compat_netbsd.h" @@ -107,7 +107,7 @@ * [2] SWAP_STATS: given a pointer to an array of swapent structures * (passed in via "arg") of a size passed in via "misc" ... we load * the current swap config into the array. The actual work is done - * in the uvm_swap_stats(9) function. + * in the uvm_swap_stats() function. * [3] SWAP_ON: given a pathname in arg (could be device or file) and a * priority in "misc", start swapping on it. * [4] SWAP_OFF: as SWAP_ON, but stops swapping to a device @@ -238,7 +238,7 @@ static int swap_on(struct lwp *, struct swapdev *); static int swap_off(struct lwp *, struct swapdev *); -static void uvm_swap_stats_locked(int, struct swapent *, int, register_t *); +static void uvm_swap_stats(int, struct swapent *, int, register_t *); static void sw_reg_strategy(struct swapdev *, struct buf *, int); static void sw_reg_biodone(struct buf *); @@ -513,7 +513,7 @@ len = sizeof(struct swapent) * misc; sep = (struct swapent *)malloc(len, M_TEMP, M_WAITOK); - uvm_swap_stats_locked(SCARG(uap, cmd), sep, misc, retval); + uvm_swap_stats(SCARG(uap, cmd), sep, misc, retval); error = copyout(sep, SCARG(uap, arg), len); free(sep, M_TEMP); @@ -723,7 +723,7 @@ } /* - * swap_stats: implements swapctl(SWAP_STATS). The function is kept + * uvm_swap_stats: implements swapctl(SWAP_STATS). The function is kept * away from sys_swapctl() in order to allow COMPAT_* swapctl() * emulation to use it directly without going through sys_swapctl(). * The problem with using sys_swapctl() there is that it involves @@ -731,17 +731,8 @@ * is not known at build time. Hence it would not be possible to * ensure it would fit in the stackgap in any case. */ -void -uvm_swap_stats(int cmd, struct swapent *sep, int sec, register_t *retval) -{ - - rw_enter(&swap_syscall_lock, RW_READER); - uvm_swap_stats_locked(cmd, sep, sec, retval); - rw_exit(&swap_syscall_lock); -} - static void -uvm_swap_stats_locked(int cmd, struct swapent *sep, int sec, register_t *retval) +uvm_swap_stats(int cmd, struct swapent *sep, int sec, register_t *retval) { struct swappri *spp; struct swapdev *sdp; Index: src/sys/uvm/uvm_swap.h diff -u src/sys/uvm/uvm_swap.h:1.17 src/sys/uvm/uvm_swap.h:1.18 --- src/sys/uvm/uvm_swap.h:1.17 Thu May 29 14:51:27 2008 +++ src/sys/uvm/uvm_swap.h Wed Apr 27 00:35:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_swap.
CVS commit: src/sys/sys
Module Name:src Committed By: rmind Date: Sun Apr 24 21:50:34 UTC 2011 Modified Files: src/sys/sys: param.h Log Message: Bump to 5.99.50 for recent changes. To generate a diff of this commit: cvs rdiff -u -r1.386 -r1.387 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.386 src/sys/sys/param.h:1.387 --- src/sys/sys/param.h:1.386 Mon Apr 11 01:33:46 2011 +++ src/sys/sys/param.h Sun Apr 24 21:50:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.386 2011/04/11 01:33:46 dholland Exp $ */ +/* $NetBSD: param.h,v 1.387 2011/04/24 21:50:34 rmind Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -63,7 +63,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 599004900 /* NetBSD 5.99.49 */ +#define __NetBSD_Version__ 599005000 /* NetBSD 5.99.50 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun Apr 24 21:35:30 UTC 2011 Modified Files: src/sys/fs/nilfs: nilfs_vnops.c src/sys/fs/tmpfs: tmpfs_vnops.c src/sys/fs/udf: udf_vnops.c src/sys/kern: vfs_syscalls.c src/sys/nfs: nfs_vnops.c src/sys/ufs/ext2fs: ext2fs_vnops.c src/sys/ufs/ufs: ufs_vnops.c Log Message: sys_link: prevent hard links on directories (cross-mount operations are already prevented). File systems are no longer responsible to check this. Clean up and add asserts (note that dvp == vp cannot happen in vop_link). OK dholland@ To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/fs/nilfs/nilfs_vnops.c cvs rdiff -u -r1.76 -r1.77 src/sys/fs/tmpfs/tmpfs_vnops.c cvs rdiff -u -r1.62 -r1.63 src/sys/fs/udf/udf_vnops.c cvs rdiff -u -r1.422 -r1.423 src/sys/kern/vfs_syscalls.c cvs rdiff -u -r1.289 -r1.290 src/sys/nfs/nfs_vnops.c cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ext2fs/ext2fs_vnops.c cvs rdiff -u -r1.187 -r1.188 src/sys/ufs/ufs/ufs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/nilfs/nilfs_vnops.c diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.9 src/sys/fs/nilfs/nilfs_vnops.c:1.10 --- src/sys/fs/nilfs/nilfs_vnops.c:1.9 Tue Nov 30 10:43:03 2010 +++ src/sys/fs/nilfs/nilfs_vnops.c Sun Apr 24 21:35:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nilfs_vnops.c,v 1.9 2010/11/30 10:43:03 dholland Exp $ */ +/* $NetBSD: nilfs_vnops.c,v 1.10 2011/04/24 21:35:29 rmind Exp $ */ /* * Copyright (c) 2008, 2009 Reinoud Zandijk @@ -28,7 +28,7 @@ #include #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.9 2010/11/30 10:43:03 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.10 2011/04/24 21:35:29 rmind Exp $"); #endif /* not lint */ @@ -1159,15 +1159,9 @@ int error; DPRINTF(VFSCALL, ("nilfs_link called\n")); - error = 0; - - /* some quick checks */ - if (vp->v_type == VDIR) - return EPERM; /* can't link a directory */ - if (dvp->v_mount != vp->v_mount) - return EXDEV; /* can't link across devices */ - if (dvp == vp) - return EPERM; /* can't be the same */ + KASSERT(dvp != vp); + KASSERT(vp->v_type != VDIR); + KASSERT(dvp->v_mount == vp->v_mount); /* lock node */ error = vn_lock(vp, LK_EXCLUSIVE); Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.76 src/sys/fs/tmpfs/tmpfs_vnops.c:1.77 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.76 Thu Jan 13 13:35:12 2011 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sun Apr 24 21:35:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.76 2011/01/13 13:35:12 pooka Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.77 2011/04/24 21:35:29 rmind Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.76 2011/01/13 13:35:12 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.77 2011/04/24 21:35:29 rmind Exp $"); #include #include @@ -737,44 +737,34 @@ return error; } -/* - */ - +/* + * tmpfs:link: create hard link. + */ int tmpfs_link(void *v) { - struct vnode *dvp = ((struct vop_link_args *)v)->a_dvp; - struct vnode *vp = ((struct vop_link_args *)v)->a_vp; - struct componentname *cnp = ((struct vop_link_args *)v)->a_cnp; - - int error; + struct vop_link_args /* { + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; + } */ *ap = v; + struct vnode *dvp = ap->a_dvp; + struct vnode *vp = ap->a_vp; + struct componentname *cnp = ap->a_cnp;; + struct tmpfs_node *dnode, *node; struct tmpfs_dirent *de; - struct tmpfs_node *dnode; - struct tmpfs_node *node; + int error; + KASSERT(dvp != vp); KASSERT(VOP_ISLOCKED(dvp)); - KASSERT(dvp != vp); /* XXX When can this be false? */ + KASSERT(vp->v_type != VDIR); + KASSERT(dvp->v_mount == vp->v_mount); dnode = VP_TO_TMPFS_DIR(dvp); node = VP_TO_TMPFS_NODE(vp); - /* Lock vp because we will need to run tmpfs_update over it, which - * needs the vnode to be locked. */ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - /* XXX: Why aren't the following two tests done by the caller? */ - - /* Hard links of directories are forbidden. */ - if (vp->v_type == VDIR) { - error = EPERM; - goto out; - } - - /* Cannot create cross-device links. */ - if (dvp->v_mount != vp->v_mount) { - error = EXDEV; - goto out; - } - /* Ensure that we do not overflow the maximum number of links imposed * by the system. */ KASSERT(node->tn_links <= LINK_MAX); Index: src/sys/fs/udf/udf_vnops.c diff -u src/sys/fs/udf/udf_vnops.c:1.62 src/sys/fs/udf/udf_vnops.c:1.63 --- src/sys/fs/udf/udf_vnops.c:1.62 Sun Jan 2 05:09:30 2011 +++ src/sys/fs/udf/udf_vnops.c Sun Apr 24 21:35:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vnops.c,v 1.62 2011/01/02 05:09:30 dholland Exp $ */ +/* $NetBSD: udf_vnops.c,v 1.63 2011/04/24 21:3
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sun Apr 24 20:30:38 UTC 2011 Modified Files: src/sys/kern: kern_descrip.c Log Message: Drop extern inline for fd_getfile(). Apparently, GCC already ignores it. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/sys/kern/kern_descrip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_descrip.c diff -u src/sys/kern/kern_descrip.c:1.213 src/sys/kern/kern_descrip.c:1.214 --- src/sys/kern/kern_descrip.c:1.213 Sat Apr 23 18:57:27 2011 +++ src/sys/kern/kern_descrip.c Sun Apr 24 20:30:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_descrip.c,v 1.213 2011/04/23 18:57:27 rmind Exp $ */ +/* $NetBSD: kern_descrip.c,v 1.214 2011/04/24 20:30:38 rmind Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.213 2011/04/23 18:57:27 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.214 2011/04/24 20:30:38 rmind Exp $"); #include #include @@ -350,7 +350,7 @@ * Look up the file structure corresponding to a file descriptor * and return the file, holding a reference on the descriptor. */ -inline file_t * +file_t * fd_getfile(unsigned fd) { filedesc_t *fdp;
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun Apr 24 20:17:53 UTC 2011 Modified Files: src/sys/kern: kern_fork.c sys_mqueue.c src/sys/sys: mqueue.h Log Message: - Move some checks into mqueue_get() and avoid some duplication. - Simplify message queue descriptor unlinking and closure operations. - Update proc_t::p_mqueue_cnt atomically. Inherit it on fork(). - Use separate allocation for the name of message queue. To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/sys/kern/kern_fork.c cvs rdiff -u -r1.31 -r1.32 src/sys/kern/sys_mqueue.c cvs rdiff -u -r1.12 -r1.13 src/sys/sys/mqueue.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_fork.c diff -u src/sys/kern/kern_fork.c:1.180 src/sys/kern/kern_fork.c:1.181 --- src/sys/kern/kern_fork.c:1.180 Wed Mar 23 13:57:40 2011 +++ src/sys/kern/kern_fork.c Sun Apr 24 20:17:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.180 2011/03/23 13:57:40 joerg Exp $ */ +/* $NetBSD: kern_fork.c,v 1.181 2011/04/24 20:17:53 rmind Exp $ */ /*- * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.180 2011/03/23 13:57:40 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.181 2011/04/24 20:17:53 rmind Exp $"); #include "opt_ktrace.h" @@ -349,6 +349,9 @@ else p2->p_fd = fd_copy(); + /* XXX racy */ + p2->p_mqueue_cnt = p1->p_mqueue_cnt; + if (flags & FORK_SHARECWD) cwdshare(p2); else Index: src/sys/kern/sys_mqueue.c diff -u src/sys/kern/sys_mqueue.c:1.31 src/sys/kern/sys_mqueue.c:1.32 --- src/sys/kern/sys_mqueue.c:1.31 Tue Jan 18 20:32:53 2011 +++ src/sys/kern/sys_mqueue.c Sun Apr 24 20:17:53 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: sys_mqueue.c,v 1.31 2011/01/18 20:32:53 rmind Exp $ */ +/* $NetBSD: sys_mqueue.c,v 1.32 2011/04/24 20:17:53 rmind Exp $ */ /* - * Copyright (c) 2007-2009 Mindaugas Rasiukevicius + * Copyright (c) 2007-2011 Mindaugas Rasiukevicius * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,37 +31,30 @@ * Defined in the Base Definitions volume of IEEE Std 1003.1-2001. * * Locking - * - * Global list of message queues (mqueue_head) and proc_t::p_mqueue_cnt - * counter are protected by mqlist_mtx lock. The very message queue and - * its members are protected by mqueue::mq_mtx. - * + * + * Global list of message queues (mqueue_head) is protected by mqlist_lock. + * Each message queue and its members are protected by mqueue::mq_mtx. + * Note that proc_t::p_mqueue_cnt is updated atomically. + * * Lock order: - * mqlist_mtx -> - * mqueue::mq_mtx + * + * mqlist_lock -> + * mqueue::mq_mtx */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.31 2011/01/18 20:32:53 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.32 2011/04/24 20:17:53 rmind Exp $"); #include #include -#include -#include -#include + #include #include #include -#include -#include #include #include #include -#include -#include #include -#include -#include #include #include #include @@ -70,8 +63,6 @@ #include #include #include -#include -#include #include @@ -84,10 +75,10 @@ static u_int mq_def_maxmsg = 32; static u_int mq_max_maxmsg = 16 * 32; -static kmutex_t mqlist_mtx; -static pool_cache_t mqmsg_cache; -static LIST_HEAD(, mqueue) mqueue_head; -static struct sysctllog *mqsysctl_log; +static pool_cache_t mqmsg_cache __read_mostly; +static kmutex_t mqlist_lock __cacheline_aligned; +static LIST_HEAD(, mqueue) mqueue_head __cacheline_aligned; +static struct sysctllog * mqsysctl_log; static int mqueue_sysinit(void); static int mqueue_sysfini(bool); @@ -133,7 +124,7 @@ mqmsg_cache = pool_cache_init(MQ_DEF_MSGSIZE, coherency_unit, 0, 0, "mqmsgpl", NULL, IPL_NONE, NULL, NULL, NULL); - mutex_init(&mqlist_mtx, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&mqlist_lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&mqueue_head); error = mqueue_sysctl_init(); @@ -160,13 +151,10 @@ error = syscall_disestablish(NULL, mqueue_syscalls); if (error) return error; - /* - * Check if there are any message queues in use. - * TODO: We shall support forced unload. - */ - mutex_enter(&mqlist_mtx); + /* Check if there are any message queues in use. */ + mutex_enter(&mqlist_lock); inuse = !LIST_EMPTY(&mqueue_head); - mutex_exit(&mqlist_mtx); + mutex_exit(&mqlist_lock); if (inuse) { error = syscall_establish(NULL, mqueue_syscalls); KASSERT(error == 0); @@ -177,7 +165,7 @@ if (mqsysctl_log != NULL) sysctl_teardown(&mqsysctl_log); - mutex_destroy(&mqlist_mtx); + mutex_destroy(&mqlist_lock); pool_cache_destroy(mqmsg_cach
CVS commit: src/sys/dev/ieee1394
Module Name:src Committed By: rmind Date: Sun Apr 24 18:52:26 UTC 2011 Modified Files: src/sys/dev/ieee1394: firewirereg.h Log Message: Inclusion for malloc decls (missed in previous commit). To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ieee1394/firewirereg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ieee1394/firewirereg.h diff -u src/sys/dev/ieee1394/firewirereg.h:1.15 src/sys/dev/ieee1394/firewirereg.h:1.16 --- src/sys/dev/ieee1394/firewirereg.h:1.15 Sun Nov 14 15:47:20 2010 +++ src/sys/dev/ieee1394/firewirereg.h Sun Apr 24 18:52:26 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: firewirereg.h,v 1.15 2010/11/14 15:47:20 uebayasi Exp $ */ +/* $NetBSD: firewirereg.h,v 1.16 2011/04/24 18:52:26 rmind Exp $ */ /*- * Copyright (c) 2003 Hidetoshi Shimokawa * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa @@ -320,6 +320,8 @@ #define BIO_READ B_READ #define BIO_WRITE B_WRITE +#include + MALLOC_DECLARE(M_FW); MALLOC_DECLARE(M_FWXFER);
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun Apr 24 18:46:24 UTC 2011 Modified Files: src/sys/kern: exec_aout.c exec_ecoff.c kern_ksyms.c kern_pax.c kern_softint.c subr_autoconf.c subr_blist.c subr_prf.c subr_userconf.c uipc_mbuf.c uipc_socket2.c uipc_syscalls.c vfs_bio.c src/sys/sys: device.h event.h file.h namei.h namei.src Log Message: - Replace few malloc(9) uses with kmem(9). - Rename buf_malloc() to buf_alloc(), fix comments. - Remove some unnecessary inclusions. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/kern/exec_aout.c \ src/sys/kern/kern_softint.c cvs rdiff -u -r1.28 -r1.29 src/sys/kern/exec_ecoff.c cvs rdiff -u -r1.62 -r1.63 src/sys/kern/kern_ksyms.c cvs rdiff -u -r1.24 -r1.25 src/sys/kern/kern_pax.c cvs rdiff -u -r1.214 -r1.215 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_blist.c cvs rdiff -u -r1.139 -r1.140 src/sys/kern/subr_prf.c src/sys/kern/uipc_mbuf.c cvs rdiff -u -r1.20 -r1.21 src/sys/kern/subr_userconf.c cvs rdiff -u -r1.107 -r1.108 src/sys/kern/uipc_socket2.c cvs rdiff -u -r1.142 -r1.143 src/sys/kern/uipc_syscalls.c cvs rdiff -u -r1.228 -r1.229 src/sys/kern/vfs_bio.c cvs rdiff -u -r1.138 -r1.139 src/sys/sys/device.h cvs rdiff -u -r1.21 -r1.22 src/sys/sys/event.h cvs rdiff -u -r1.73 -r1.74 src/sys/sys/file.h cvs rdiff -u -r1.76 -r1.77 src/sys/sys/namei.h cvs rdiff -u -r1.23 -r1.24 src/sys/sys/namei.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/exec_aout.c diff -u src/sys/kern/exec_aout.c:1.34 src/sys/kern/exec_aout.c:1.35 --- src/sys/kern/exec_aout.c:1.34 Wed Nov 19 18:36:06 2008 +++ src/sys/kern/exec_aout.c Sun Apr 24 18:46:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: exec_aout.c,v 1.34 2008/11/19 18:36:06 ad Exp $ */ +/* $NetBSD: exec_aout.c,v 1.35 2011/04/24 18:46:22 rmind Exp $ */ /* * Copyright (c) 1993, 1994 Christopher G. Demetriou @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.34 2008/11/19 18:36:06 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.35 2011/04/24 18:46:22 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_coredump.h" @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include Index: src/sys/kern/kern_softint.c diff -u src/sys/kern/kern_softint.c:1.34 src/sys/kern/kern_softint.c:1.35 --- src/sys/kern/kern_softint.c:1.34 Mon Apr 11 19:13:54 2011 +++ src/sys/kern/kern_softint.c Sun Apr 24 18:46:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_softint.c,v 1.34 2011/04/11 19:13:54 rmind Exp $ */ +/* $NetBSD: kern_softint.c,v 1.35 2011/04/24 18:46:22 rmind Exp $ */ /*- * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. @@ -176,10 +176,9 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.34 2011/04/11 19:13:54 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.35 2011/04/24 18:46:22 rmind Exp $"); #include -#include #include #include #include Index: src/sys/kern/exec_ecoff.c diff -u src/sys/kern/exec_ecoff.c:1.28 src/sys/kern/exec_ecoff.c:1.29 --- src/sys/kern/exec_ecoff.c:1.28 Wed Nov 19 21:29:32 2008 +++ src/sys/kern/exec_ecoff.c Sun Apr 24 18:46:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: exec_ecoff.c,v 1.28 2008/11/19 21:29:32 cegger Exp $ */ +/* $NetBSD: exec_ecoff.c,v 1.29 2011/04/24 18:46:22 rmind Exp $ */ /* * Copyright (c) 1994 Adam Glass @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.28 2008/11/19 21:29:32 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.29 2011/04/24 18:46:22 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_coredump.h" @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include Index: src/sys/kern/kern_ksyms.c diff -u src/sys/kern/kern_ksyms.c:1.62 src/sys/kern/kern_ksyms.c:1.63 --- src/sys/kern/kern_ksyms.c:1.62 Tue Jan 4 01:40:19 2011 +++ src/sys/kern/kern_ksyms.c Sun Apr 24 18:46:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ksyms.c,v 1.62 2011/01/04 01:40:19 matt Exp $ */ +/* $NetBSD: kern_ksyms.c,v 1.63 2011/04/24 18:46:22 rmind Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.62 2011/01/04 01:40:19 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.63 2011/04/24 18:46:22 rmind Exp $"); #if defined(_KERNEL) && defined(_KERNEL_OPT) #include "opt_ddb.h" @@ -280,7 +280,7 @@ char *str; int nsyms = symsize / sizeof(Elf_Sym); - /* sanity check for pre-malloc map table used during startup */ + /* Sanity check for pre-allocated map table used during startup. */ if ((nmap == ksyms_nmap) && (nsyms >= KSYMS_MAX_ID)) { printf("kern_ksyms: ERROR %d > %d, increase KSYMS_MAX_ID\n", nsyms, KSYMS_MAX_ID); Index: src/sys/kern/kern_pax.c diff -u src/sys/kern/kern_pax.c:1.24 src/sys/kern/kern_pax.
CVS commit: src/sys/uvm
Module Name:src Committed By: rmind Date: Sun Apr 24 03:56:50 UTC 2011 Modified Files: src/sys/uvm: uvm_init.c Log Message: Initialize UVM loaning subsystem a bit later, after kmem(9). Makes UVMHIST work again. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/uvm/uvm_init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_init.c diff -u src/sys/uvm/uvm_init.c:1.40 src/sys/uvm/uvm_init.c:1.41 --- src/sys/uvm/uvm_init.c:1.40 Sat Apr 23 18:14:12 2011 +++ src/sys/uvm/uvm_init.c Sun Apr 24 03:56:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_init.c,v 1.40 2011/04/23 18:14:12 rmind Exp $ */ +/* $NetBSD: uvm_init.c,v 1.41 2011/04/24 03:56:50 rmind Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.40 2011/04/23 18:14:12 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.41 2011/04/24 03:56:50 rmind Exp $"); #include #include @@ -144,12 +144,6 @@ uvm_pager_init(); /* - * step 8: init the uvm_loan() facility. - */ - - uvm_loan_init(); - - /* * Initialize pools. This must be done before anyone manipulates * any vm_maps because we use a pool for some map entry structures. */ @@ -163,6 +157,12 @@ kmem_init(); /* + * Initialize the uvm_loan() facility. + */ + + uvm_loan_init(); + + /* * init emap subsystem. */
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sat Apr 23 18:57:28 UTC 2011 Modified Files: src/sys/kern: kern_descrip.c src/sys/sys: file.h Log Message: - Sprinkle __cacheline_aligned and __read_mostly in file descriptor code. - While here, remove trailing whitespaces, KNF. To generate a diff of this commit: cvs rdiff -u -r1.212 -r1.213 src/sys/kern/kern_descrip.c cvs rdiff -u -r1.72 -r1.73 src/sys/sys/file.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_descrip.c diff -u src/sys/kern/kern_descrip.c:1.212 src/sys/kern/kern_descrip.c:1.213 --- src/sys/kern/kern_descrip.c:1.212 Sun Apr 10 15:45:33 2011 +++ src/sys/kern/kern_descrip.c Sat Apr 23 18:57:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_descrip.c,v 1.212 2011/04/10 15:45:33 christos Exp $ */ +/* $NetBSD: kern_descrip.c,v 1.213 2011/04/23 18:57:27 rmind Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.212 2011/04/10 15:45:33 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.213 2011/04/23 18:57:27 rmind Exp $"); #include #include @@ -97,6 +97,17 @@ #include #include +/* + * A list (head) of open files, counter, and lock protecting them. + */ +struct filelist filehead __cacheline_aligned; +static u_int nfiles __cacheline_aligned; +kmutex_t filelist_lock __cacheline_aligned; + +static pool_cache_t filedesc_cache __read_mostly; +static pool_cache_t file_cache __read_mostly; +static pool_cache_t fdfile_cache __read_mostly; + static int file_ctor(void *, void *, int); static void file_dtor(void *, void *); static int fdfile_ctor(void *, void *, int); @@ -110,14 +121,6 @@ static void fill_file(struct kinfo_file *, const file_t *, const fdfile_t *, int, pid_t); -kmutex_t filelist_lock; /* lock on filehead */ -struct filelist filehead; /* head of list of open files */ -u_int nfiles; /* actual number of open files */ - -static pool_cache_t filedesc_cache; -static pool_cache_t file_cache; -static pool_cache_t fdfile_cache; - const struct cdevsw filedesc_cdevsw = { filedescopen, noclose, noread, nowrite, noioctl, nostop, notty, nopoll, nommap, nokqfilter, D_OTHER | D_MPSAFE, @@ -206,9 +209,7 @@ KASSERT(fd_isused(fdp, fd)); } } -#else /* DEBUG */ - /* nothing */ -#endif /* DEBUG */ +#endif } static int @@ -240,7 +241,7 @@ off++; } - return (-1); + return -1; found: return (off << NDENTRYSHIFT) + ffs(~sub) - 1; @@ -263,7 +264,7 @@ off--; if (off < 0) - return (-1); + return -1; i = ((off + 1) << NDENTRYSHIFT) - 1; if (i >= last) @@ -273,7 +274,7 @@ while (i > 0 && (ff[i] == NULL || !ff[i]->ff_allocated)) i--; - return (i); + return i; } static inline void @@ -288,9 +289,9 @@ KASSERT((fdp->fd_lomap[off] & (1 << (fd & NDENTRYMASK))) == 0); KASSERT(ff != NULL); KASSERT(ff->ff_file == NULL); - KASSERT(!ff->ff_allocated); + KASSERT(!ff->ff_allocated); - ff->ff_allocated = 1; + ff->ff_allocated = 1; fdp->fd_lomap[off] |= 1 << (fd & NDENTRYMASK); if (__predict_false(fdp->fd_lomap[off] == ~0)) { KASSERT((fdp->fd_himap[off >> NDENTRYSHIFT] & @@ -322,7 +323,7 @@ */ KASSERT(ff != NULL); KASSERT(ff->ff_file == NULL); - KASSERT(ff->ff_allocated); + KASSERT(ff->ff_allocated); if (fd < fdp->fd_freefile) { fdp->fd_freefile = fd; @@ -709,11 +710,9 @@ int fd_dup(file_t *fp, int minfd, int *newp, bool exclose) { - proc_t *p; + proc_t *p = curproc; int error; - p = curproc; - while ((error = fd_alloc(p, minfd, newp)) != 0) { if (error != ENOSPC) { return error; @@ -732,12 +731,10 @@ int fd_dup2(file_t *fp, unsigned new) { - filedesc_t *fdp; + filedesc_t *fdp = curlwp->l_fd; fdfile_t *ff; fdtab_t *dt; - fdp = curlwp->l_fd; - /* * Ensure there are enough slots in the descriptor table, * and allocate an fdfile_t up front in case we need it. @@ -772,7 +769,7 @@ KASSERT(new >= NDFDFILE); dt->dt_ff[new] = ff; ff = NULL; - } + } fd_used(fdp, new); mutex_exit(&fdp->fd_lock); @@ -807,8 +804,8 @@ mutex_exit(&fp->f_lock); /* We held the last reference - release locks, close and free. */ -if ((fp->f_flag & FHASLOCK) && fp->f_type == DTYPE_VNODE) { - lf.l_whence = SEEK_SET; + if ((fp->f_flag & FHASLOCK) && fp->f_type == DTYPE_VNODE) { + lf.l_whence = SEEK_SET; lf.l_start = 0; lf.l_len = 0; lf.l_type = F_UNLCK; @@ -832,15 +829,13 @@ int fd_alloc(proc_t *p, int want, int *result) { - filedesc_t *fdp; + filedesc_t *fdp = p->p_fd; int i, lim, last, error; u_int off, new; fdtab_t *dt; KASSERT(p == curproc || p == &proc0); - fdp = p->p_fd; - /* * Search for a free descriptor starting at the higher * of want or fd_freefile. @@ -1070,13 +1065,11 @@ int fd_allocfile(file_t **resultfp, int *resultfd) { + proc_t *p = c
CVS commit: src/sys/uvm
Module Name:src Committed By: rmind Date: Sat Apr 23 18:14:13 UTC 2011 Modified Files: src/sys/uvm: uvm_amap.c uvm_amap.h uvm_anon.c uvm_aobj.c uvm_device.c uvm_extern.h uvm_fault.c uvm_init.c uvm_io.c uvm_kmguard.c uvm_loan.c uvm_mmap.c uvm_pager.c uvm_pglist.c uvm_stat.h uvm_swap.c uvm_vnode.c Log Message: Replace "malloc" in comments, remove unnecessary header inclusions. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/uvm/uvm_amap.c cvs rdiff -u -r1.35 -r1.36 src/sys/uvm/uvm_amap.h cvs rdiff -u -r1.52 -r1.53 src/sys/uvm/uvm_anon.c cvs rdiff -u -r1.113 -r1.114 src/sys/uvm/uvm_aobj.c cvs rdiff -u -r1.60 -r1.61 src/sys/uvm/uvm_device.c src/sys/uvm/uvm_pglist.c cvs rdiff -u -r1.171 -r1.172 src/sys/uvm/uvm_extern.h cvs rdiff -u -r1.183 -r1.184 src/sys/uvm/uvm_fault.c cvs rdiff -u -r1.39 -r1.40 src/sys/uvm/uvm_init.c cvs rdiff -u -r1.25 -r1.26 src/sys/uvm/uvm_io.c cvs rdiff -u -r1.4 -r1.5 src/sys/uvm/uvm_kmguard.c cvs rdiff -u -r1.78 -r1.79 src/sys/uvm/uvm_loan.c cvs rdiff -u -r1.134 -r1.135 src/sys/uvm/uvm_mmap.c cvs rdiff -u -r1.99 -r1.100 src/sys/uvm/uvm_pager.c cvs rdiff -u -r1.48 -r1.49 src/sys/uvm/uvm_stat.h cvs rdiff -u -r1.153 -r1.154 src/sys/uvm/uvm_swap.c cvs rdiff -u -r1.94 -r1.95 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_amap.c diff -u src/sys/uvm/uvm_amap.c:1.89 src/sys/uvm/uvm_amap.c:1.90 --- src/sys/uvm/uvm_amap.c:1.89 Wed Feb 2 15:13:33 2011 +++ src/sys/uvm/uvm_amap.c Sat Apr 23 18:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_amap.c,v 1.89 2011/02/02 15:13:33 chuck Exp $ */ +/* $NetBSD: uvm_amap.c,v 1.90 2011/04/23 18:14:12 rmind Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -35,13 +35,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.89 2011/02/02 15:13:33 chuck Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.90 2011/04/23 18:14:12 rmind Exp $"); #include "opt_uvmhist.h" #include #include -#include #include #include #include @@ -98,8 +97,8 @@ * when enabled, an array of ints is allocated for the pprefs. this * array is allocated only when a partial reference is added to the * map (either by unmapping part of the amap, or gaining a reference - * to only a part of an amap). if the malloc of the array fails - * (M_NOWAIT), then we set the array pointer to PPREF_NONE to indicate + * to only a part of an amap). if the allocation of the array fails + * (KM_NOSLEEP), then we set the array pointer to PPREF_NONE to indicate * that we tried to do ppref's but couldn't alloc the array so just * give up (after all, this is an optional feature!). * @@ -190,6 +189,10 @@ amap->am_nslot = slots; amap->am_nused = 0; + /* + * Note: since allocations are likely big, we expect to reduce the + * memory fragmentation by allocating them in separate blocks. + */ amap->am_slots = kmem_alloc(totalslots * sizeof(int), kmflags); if (amap->am_slots == NULL) goto fail1; @@ -475,15 +478,15 @@ } /* - * case 3: we need to malloc a new amap and copy all the amap - * data over from old amap to the new one. + * Case 3: we need to allocate a new amap and copy all the amap + * data over from old amap to the new one. Drop the lock before + * performing allocation. * - * note that the use of a kernel realloc() probably would not - * help here, since we wish to abort cleanly if one of the - * three (or four) mallocs fails. + * Note: since allocations are likely big, we expect to reduce the + * memory fragmentation by allocating them in separate blocks. */ - amap_unlock(amap); /* unlock in case we sleep in malloc */ + amap_unlock(amap); if (slotneed >= UVM_AMAP_LARGE) { return E2BIG; @@ -492,8 +495,10 @@ slotalloc = amap_roundup_slots(slotneed); #ifdef UVM_AMAP_PPREF newppref = NULL; - if (amap->am_ppref && amap->am_ppref != PPREF_NONE) + if (amap->am_ppref && amap->am_ppref != PPREF_NONE) { + /* Will be handled later if fails. */ newppref = kmem_alloc(slotalloc * sizeof(*newppref), kmflags); + } #endif newsl = kmem_alloc(slotalloc * sizeof(*newsl), kmflags); newbck = kmem_alloc(slotalloc * sizeof(*newbck), kmflags); @@ -519,7 +524,7 @@ KASSERT(amap->am_maxslot < slotneed); /* - * now copy everything over to new malloc'd areas... + * Copy everything over to new allocated areas. */ slotadded = slotalloc - amap->am_nslot; @@ -829,7 +834,7 @@ /* * need to double check reference count now that we've got the * src amap locked down. the reference count could have - * changed while we were in malloc. if the reference count + * changed while we were allocating. if the reference count * dropped down to one we take over the old map rather than * copying the amap. */ @@ -1587,4 +1592,3 @@ UVMHIST_LOG(maphist,"<- done!", 0, 0, 0, 0);
CVS commit: [rmind-uvmplock] src/sys/ufs/ffs
Module Name:src Committed By: rmind Date: Sat Apr 23 15:35:25 UTC 2011 Modified Files: src/sys/ufs/ffs [rmind-uvmplock]: ffs_quota2.c Log Message: Few fixes, missed in last sync with head. To generate a diff of this commit: cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/ufs/ffs/ffs_quota2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_quota2.c diff -u src/sys/ufs/ffs/ffs_quota2.c:1.2.2.2 src/sys/ufs/ffs/ffs_quota2.c:1.2.2.3 --- src/sys/ufs/ffs/ffs_quota2.c:1.2.2.2 Thu Apr 21 01:42:20 2011 +++ src/sys/ufs/ffs/ffs_quota2.c Sat Apr 23 15:35:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_quota2.c,v 1.2.2.2 2011/04/21 01:42:20 rmind Exp $ */ +/* $NetBSD: ffs_quota2.c,v 1.2.2.3 2011/04/23 15:35:25 rmind Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_quota2.c,v 1.2.2.2 2011/04/21 01:42:20 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_quota2.c,v 1.2.2.3 2011/04/23 15:35:25 rmind Exp $"); #include #include @@ -92,9 +92,9 @@ } ump->um_quotas[USRQUOTA] = vp; ump->um_cred[USRQUOTA] = l->l_cred; - mutex_enter(&vp->v_interlock); + mutex_enter(vp->v_interlock); vp->v_writecount++; - mutex_exit(&vp->v_interlock); + mutex_exit(vp->v_interlock); VOP_UNLOCK(vp); } if (fs->fs_quota_flags & FS_Q2_DO_TYPE(GRPQUOTA) && @@ -109,10 +109,10 @@ } ump->um_quotas[GRPQUOTA] = vp; ump->um_cred[GRPQUOTA] = l->l_cred; - mutex_enter(&vp->v_interlock); + mutex_enter(vp->v_interlock); vp->v_vflag |= VV_SYSTEM; vp->v_writecount++; - mutex_exit(&vp->v_interlock); + mutex_exit(vp->v_interlock); VOP_UNLOCK(vp); } mp->mnt_flag |= MNT_QUOTA;
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Mon Apr 18 15:53:04 UTC 2011 Modified Files: src/sys/miscfs/genfs: genfs_io.c src/sys/miscfs/syncfs: sync_subr.c syncfs.h src/sys/sys: vnode.h Log Message: G/C unused speedup_syncer() mechanism and thus simplify some code. Update some comments to reflect the reality. No actual changes to the (used) syncer logic. OK ad@ To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.43 -r1.44 src/sys/miscfs/syncfs/sync_subr.c cvs rdiff -u -r1.11 -r1.12 src/sys/miscfs/syncfs/syncfs.h cvs rdiff -u -r1.227 -r1.228 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.46 src/sys/miscfs/genfs/genfs_io.c:1.47 --- src/sys/miscfs/genfs/genfs_io.c:1.46 Mon Dec 6 10:22:43 2010 +++ src/sys/miscfs/genfs/genfs_io.c Mon Apr 18 15:53:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.46 2010/12/06 10:22:43 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.47 2011/04/18 15:53:04 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.46 2010/12/06 10:22:43 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.47 2011/04/18 15:53:04 rmind Exp $"); #include #include @@ -52,6 +52,7 @@ #include #include #include +#include #include #include Index: src/sys/miscfs/syncfs/sync_subr.c diff -u src/sys/miscfs/syncfs/sync_subr.c:1.43 src/sys/miscfs/syncfs/sync_subr.c:1.44 --- src/sys/miscfs/syncfs/sync_subr.c:1.43 Wed Jul 21 17:52:12 2010 +++ src/sys/miscfs/syncfs/sync_subr.c Mon Apr 18 15:53:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sync_subr.c,v 1.43 2010/07/21 17:52:12 hannken Exp $ */ +/* $NetBSD: sync_subr.c,v 1.44 2011/04/18 15:53:04 rmind Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -60,8 +60,37 @@ * SUCH DAMAGE. */ +/* + * The filesystem synchronizer mechanism - syncer. + * + * It is useful to delay writes of file data and filesystem metadata for + * a certain amount of time so that quickly created and deleted files need + * not waste disk bandwidth being created and removed. To implement this, + * vnodes are appended to a "workitem" queue. + * + * Most pending metadata should not wait for more than ten seconds. Thus, + * mounted on block devices are delayed only about a half the time that file + * data is delayed. Similarly, directory updates are more critical, so are + * only delayed about a third the time that file data is delayed. + * + * There are SYNCER_MAXDELAY queues that are processed in a round-robin + * manner at a rate of one each second (driven off the filesystem syner + * thread). The syncer_delayno variable indicates the next queue that is + * to be processed. Items that need to be processed soon are placed in + * this queue: + * + * syncer_workitem_pending[syncer_delayno] + * + * A delay of e.g. fifteen seconds is done by placing the request fifteen + * entries later in the queue: + * + * syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask] + * + * Flag VI_ONWORKLST indicates that vnode is added into the queue. + */ + #include -__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.43 2010/07/21 17:52:12 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.44 2011/04/18 15:53:04 rmind Exp $"); #include #include @@ -78,7 +107,10 @@ #include #include +typedef TAILQ_HEAD(synclist, vnode) synclist_t; + static void vn_syncer_add1(struct vnode *, int); +static void sysctl_vfs_syncfs_setup(struct sysctllog **); /* * Defines and variables for the syncer process. @@ -90,19 +122,12 @@ time_t metadelay = 10; /* time to delay syncing metadata */ time_t lockdelay = 1; /* time to delay if locking fails */ -kmutex_t syncer_mutex; /* used to freeze syncer, long term */ -static kmutex_t syncer_data_lock; /* short term lock on data structures */ +kmutex_t syncer_mutex; /* used to freeze syncer, long term */ +static kmutex_t syncer_data_lock; /* short term lock on data structs */ -static int rushjob; /* number of slots to run ASAP */ -static kcondvar_t syncer_cv; /* cv for rushjob */ -static int stat_rush_requests; /* number of times I/O speeded up */ - -static int syncer_delayno = 0; -static long syncer_last; -static struct synclist *syncer_workitem_pending; -struct lwp *updateproc = NULL; - -static void sysctl_vfs_syncfs_setup(struct sysctllog **); +static int syncer_delayno = 0; +static long syncer_last; +static synclist_t * syncer_workitem_pending; void vn_initialize_syncerd(void) @@ -121,57 +146,27 @@ mutex_init(&syncer_mutex, MUTEX_DEFAULT, IPL_NONE); mutex_init(&syncer_data_lock, MUTEX_DEFAULT, IPL_NONE); - cv_init(&syncer_cv, "syncer"); } /* - * The workitem queue. - * - * It is useful to delay writes of file data and
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: rmind Date: Mon Apr 18 03:04:31 UTC 2011 Modified Files: src/sys/arch/xen/xen: balloon.c Log Message: balloon_xenbus_attach: use KM_SLEEP for allocation. Note: please do not use KM_NOSLEEP. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/xen/xen/balloon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/balloon.c diff -u src/sys/arch/xen/xen/balloon.c:1.7 src/sys/arch/xen/xen/balloon.c:1.8 --- src/sys/arch/xen/xen/balloon.c:1.7 Mon Apr 18 01:36:25 2011 +++ src/sys/arch/xen/xen/balloon.c Mon Apr 18 03:04:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: balloon.c,v 1.7 2011/04/18 01:36:25 jym Exp $ */ +/* $NetBSD: balloon.c,v 1.8 2011/04/18 03:04:31 rmind Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ #define BALLOONDEBUG 0 #include -__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.7 2011/04/18 01:36:25 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.8 2011/04/18 03:04:31 rmind Exp $"); #include #include @@ -229,11 +229,7 @@ sysctl_kern_xen_balloon_setup(sc); /* List of MFNs passed from/to balloon for inflating/deflating */ - mfn_list = kmem_alloc(BALLOON_DELTA * sizeof(*mfn_list), KM_NOSLEEP); - if (mfn_list == NULL) { - aprint_error_dev(self, "could not allocate mfn_list\n"); - goto error; - } + mfn_list = kmem_alloc(BALLOON_DELTA * sizeof(*mfn_list), KM_SLEEP); sc->sc_mfn_list = mfn_list; /* Setup xenbus node watch callback */
CVS commit: src/sys/dev
Module Name:src Committed By: rmind Date: Mon Apr 18 01:47:28 UTC 2011 Modified Files: src/sys/dev/ata: ata.c atavar.h src/sys/dev/scsipi: scsiconf.c Log Message: Replace few simple_lock and ltsleep/wakeup uses with mutex(9) and condvar(9). Note to all: please replace old primitives in your code! Thanks. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/dev/ata/ata.c cvs rdiff -u -r1.80 -r1.81 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.259 -r1.260 src/sys/dev/scsipi/scsiconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.113 src/sys/dev/ata/ata.c:1.114 --- src/sys/dev/ata/ata.c:1.113 Sun Mar 28 20:46:18 2010 +++ src/sys/dev/ata/ata.c Mon Apr 18 01:47:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.113 2010/03/28 20:46:18 snj Exp $ */ +/* $NetBSD: ata.c,v 1.114 2011/04/18 01:47:28 rmind Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.113 2010/03/28 20:46:18 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.114 2011/04/18 01:47:28 rmind Exp $"); #include "opt_ata.h" @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -74,18 +73,18 @@ #define ATADEBUG_PRINT(args, level) #endif +static ONCE_DECL(ata_init_ctrl); static struct pool ata_xfer_pool; /* * A queue of atabus instances, used to ensure the same bus probe order - * for a given hardware configuration at each boot. + * for a given hardware configuration at each boot. Kthread probing + * devices on a atabus. Only one probing at once. */ -struct atabus_initq_head atabus_initq_head = -TAILQ_HEAD_INITIALIZER(atabus_initq_head); -struct simplelock atabus_interlock = SIMPLELOCK_INITIALIZER; - -/* kernel thread probing devices on a atabus. Only one probing at once */ -struct lwp *atabus_configlwp; +static TAILQ_HEAD(, atabus_initq) atabus_initq_head; +static kmutex_tatabus_qlock; +static kcondvar_t atabus_qcv; +static lwp_t *atabus_cfg_lwp; /* * ATA bus layer. @@ -111,6 +110,23 @@ static void atabusconfig_thread(void *); /* + * atabus_init: + * + * Initialize ATA subsystem structures. + */ +static int +atabus_init(void) +{ + + pool_init(&ata_xfer_pool, sizeof(struct ata_xfer), 0, 0, 0, + "ataspl", NULL, IPL_BIO); + TAILQ_INIT(&atabus_initq_head); + mutex_init(&atabus_qlock, MUTEX_DEFAULT, IPL_NONE); + cv_init(&atabus_qcv, "atainitq"); + return 0; +} + +/* * atabusprint: * * Autoconfiguration print routine used by ATA controllers when @@ -196,15 +212,14 @@ splx(s); /* Make sure the devices probe in atabus order to avoid jitter. */ - simple_lock(&atabus_interlock); - while(1) { + mutex_enter(&atabus_qlock); + for (;;) { atabus_initq = TAILQ_FIRST(&atabus_initq_head); if (atabus_initq->atabus_sc == atabus_sc) break; - ltsleep(&atabus_initq_head, PRIBIO, "ata_initq", 0, - &atabus_interlock); + cv_wait(&atabus_qcv, &atabus_qlock); } - simple_unlock(&atabus_interlock); + mutex_exit(&atabus_qlock); /* If no drives, abort here */ for (i = 0; i < chp->ch_ndrive; i++) @@ -219,19 +234,19 @@ if ((error = kthread_create(PRI_NONE, 0, NULL, atabusconfig_thread, - atabus_sc, &atabus_configlwp, + atabus_sc, &atabus_cfg_lwp, "%scnf", device_xname(atac->atac_dev))) != 0) aprint_error_dev(atac->atac_dev, "unable to create config thread: error %d\n", error); return; out: - simple_lock(&atabus_interlock); + mutex_enter(&atabus_qlock); TAILQ_REMOVE(&atabus_initq_head, atabus_initq, atabus_initq); - simple_unlock(&atabus_interlock); + cv_broadcast(&atabus_qcv); + mutex_exit(&atabus_qlock); free(atabus_initq, M_DEVBUF); - wakeup(&atabus_initq_head); ata_delref(chp); @@ -248,13 +263,15 @@ struct atabus_softc *atabus_sc = arg; struct ata_channel *chp = atabus_sc->sc_chan; struct atac_softc *atac = chp->ch_atac; - int i, s; struct atabus_initq *atabus_initq = NULL; + int i, s; - simple_lock(&atabus_interlock); + /* XXX seems wrong */ + mutex_enter(&atabus_qlock); atabus_initq = TAILQ_FIRST(&atabus_initq_head); - simple_unlock(&atabus_interlock); KASSERT(atabus_initq->atabus_sc == atabus_sc); + mutex_exit(&atabus_qlock); + /* * Attach an ATAPI bus, if needed. */ @@ -326,12 +343,12 @@ } splx(s); - simple_lock(&atabus_interlock); + mutex_enter(&atabus_qlock); TAILQ_REMOVE(&atabus_initq_head, atabus_initq, atabus_initq); - simple_unlock(&atabus_interlock); + cv_broadcast(&atabus_qcv); + mutex_exit(&atabus_qlock); free(atabus_initq, M_DEVBUF); - wakeup(&atabus_initq_head); ata_delref(chp); @@ -424,15 +441,6 @@ return (1); } -static int -atabus_xferpool_init(void) -{ - - pool_init(&ata_xfer_pool,
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Mon Apr 18 00:26:12 UTC 2011 Modified Files: src/sys/arch/sparc/sparc: machdep.c trap.c vm_machdep.c src/sys/kern: kern_proc.c src/sys/sys: proc.h Log Message: Replace malloc with kmem, and remove M_SUBPROC. To generate a diff of this commit: cvs rdiff -u -r1.307 -r1.308 src/sys/arch/sparc/sparc/machdep.c cvs rdiff -u -r1.186 -r1.187 src/sys/arch/sparc/sparc/trap.c cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc/sparc/vm_machdep.c cvs rdiff -u -r1.174 -r1.175 src/sys/kern/kern_proc.c cvs rdiff -u -r1.303 -r1.304 src/sys/sys/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/machdep.c diff -u src/sys/arch/sparc/sparc/machdep.c:1.307 src/sys/arch/sparc/sparc/machdep.c:1.308 --- src/sys/arch/sparc/sparc/machdep.c:1.307 Fri Mar 4 22:25:28 2011 +++ src/sys/arch/sparc/sparc/machdep.c Mon Apr 18 00:26:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.307 2011/03/04 22:25:28 joerg Exp $ */ +/* $NetBSD: machdep.c,v 1.308 2011/04/18 00:26:11 rmind Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.307 2011/03/04 22:25:28 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.308 2011/04/18 00:26:11 rmind Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_sunos.h" @@ -383,7 +383,7 @@ } l->l_md.md_fpu = NULL; FPU_UNLOCK(s); - free((void *)fs, M_SUBPROC); + kmem_free(fs, sizeof(struct fpstate)); l->l_md.md_fpstate = NULL; } memset((void *)tf, 0, sizeof *tf); Index: src/sys/arch/sparc/sparc/trap.c diff -u src/sys/arch/sparc/sparc/trap.c:1.186 src/sys/arch/sparc/sparc/trap.c:1.187 --- src/sys/arch/sparc/sparc/trap.c:1.186 Fri Jan 14 02:06:31 2011 +++ src/sys/arch/sparc/sparc/trap.c Mon Apr 18 00:26:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.186 2011/01/14 02:06:31 rmind Exp $ */ +/* $NetBSD: trap.c,v 1.187 2011/04/18 00:26:12 rmind Exp $ */ /* * Copyright (c) 1996 @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.186 2011/01/14 02:06:31 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.187 2011/04/18 00:26:12 rmind Exp $"); #include "opt_ddb.h" #include "opt_compat_svr4.h" @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -419,7 +418,7 @@ #endif if (fs == NULL) { - fs = malloc(sizeof *fs, M_SUBPROC, M_WAITOK); + fs = kmem_alloc(sizeof(struct fpstate), KM_SLEEP); *fs = initfpstate; l->l_md.md_fpstate = fs; } Index: src/sys/arch/sparc/sparc/vm_machdep.c diff -u src/sys/arch/sparc/sparc/vm_machdep.c:1.105 src/sys/arch/sparc/sparc/vm_machdep.c:1.106 --- src/sys/arch/sparc/sparc/vm_machdep.c:1.105 Thu Feb 24 04:28:48 2011 +++ src/sys/arch/sparc/sparc/vm_machdep.c Mon Apr 18 00:26:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.105 2011/02/24 04:28:48 joerg Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.106 2011/04/18 00:26:12 rmind Exp $ */ /* * Copyright (c) 1996 @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.105 2011/02/24 04:28:48 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.106 2011/04/18 00:26:12 rmind Exp $"); #include "opt_multiprocessor.h" @@ -57,11 +57,10 @@ #include #include #include -#include +#include #include #include #include -#include #include #include @@ -220,8 +219,8 @@ struct cpu_info *cpi; int s; - l2->l_md.md_fpstate = malloc(sizeof(struct fpstate), - M_SUBPROC, M_WAITOK); + l2->l_md.md_fpstate = + kmem_alloc(sizeof(struct fpstate), KM_SLEEP); FPU_LOCK(s); if ((cpi = l1->l_md.md_fpu) != NULL) { @@ -325,7 +324,7 @@ struct fpstate *fs; if ((fs = l->l_md.md_fpstate) != NULL) - free((void *)fs, M_SUBPROC); + kmem_free(fs, sizeof(struct fpstate)); } void Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.174 src/sys/kern/kern_proc.c:1.175 --- src/sys/kern/kern_proc.c:1.174 Tue Apr 5 09:02:23 2011 +++ src/sys/kern/kern_proc.c Mon Apr 18 00:26:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.174 2011/04/05 09:02:23 rmind Exp $ */ +/* $NetBSD: kern_proc.c,v 1.175 2011/04/18 00:26:11 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.174 2011/04/05 09:02:23 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.175 2011/04/18 00:26:11 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -205,7 +205,6 @@ int cmask = CMASK; MALLOC_DEFINE(M_EMULDATA, "emuldata", "Per-process emulation data"); -MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures"); static int sysctl_doeproc(SYSCTLFN_PROTO); static int sysctl_kern_proc_args(SYSCTLFN_PROTO); Index: src/sys/sys/proc.h diff -u sr
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sun Apr 17 20:37:43 UTC 2011 Modified Files: src/sys/kern: uipc_sem.c Log Message: ksem_free: remove wrong assert. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/kern/uipc_sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.34 src/sys/kern/uipc_sem.c:1.35 --- src/sys/kern/uipc_sem.c:1.34 Sat Apr 16 20:39:18 2011 +++ src/sys/kern/uipc_sem.c Sun Apr 17 20:37:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_sem.c,v 1.34 2011/04/16 20:39:18 rmind Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.35 2011/04/17 20:37:43 rmind Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.34 2011/04/16 20:39:18 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.35 2011/04/17 20:37:43 rmind Exp $"); #include #include @@ -312,7 +312,6 @@ ksem_free(ksem_t *ks) { - KASSERT(ks->ks_ref == 0); KASSERT(!cv_has_waiters(&ks->ks_cv)); if (ks->ks_name) {
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat Apr 16 20:39:18 UTC 2011 Modified Files: src/sys/kern: uipc_sem.c Log Message: - Add nsems_total and track the use of all semaphores (not only named ones). Prevents ksem module from unloading while anonymous semaphore(s) are in use. - ksem_free: add few asserts. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/kern/uipc_sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.33 src/sys/kern/uipc_sem.c:1.34 --- src/sys/kern/uipc_sem.c:1.33 Fri Apr 15 00:01:48 2011 +++ src/sys/kern/uipc_sem.c Sat Apr 16 20:39:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_sem.c,v 1.33 2011/04/15 00:01:48 rmind Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.34 2011/04/16 20:39:18 rmind Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,11 +60,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.33 2011/04/15 00:01:48 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.34 2011/04/16 20:39:18 rmind Exp $"); #include -#include #include + +#include #include #include #include @@ -104,6 +105,7 @@ static kmutex_t ksem_lock __cacheline_aligned; static LIST_HEAD(,ksem) ksem_head __cacheline_aligned; +static u_int nsems_total __cacheline_aligned; static u_int nsems __cacheline_aligned; static int ksem_sysinit(void); @@ -141,9 +143,10 @@ { int error; - nsems = 0; mutex_init(&ksem_lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ksem_head); + nsems_total = 0; + nsems = 0; error = syscall_establish(NULL, ksem_syscalls); if (error) { @@ -162,7 +165,11 @@ if (error != 0) { return error; } - if (nsems != 0) { + /* + * Make sure that no semaphores are in use. Note: semops + * must be unused at this point. + */ + if (nsems_total) { error = syscall_establish(NULL, ksem_syscalls); KASSERT(error == 0); return EBUSY; @@ -296,6 +303,7 @@ ks->ks_uid = kauth_cred_geteuid(uc); ks->ks_gid = kauth_cred_getegid(uc); + atomic_inc_uint(&nsems_total); *ksret = ks; return 0; } @@ -304,6 +312,9 @@ ksem_free(ksem_t *ks) { + KASSERT(ks->ks_ref == 0); + KASSERT(!cv_has_waiters(&ks->ks_cv)); + if (ks->ks_name) { KASSERT(ks->ks_namelen > 0); kmem_free(ks->ks_name, ks->ks_namelen); @@ -311,6 +322,8 @@ mutex_destroy(&ks->ks_lock); cv_destroy(&ks->ks_cv); kmem_free(ks, sizeof(ksem_t)); + + atomic_dec_uint(&nsems_total); } int
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Fri Apr 15 00:01:48 UTC 2011 Modified Files: src/sys/kern: uipc_sem.c Log Message: sys__ksem_close: use fd_close(). To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/kern/uipc_sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.32 src/sys/kern/uipc_sem.c:1.33 --- src/sys/kern/uipc_sem.c:1.32 Thu Apr 14 00:32:23 2011 +++ src/sys/kern/uipc_sem.c Fri Apr 15 00:01:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_sem.c,v 1.32 2011/04/14 00:32:23 rmind Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.33 2011/04/15 00:01:48 rmind Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.32 2011/04/14 00:32:23 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.33 2011/04/15 00:01:48 rmind Exp $"); #include #include @@ -490,9 +490,12 @@ /* { intptr_t id; } */ - struct sys_close_args cuap; - SCARG(&cuap, fd) = SCARG(uap, id); - return sys_close(l, (const void *)&cuap, retval); + int fd = (int)SCARG(uap, id); + + if (fd_getfile(fd) == NULL) { + return EBADF; + } + return fd_close(fd); } static int
CVS commit: src/usr.bin/fstat
Module Name:src Committed By: rmind Date: Thu Apr 14 00:35:35 UTC 2011 Modified Files: src/usr.bin/fstat: fstat.c Log Message: Add DTYPE_SEM. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/usr.bin/fstat/fstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fstat/fstat.c diff -u src/usr.bin/fstat/fstat.c:1.89 src/usr.bin/fstat/fstat.c:1.90 --- src/usr.bin/fstat/fstat.c:1.89 Sun May 24 21:41:44 2009 +++ src/usr.bin/fstat/fstat.c Thu Apr 14 00:35:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fstat.c,v 1.89 2009/05/24 21:41:44 ad Exp $ */ +/* $NetBSD: fstat.c,v 1.90 2011/04/14 00:35:35 rmind Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95"; #else -__RCSID("$NetBSD: fstat.c,v 1.89 2009/05/24 21:41:44 ad Exp $"); +__RCSID("$NetBSD: fstat.c,v 1.90 2011/04/14 00:35:35 rmind Exp $"); #endif #endif /* not lint */ @@ -407,6 +407,7 @@ case DTYPE_KQUEUE: case DTYPE_CRYPTO: case DTYPE_MQUEUE: + case DTYPE_SEM: if (checkfile == 0) misctrans(&file); break;
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Thu Apr 14 00:32:23 UTC 2011 Modified Files: src/sys/kern: uipc_sem.c Log Message: Minor comment fix. Use fd_close() in sys__ksem_destroy(), it is cleaner. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/kern/uipc_sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.31 src/sys/kern/uipc_sem.c:1.32 --- src/sys/kern/uipc_sem.c:1.31 Tue Apr 12 20:37:25 2011 +++ src/sys/kern/uipc_sem.c Thu Apr 14 00:32:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_sem.c,v 1.31 2011/04/12 20:37:25 rmind Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.32 2011/04/14 00:32:23 rmind Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.31 2011/04/12 20:37:25 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.32 2011/04/14 00:32:23 rmind Exp $"); #include #include @@ -460,7 +460,7 @@ } /* - * Finally, insert semaphore into the hash. + * Finally, insert semaphore into the list. * Note: it already has the initial reference. */ ks = ksnew; @@ -676,7 +676,6 @@ intptr_t id; } */ int fd = (int)SCARG(uap, id), error; - struct sys_close_args cuap; ksem_t *ks; error = ksem_get(fd, &ks); @@ -697,10 +696,9 @@ } out: mutex_exit(&ks->ks_lock); - fd_putfile(fd); if (error) { + fd_putfile(fd); return error; } - SCARG(&cuap, fd) = fd; - return sys_close(l, (const void *)&cuap, retval); + return fd_close(fd); }
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Tue Apr 12 20:37:26 UTC 2011 Modified Files: src/sys/kern: uipc_sem.c Log Message: do_ksem_open: do not leak the file descriptor on error path. sys__ksem_unlink: fix comment, release one lock ealier. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/kern/uipc_sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.30 src/sys/kern/uipc_sem.c:1.31 --- src/sys/kern/uipc_sem.c:1.30 Mon Apr 11 22:31:43 2011 +++ src/sys/kern/uipc_sem.c Tue Apr 12 20:37:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_sem.c,v 1.30 2011/04/11 22:31:43 rmind Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.31 2011/04/12 20:37:25 rmind Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.30 2011/04/11 22:31:43 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.31 2011/04/12 20:37:25 rmind Exp $"); #include #include @@ -448,7 +448,8 @@ if ((oflag & O_CREAT) == 0) { mutex_exit(&ksem_lock); KASSERT(ksnew == NULL); - return ENOENT; + error = ENOENT; + goto err; } /* Check for the limit locked. */ @@ -549,9 +550,10 @@ return error; } - /* Remove and destroy if no referenes. */ + /* Remove from the global list. */ LIST_REMOVE(ks, ks_entry); nsems--; + mutex_exit(&ksem_lock); refcnt = ks->ks_ref; if (refcnt) { @@ -559,7 +561,6 @@ ks->ks_flags |= KS_UNLINKED; } mutex_exit(&ks->ks_lock); - mutex_exit(&ksem_lock); if (refcnt == 0) { ksem_free(ks);
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Mon Apr 11 22:31:43 UTC 2011 Modified Files: src/sys/kern: uipc_sem.c src/sys/sys: file.h Log Message: Highly rewrite POSIX semaphore. Use file descriptor subsystem, greatly simplify reference counting, and fix various bugs which existed before, e.g. some incorrect locking or mq_unlink() not checking for permissions. Also, fixes PR/43452. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/kern/uipc_sem.c cvs rdiff -u -r1.71 -r1.72 src/sys/sys/file.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_sem.c diff -u src/sys/kern/uipc_sem.c:1.29 src/sys/kern/uipc_sem.c:1.30 --- src/sys/kern/uipc_sem.c:1.29 Fri Nov 14 15:49:21 2008 +++ src/sys/kern/uipc_sem.c Mon Apr 11 22:31:43 2011 @@ -1,11 +1,11 @@ -/* $NetBSD: uipc_sem.c,v 1.29 2008/11/14 15:49:21 ad Exp $ */ +/* $NetBSD: uipc_sem.c,v 1.30 2011/04/11 22:31:43 rmind Exp $ */ /*- - * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. + * by Mindaugas Rasiukevicius. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,8 +55,12 @@ * SUCH DAMAGE. */ +/* + * Implementation of POSIX semaphore. + */ + #include -__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.29 2008/11/14 15:49:21 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.30 2011/04/11 22:31:43 rmind Exp $"); #include #include @@ -67,6 +71,8 @@ #include #include #include +#include +#include #include #include #include @@ -74,14 +80,48 @@ #include #include -#define SEM_MAX_NAMELEN 14 -#define SEM_VALUE_MAX (~0U) -#define SEM_HASHTBL_SIZE 13 +MODULE(MODULE_CLASS_MISC, ksem, NULL); -#define SEM_TO_ID(x) (((x)->ks_id)) -#define SEM_HASH(id) ((id) % SEM_HASHTBL_SIZE) +#define SEM_MAX_NAMELEN 14 +#define SEM_VALUE_MAX (~0U) -MODULE(MODULE_CLASS_MISC, ksem, NULL); +#define KS_UNLINKED 0x01 + +typedef struct ksem { + LIST_ENTRY(ksem) ks_entry; /* global list entry */ + kmutex_t ks_lock; /* lock on this ksem */ + kcondvar_t ks_cv; /* condition variable */ + u_int ks_ref; /* number of references */ + u_int ks_value; /* current value */ + u_int ks_waiters; /* number of waiters */ + char * ks_name; /* name, if named */ + size_t ks_namelen; /* length of name */ + int ks_flags; /* for KS_UNLINKED */ + mode_t ks_mode; /* protection bits */ + uid_t ks_uid; /* creator uid */ + gid_t ks_gid; /* creator gid */ +} ksem_t; + +static kmutex_t ksem_lock __cacheline_aligned; +static LIST_HEAD(,ksem) ksem_head __cacheline_aligned; +static u_int nsems __cacheline_aligned; + +static int ksem_sysinit(void); +static int ksem_sysfini(bool); +static int ksem_modcmd(modcmd_t, void *); +static int ksem_close_fop(file_t *); + +static const struct fileops semops = { + .fo_read = fbadop_read, + .fo_write = fbadop_write, + .fo_ioctl = fbadop_ioctl, + .fo_fcntl = fnullop_fcntl, + .fo_poll = fnullop_poll, + .fo_stat = fbadop_stat, + .fo_close = ksem_close_fop, + .fo_kqfilter = fnullop_kqfilter, + .fo_restart = fnullop_restart, +}; static const struct syscall_package ksem_syscalls[] = { { SYS__ksem_init, 0, (sy_call_t *)sys__ksem_init }, @@ -96,283 +136,186 @@ { 0, 0, NULL }, }; -/* - * Note: to read the ks_name member, you need either the ks_interlock - * or the ksem_mutex. To write the ks_name member, you need both. Make - * sure the order is ksem_mutex -> ks_interlock. - */ -struct ksem { - LIST_ENTRY(ksem) ks_entry; /* global list entry */ - LIST_ENTRY(ksem) ks_hash; /* hash list entry */ - kmutex_t ks_interlock; /* lock on this ksem */ - kcondvar_t ks_cv; /* condition variable */ - unsigned int ks_ref; /* number of references */ - char *ks_name; /* if named, this is the name */ - size_t ks_namelen; /* length of name */ - mode_t ks_mode; /* protection bits */ - uid_t ks_uid; /* creator uid */ - gid_t ks_gid; /* creator gid */ - unsigned int ks_value; /* current value */ - unsigned int ks_waiters; /* number of waiters */ - intptr_t ks_id; /* unique identifier */ -}; - -struct ksem_ref { - LIST_ENTRY(ksem_ref) ksr_list; - struct ksem *ksr_ksem; -}; - -struct ksem_proc { - krwlock_t kp_lock; - LIST_HEAD(, ksem_ref) kp_ksems; -}; - -LIST_HEAD(ksem_list, ksem); - -/* - * ksem_mutex protects ksem_head and nsems. Only named semaphores go - * onto ksem_head. - */ -static kmutex_t ksem_mutex; -static struct ksem_list ksem_head = LIST_HEAD_INITIALIZER(&ksem_head); -static struct ksem_list ksem_hash[SEM_HASHTBL_SIZE]; -static int nsems = 0; - -/* - * ksem_counter is the last assigned intptr_t.
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Mon Apr 11 19:13:54 UTC 2011 Modified Files: src/sys/kern: kern_softint.c Log Message: softint_execute: add assert which could catch locking bugs in softint handlers. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/kern/kern_softint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_softint.c diff -u src/sys/kern/kern_softint.c:1.33 src/sys/kern/kern_softint.c:1.34 --- src/sys/kern/kern_softint.c:1.33 Mon Dec 20 00:25:46 2010 +++ src/sys/kern/kern_softint.c Mon Apr 11 19:13:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_softint.c,v 1.33 2010/12/20 00:25:46 matt Exp $ */ +/* $NetBSD: kern_softint.c,v 1.34 2011/04/11 19:13:54 rmind Exp $ */ /*- * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. @@ -176,7 +176,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.33 2010/12/20 00:25:46 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.34 2011/04/11 19:13:54 rmind Exp $"); #include #include @@ -539,6 +539,11 @@ havelock = true; } (*sh->sh_func)(sh->sh_arg); + + /* Diagnostic: check that spin-locks have not leaked. */ + KASSERTMSG(curcpu()->ci_mtx_count == 0, + ("%s: ci_mtx_count (%d) != 0, sh_func %p\n", + __func__, curcpu()->ci_mtx_count, sh->sh_func)); (void)splhigh(); KASSERT((sh->sh_flags & SOFTINT_ACTIVE) != 0);
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Mon Apr 11 19:11:08 UTC 2011 Modified Files: src/sys/arch/vax/vax: genassym.cf src/sys/kern: kern_mutex.c Log Message: G/C unused MUTEX_COUNT_BIAS (it was for VAX) To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/vax/vax/genassym.cf cvs rdiff -u -r1.50 -r1.51 src/sys/kern/kern_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/vax/vax/genassym.cf diff -u src/sys/arch/vax/vax/genassym.cf:1.48 src/sys/arch/vax/vax/genassym.cf:1.49 --- src/sys/arch/vax/vax/genassym.cf:1.48 Mon Dec 20 00:25:45 2010 +++ src/sys/arch/vax/vax/genassym.cf Mon Apr 11 19:11:08 2011 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.48 2010/12/20 00:25:45 matt Exp $ +# $NetBSD: genassym.cf,v 1.49 2011/04/11 19:11:08 rmind Exp $ # # Copyright (c) 1997 Ludd, University of Lule}, Sweden. # All rights reserved. @@ -170,9 +170,6 @@ define MTX_OWNER offsetof(struct kmutex, mtx_owner) define MTX_LOCK offsetof(struct kmutex, mtx_lock) define MTX_IPL offsetof(struct kmutex, mtx_ipl) -ifdef MUTEX_COUNT_BIAS -define MTX_COUNT_BIAS MUTEX_COUNT_BIAS -endif define RW_OWNER offsetof(struct krwlock, rw_owner) define RW_HAS_WAITERS RW_HAS_WAITERS Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.50 src/sys/kern/kern_mutex.c:1.51 --- src/sys/kern/kern_mutex.c:1.50 Sun Mar 20 23:19:16 2011 +++ src/sys/kern/kern_mutex.c Mon Apr 11 19:11:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.50 2011/03/20 23:19:16 rmind Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.51 2011/04/11 19:11:08 rmind Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.50 2011/03/20 23:19:16 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.51 2011/04/11 19:11:08 rmind Exp $"); #include #include @@ -117,9 +117,6 @@ /* * Spin mutex SPL save / restore. */ -#ifndef MUTEX_COUNT_BIAS -#define MUTEX_COUNT_BIAS 0 -#endif #define MUTEX_SPIN_SPLRAISE(mtx) \ do { \ @@ -129,7 +126,7 @@ x__ci = curcpu(); \ x__cnt = x__ci->ci_mtx_count--; \ __insn_barrier(); \ - if (x__cnt == MUTEX_COUNT_BIAS) \ + if (x__cnt == 0) \ x__ci->ci_mtx_oldspl = (s);\ } while (/* CONSTCOND */ 0) @@ -138,7 +135,7 @@ struct cpu_info *x__ci = curcpu();\ int s = x__ci->ci_mtx_oldspl; \ __insn_barrier(); \ - if (++(x__ci->ci_mtx_count) == MUTEX_COUNT_BIAS) \ + if (++(x__ci->ci_mtx_count) == 0) \ splx(s); \ } while (/* CONSTCOND */ 0)
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Tue Apr 5 09:02:23 UTC 2011 Modified Files: src/sys/kern: kern_proc.c Log Message: sysctl_kern_proc_args: fix the deadlock (hi joerg!). To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/sys/kern/kern_proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.173 src/sys/kern/kern_proc.c:1.174 --- src/sys/kern/kern_proc.c:1.173 Sat Mar 5 01:52:18 2011 +++ src/sys/kern/kern_proc.c Tue Apr 5 09:02:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.173 2011/03/05 01:52:18 matt Exp $ */ +/* $NetBSD: kern_proc.c,v 1.174 2011/04/05 09:02:23 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.173 2011/03/05 01:52:18 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.174 2011/04/05 09:02:23 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -1940,8 +1940,11 @@ goto out_locked; } - rw_enter(&p->p_reflock, RW_READER); + error = rw_tryenter(&p->p_reflock, RW_READER) ? 0 : EBUSY; mutex_exit(p->p_lock); + if (error) { + goto out_locked; + } mutex_exit(proc_lock); if (type == KERN_PROC_NARGV || type == KERN_PROC_NENV) {
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Mon Apr 4 02:46:58 UTC 2011 Modified Files: src/sys/kern: vfs_vnode.c Log Message: getcleanvnode: make static, add few comments, convert checks to asserts. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.4 src/sys/kern/vfs_vnode.c:1.5 --- src/sys/kern/vfs_vnode.c:1.4 Sat Apr 2 07:33:49 2011 +++ src/sys/kern/vfs_vnode.c Mon Apr 4 02:46:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.4 2011/04/02 07:33:49 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.5 2011/04/04 02:46:57 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.4 2011/04/02 07:33:49 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5 2011/04/04 02:46:57 rmind Exp $"); #include #include @@ -215,8 +215,11 @@ /* * getcleanvnode: grab a vnode from freelist and clean it. + * + * => Releases vnode_free_list_lock. + * => Returns referenced vnode on success. */ -vnode_t * +static vnode_t * getcleanvnode(void) { vnode_t *vp; @@ -233,16 +236,10 @@ * these vnodes should never appear on the * lists. */ - if (vp->v_usecount != 0) { - vpanic(vp, "free vnode isn't"); - } - if ((vp->v_iflag & VI_CLEAN) != 0) { - vpanic(vp, "clean vnode on freelist"); - } - if (vp->v_freelisthd != listhd) { - printf("vnode sez %p, listhd %p\n", vp->v_freelisthd, listhd); - vpanic(vp, "list head mismatch"); - } + KASSERT(vp->v_usecount == 0); + KASSERT((vp->v_iflag & VI_CLEAN) == 0); + KASSERT(vp->v_freelisthd == listhd); + if (!mutex_tryenter(&vp->v_interlock)) continue; if ((vp->v_iflag & VI_XLOCK) == 0) @@ -294,22 +291,19 @@ goto retry; } - if (vp->v_data != NULL || vp->v_uobj.uo_npages != 0 || - !TAILQ_EMPTY(&vp->v_uobj.memq)) { - vpanic(vp, "cleaned vnode isn't"); - } - if (vp->v_numoutput != 0) { - vpanic(vp, "clean vnode has pending I/O's"); - } - if ((vp->v_iflag & VI_ONWORKLST) != 0) { - vpanic(vp, "clean vnode on syncer list"); - } + KASSERT(vp->v_data == NULL); + KASSERT(vp->v_uobj.uo_npages == 0); + KASSERT(TAILQ_EMPTY(&vp->v_uobj.memq)); + KASSERT(vp->v_numoutput == 0); + KASSERT((vp->v_iflag & VI_ONWORKLST) == 0); return vp; } /* * getnewvnode: return the next vnode from the free list. + * + * => Returns referenced vnode, moved into the mount queue. */ int getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *), @@ -360,6 +354,7 @@ (TAILQ_FIRST(&vnode_hold_list) == NULL || toggle)); if (tryalloc) { + /* Allocate a new vnode. */ numvnodes++; mutex_exit(&vnode_free_list_lock); if ((vp = vnalloc(NULL)) == NULL) { @@ -370,6 +365,7 @@ } if (vp == NULL) { + /* Recycle and get vnode clean. */ vp = getcleanvnode(); if (vp == NULL) { if (mp != NULL) { @@ -396,29 +392,28 @@ KASSERT(LIST_EMPTY(&vp->v_nclist)); KASSERT(LIST_EMPTY(&vp->v_dnclist)); + /* Initialize vnode. */ vp->v_type = VNON; vp->v_tag = tag; vp->v_op = vops; - vfs_insmntque(vp, mp); - *vpp = vp; vp->v_data = NULL; - /* - * Initialize uvm_object within vnode. - */ - uobj = &vp->v_uobj; KASSERT(uobj->pgops == &uvm_vnodeops); KASSERT(uobj->uo_npages == 0); KASSERT(TAILQ_FIRST(&uobj->memq) == NULL); vp->v_size = vp->v_writesize = VSIZENOTSET; + /* Finally, move vnode into the mount queue. */ + vfs_insmntque(vp, mp); + if (mp != NULL) { if ((mp->mnt_iflag & IMNT_MPSAFE) != 0) vp->v_vflag |= VV_MPSAFE; vfs_unbusy(mp, true, NULL); } + *vpp = vp; return 0; }
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sun Apr 3 01:20:24 UTC 2011 Modified Files: src/sys/kern: vfs_mount.c Log Message: vfs_insmntque: convert check to assert. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.3 src/sys/kern/vfs_mount.c:1.4 --- src/sys/kern/vfs_mount.c:1.3 Sat Apr 2 06:48:20 2011 +++ src/sys/kern/vfs_mount.c Sun Apr 3 01:20:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.3 2011/04/02 06:48:20 rmind Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.4 2011/04/03 01:20:23 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.3 2011/04/02 06:48:20 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.4 2011/04/03 01:20:23 rmind Exp $"); #include #include @@ -376,13 +376,8 @@ { struct mount *omp; -#ifdef DIAGNOSTIC - if ((mp != NULL) && - (mp->mnt_iflag & IMNT_UNMOUNT) && - vp->v_tag != VT_VFS) { - panic("insmntque into dying filesystem"); - } -#endif + KASSERT(mp == NULL || (mp->mnt_iflag & IMNT_UNMOUNT) == 0 || + vp->v_tag == VT_VFS); mutex_enter(&mntvnode_lock); /*
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sun Apr 3 01:19:37 UTC 2011 Modified Files: src/sys/kern: vnode_if.sh src/sys/miscfs/genfs: layer_vnops.c src/sys/miscfs/umapfs: umap_vnops.c src/sys/sys: vnode.h src/sys/ufs/lfs: lfs_segment.c Log Message: - Use offsetof() in VOPARG_OFFSETOF() instead of re-implementing it. - Remove VDESC_NOMAP_VPP and VDESC_VPP_WILLRELE. - Remove VRELEL_NOINACTIVE and VRELEL_ONHEAD. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/kern/vnode_if.sh cvs rdiff -u -r1.46 -r1.47 src/sys/miscfs/genfs/layer_vnops.c cvs rdiff -u -r1.51 -r1.52 src/sys/miscfs/umapfs/umap_vnops.c cvs rdiff -u -r1.226 -r1.227 src/sys/sys/vnode.h cvs rdiff -u -r1.219 -r1.220 src/sys/ufs/lfs/lfs_segment.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vnode_if.sh diff -u src/sys/kern/vnode_if.sh:1.56 src/sys/kern/vnode_if.sh:1.57 --- src/sys/kern/vnode_if.sh:1.56 Wed Apr 14 13:58:51 2010 +++ src/sys/kern/vnode_if.sh Sun Apr 3 01:19:37 2011 @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ " -SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.56 2010/04/14 13:58:51 pooka Exp $' +SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.57 2011/04/03 01:19:37 rmind Exp $' # Script to produce VFS front-end sugar. # @@ -368,11 +368,7 @@ } else { word = "RELE"; } - if (argdir[i] ~ /OUT/) { -printf(" | VDESC_VPP_WILL%s", word); - } else { -printf(" | VDESC_VP%s_WILL%s", vpnum, word); - }; + printf(" | VDESC_VP%s_WILL%s", vpnum, word); vpnum++; } } Index: src/sys/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.46 src/sys/miscfs/genfs/layer_vnops.c:1.47 --- src/sys/miscfs/genfs/layer_vnops.c:1.46 Thu Jan 13 10:28:38 2011 +++ src/sys/miscfs/genfs/layer_vnops.c Sun Apr 3 01:19:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.46 2011/01/13 10:28:38 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.47 2011/04/03 01:19:35 rmind Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -170,7 +170,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.46 2011/01/13 10:28:38 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.47 2011/04/03 01:19:35 rmind Exp $"); #include #include @@ -311,17 +311,7 @@ * (Assumes that the lower layer always returns * a VREF'ed vpp unless it gets an error.) */ - if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET && - !(descp->vdesc_flags & VDESC_NOMAP_VPP) && - !error) { - /* - * XXX - even though some ops have vpp returned vp's, - * several ops actually vrele this before returning. - * We must avoid these ops. - * (This should go away when these ops are regularized.) - */ - if (descp->vdesc_flags & VDESC_VPP_WILLRELE) - goto out; + if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET && !error) { vppp = VOPARG_OFFSETTO(struct vnode***, descp->vdesc_vpp_offset, ap); /* @@ -338,7 +328,6 @@ **vppp = NULL; } } -out: return error; } Index: src/sys/miscfs/umapfs/umap_vnops.c diff -u src/sys/miscfs/umapfs/umap_vnops.c:1.51 src/sys/miscfs/umapfs/umap_vnops.c:1.52 --- src/sys/miscfs/umapfs/umap_vnops.c:1.51 Mon Jan 10 11:11:04 2011 +++ src/sys/miscfs/umapfs/umap_vnops.c Sun Apr 3 01:19:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: umap_vnops.c,v 1.51 2011/01/10 11:11:04 hannken Exp $ */ +/* $NetBSD: umap_vnops.c,v 1.52 2011/04/03 01:19:36 rmind Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umap_vnops.c,v 1.51 2011/01/10 11:11:04 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umap_vnops.c,v 1.52 2011/04/03 01:19:36 rmind Exp $"); #include #include @@ -269,17 +269,7 @@ * (Assumes that the lower layer always returns * a VREF'ed vpp unless it gets an error.) */ - if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET && - !(descp->vdesc_flags & VDESC_NOMAP_VPP) && - !error) { - /* - * XXX - even though some ops have vpp returned vp's, - * several ops actually vrele this before returning. - * We must avoid these ops. - * (This should go away when these ops are regularized.) - */ - if (descp->vdesc_flags & VDESC_VPP_WILLRELE) - goto out; + if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET && !error) { vppp = VOPARG_OFFSETTO(struct vnode***, descp->vdesc_vpp_offset, ap); /* @@ -297,7 +287,6 @@ } } - out: /* * Free duplicate cred structure and restore old one. */ Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.226 src/sys/sys/vnode.h:1.227 --- src/sys/sys/vnode.h:1.226 Sat Apr 2 05:07:56 2011 +++ src/sys/sys/vnode.h Sun Apr 3 01:19:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.226 2011/04/02 05:07:56 rmind Exp $ */ +/* $NetBSD: vnode.h,v 1.227 2011/04/03 01:19:36 rmind Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -433,8 +433,6 @@ #define VDESC_VP1_WI
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat Apr 2 23:05:51 UTC 2011 Modified Files: src/sys/kern: vnode_if.src Log Message: Update UCB license (3rd clause drop). To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/kern/vnode_if.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vnode_if.src diff -u src/sys/kern/vnode_if.src:1.60 src/sys/kern/vnode_if.src:1.61 --- src/sys/kern/vnode_if.src:1.60 Sun Jan 2 06:58:45 2011 +++ src/sys/kern/vnode_if.src Sat Apr 2 23:05:50 2011 @@ -1,4 +1,4 @@ -# $NetBSD: vnode_if.src,v 1.60 2011/01/02 06:58:45 dholland Exp $ +# $NetBSD: vnode_if.src,v 1.61 2011/04/02 23:05:50 rmind Exp $ # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. @@ -11,11 +11,7 @@ # 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 University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors +# 3. Neither the name of the University nor the names of its contributors #may be used to endorse or promote products derived from this software #without specific prior written permission. #
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat Apr 2 07:33:50 UTC 2011 Modified Files: src/sys/kern: vfs_vnode.c Log Message: KNF, slightly improve few comments. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.3 src/sys/kern/vfs_vnode.c:1.4 --- src/sys/kern/vfs_vnode.c:1.3 Sat Apr 2 05:07:57 2011 +++ src/sys/kern/vfs_vnode.c Sat Apr 2 07:33:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.3 2011/04/02 05:07:57 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.4 2011/04/02 07:33:49 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.3 2011/04/02 05:07:57 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.4 2011/04/02 07:33:49 rmind Exp $"); #include #include @@ -309,7 +309,7 @@ } /* - * Return the next vnode from the free list. + * getnewvnode: return the next vnode from the free list. */ int getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *), @@ -323,9 +323,8 @@ try_again: if (mp != NULL) { /* - * Mark filesystem busy while we're creating a - * vnode. If unmount is in progress, this will - * fail. + * Mark filesystem busy while we are creating a vnode. + * If unmount is in progress, this will fail. */ error = vfs_busy(mp, NULL); if (error) @@ -384,7 +383,7 @@ } tablefull("vnode", "increase kern.maxvnodes or NVNODE"); *vpp = 0; - return (ENFILE); + return ENFILE; } vp->v_iflag = 0; vp->v_vflag = 0; @@ -405,7 +404,7 @@ vp->v_data = NULL; /* - * initialize uvm_object within vnode. + * Initialize uvm_object within vnode. */ uobj = &vp->v_uobj; @@ -420,7 +419,7 @@ vfs_unbusy(mp, true, NULL); } - return (0); + return 0; } /* @@ -497,13 +496,15 @@ } /* - * Grab a particular vnode from the free list, increment its - * reference count and lock it. If the vnode lock bit is set the - * vnode is being eliminated in vgone. In that case, we can not - * grab the vnode, so the process is awakened when the transition is - * completed, and an error returned to indicate that the vnode is no - * longer usable (possibly having been changed to a new file system type). - * Called with v_interlock held. + * vget: get a particular vnode from the free list, increment its reference + * count and lock it. + * + * => Should be called with v_interlock held. + * + * If VI_XLOCK is set, the vnode is being eliminated in vgone()/vclean(). + * In that case, we cannot grab the vnode, so the process is awakened when + * the transition is completed, and an error returned to indicate that the + * vnode is no longer usable (e.g. changed to a new file system type). */ int vget(vnode_t *vp, int flags) @@ -556,7 +557,7 @@ } /* - * vput(), just unlock and vrele() + * vput: unlock and release the reference. */ void vput(vnode_t *vp) @@ -660,7 +661,7 @@ * our caller may hold other vnode locks; defer. */ defer = true; - } else { + } else { /* If we can't acquire the lock, then defer. */ vp->v_iflag &= ~VI_INACTREDO; mutex_exit(&vp->v_interlock); @@ -1029,7 +1030,7 @@ mutex_enter(&vp->v_interlock); if (vp->v_usecount != 0) { mutex_exit(&vp->v_interlock); - return (0); + return 0; } if (inter_lkp) { mutex_exit(inter_lkp); @@ -1038,7 +1039,7 @@ vp->v_usecount = 1; vclean(vp, DOCLOSE); vrelel(vp, 0); - return (1); + return 1; } /*
CVS commit: src/sys/kern
Module Name:src Committed By: rmind Date: Sat Apr 2 06:48:22 UTC 2011 Modified Files: src/sys/kern: vfs_mount.c Log Message: Merge vfs_shutdown1() and vfs_shutdown(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.2 src/sys/kern/vfs_mount.c:1.3 --- src/sys/kern/vfs_mount.c:1.2 Sat Apr 2 04:45:24 2011 +++ src/sys/kern/vfs_mount.c Sat Apr 2 06:48:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.2 2011/04/02 04:45:24 rmind Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.3 2011/04/02 06:48:20 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.2 2011/04/02 04:45:24 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.3 2011/04/02 06:48:20 rmind Exp $"); #include #include @@ -1002,39 +1002,29 @@ printf("done\n"); } -static void -vfs_shutdown1(struct lwp *l) +/* + * Sync and unmount file systems before shutting down. + */ +void +vfs_shutdown(void) { + lwp_t *l = curlwp; vfs_sync_all(l); /* - * If we've panic'd, don't make the situation potentially + * If we have paniced - do not make the situation potentially * worse by unmounting the file systems. */ - if (panicstr != NULL) + if (panicstr != NULL) { return; + } - /* Release inodes held by texts before update. */ -#ifdef notdef - vnshutdown(); -#endif /* Unmount file systems. */ vfs_unmountall(l); } /* - * Sync and unmount file systems before shutting down. - */ -void -vfs_shutdown(void) -{ - - /* XXX we're certainly not running in lwp0's context! */ - vfs_shutdown1(curlwp); -} - -/* * Print a list of supported file system types (used by vfs_mountroot) */ static void
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sat Apr 2 05:07:57 UTC 2011 Modified Files: src/sys/kern: init_sysctl.c vfs_vnode.c src/sys/sys: vnode.h Log Message: vfs_drainvnodes: drop lwp argument, remove variable name in prototype. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/sys/kern/init_sysctl.c cvs rdiff -u -r1.2 -r1.3 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.225 -r1.226 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_sysctl.c diff -u src/sys/kern/init_sysctl.c:1.179 src/sys/kern/init_sysctl.c:1.180 --- src/sys/kern/init_sysctl.c:1.179 Sat Feb 5 01:22:12 2011 +++ src/sys/kern/init_sysctl.c Sat Apr 2 05:07:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: init_sysctl.c,v 1.179 2011/02/05 01:22:12 christos Exp $ */ +/* $NetBSD: init_sysctl.c,v 1.180 2011/04/02 05:07:57 rmind Exp $ */ /*- * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.179 2011/02/05 01:22:12 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.180 2011/04/02 05:07:57 rmind Exp $"); #include "opt_sysv.h" #include "opt_compat_netbsd.h" @@ -989,7 +989,7 @@ old_vnodes = desiredvnodes; desiredvnodes = new_vnodes; if (new_vnodes < old_vnodes) { - error = vfs_drainvnodes(new_vnodes, l); + error = vfs_drainvnodes(new_vnodes); if (error) { desiredvnodes = old_vnodes; return (error); Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.2 src/sys/kern/vfs_vnode.c:1.3 --- src/sys/kern/vfs_vnode.c:1.2 Sat Apr 2 04:45:24 2011 +++ src/sys/kern/vfs_vnode.c Sat Apr 2 05:07:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.2 2011/04/02 04:45:24 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.3 2011/04/02 05:07:57 rmind Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.2 2011/04/02 04:45:24 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.3 2011/04/02 05:07:57 rmind Exp $"); #include #include @@ -1144,7 +1144,7 @@ } int -vfs_drainvnodes(long target, struct lwp *l) +vfs_drainvnodes(long target) { while (numvnodes > target) { @@ -1152,8 +1152,9 @@ mutex_enter(&vnode_free_list_lock); vp = getcleanvnode(); - if (vp == NULL) - return EBUSY; /* give up */ + if (vp == NULL) { + return EBUSY; + } ungetnewvnode(vp); } return 0; Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.225 src/sys/sys/vnode.h:1.226 --- src/sys/sys/vnode.h:1.225 Sat Apr 2 04:45:24 2011 +++ src/sys/sys/vnode.h Sat Apr 2 05:07:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.225 2011/04/02 04:45:24 rmind Exp $ */ +/* $NetBSD: vnode.h,v 1.226 2011/04/02 05:07:56 rmind Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -636,7 +636,7 @@ /* see vfssubr(9) */ void vfs_getnewfsid(struct mount *); -int vfs_drainvnodes(long target, struct lwp *); +int vfs_drainvnodes(long); void vfs_timestamp(struct timespec *); #if defined(DDB) || defined(DEBUGPRINT) void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...));
CVS commit: src
Module Name:src Committed By: rmind Date: Sat Apr 2 04:57:35 UTC 2011 Modified Files: src/external/cddl/osnet/sys/kern: vfs.c src/sys/kern: vfs_syscalls.c src/sys/sys: mount.h Log Message: Remove unused M_MOUNT. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/kern/vfs.c cvs rdiff -u -r1.420 -r1.421 src/sys/kern/vfs_syscalls.c cvs rdiff -u -r1.198 -r1.199 src/sys/sys/mount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/vfs.c diff -u src/external/cddl/osnet/sys/kern/vfs.c:1.3 src/external/cddl/osnet/sys/kern/vfs.c:1.4 --- src/external/cddl/osnet/sys/kern/vfs.c:1.3 Thu Jun 24 13:03:05 2010 +++ src/external/cddl/osnet/sys/kern/vfs.c Sat Apr 2 04:57:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs.c,v 1.3 2010/06/24 13:03:05 hannken Exp $ */ +/* $NetBSD: vfs.c,v 1.4 2011/04/02 04:57:35 rmind Exp $ */ /*- * Copyright (c) 2006-2007 Pawel Jakub Dawidek @@ -39,8 +39,6 @@ #include #include -MALLOC_DECLARE(M_MOUNT); - int lookupname(char *dirname, enum uio_seg seg, vnode_t **dirvpp, vnode_t **compvpp) { Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.420 src/sys/kern/vfs_syscalls.c:1.421 --- src/sys/kern/vfs_syscalls.c:1.420 Sat Apr 2 04:28:56 2011 +++ src/sys/kern/vfs_syscalls.c Sat Apr 2 04:57:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.420 2011/04/02 04:28:56 rmind Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.421 2011/04/02 04:57:35 rmind Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.420 2011/04/02 04:28:56 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.421 2011/04/02 04:57:35 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -112,8 +112,6 @@ #include #include -MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount struct"); - static int change_flags(struct vnode *, u_long, struct lwp *); static int change_mode(struct vnode *, int, struct lwp *l); static int change_owner(struct vnode *, uid_t, gid_t, struct lwp *, int); Index: src/sys/sys/mount.h diff -u src/sys/sys/mount.h:1.198 src/sys/sys/mount.h:1.199 --- src/sys/sys/mount.h:1.198 Sat Apr 2 04:28:57 2011 +++ src/sys/sys/mount.h Sat Apr 2 04:57:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: mount.h,v 1.198 2011/04/02 04:28:57 rmind Exp $ */ +/* $NetBSD: mount.h,v 1.199 2011/04/02 04:57:35 rmind Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -375,8 +375,6 @@ }; #ifdef _KERNEL -#include -MALLOC_DECLARE(M_MOUNT); /* * exported VFS interface (see vfssubr(9))
CVS commit: src/sys
Module Name:src Committed By: rmind Date: Sat Apr 2 04:45:25 UTC 2011 Modified Files: src/sys/kern: vfs_mount.c vfs_vnode.c src/sys/sys: vnode.h Log Message: - Move vrele_list flush notify code into vrele_flush() routine. - Make some structures static. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/kern/vfs_mount.c src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.224 -r1.225 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.1 src/sys/kern/vfs_mount.c:1.2 --- src/sys/kern/vfs_mount.c:1.1 Sat Apr 2 04:28:56 2011 +++ src/sys/kern/vfs_mount.c Sat Apr 2 04:45:24 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: vfs_mount.c,v 1.1 2011/04/02 04:28:56 rmind Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.2 2011/04/02 04:45:24 rmind Exp $ */ /*- - * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.1 2011/04/02 04:28:56 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.2 2011/04/02 04:45:24 rmind Exp $"); #include #include @@ -436,31 +436,20 @@ return vunmark(mvp); } -extern kmutex_t vrele_lock; -extern kcondvar_t vrele_cv; -extern int vrele_pending; -extern int vrele_gen; - int vflush(struct mount *mp, vnode_t *skipvp, int flags) { vnode_t *vp, *mvp; - int busy = 0, when = 0, gen; + int busy = 0, when = 0; - /* - * First, flush out any vnode references from vrele_list. - */ - mutex_enter(&vrele_lock); - gen = vrele_gen; - while (vrele_pending && gen == vrele_gen) { - cv_broadcast(&vrele_cv); - cv_wait(&vrele_cv, &vrele_lock); - } - mutex_exit(&vrele_lock); + /* First, flush out any vnode references from vrele_list. */ + vrele_flush(); /* Allocate a marker vnode. */ - if ((mvp = vnalloc(mp)) == NULL) - return (ENOMEM); + mvp = vnalloc(mp); + if (mvp == NULL) { + return ENOMEM; + } /* * NOTE: not using the TAILQ_FOREACH here since in this loop vgone() Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.1 src/sys/kern/vfs_vnode.c:1.2 --- src/sys/kern/vfs_vnode.c:1.1 Sat Apr 2 04:28:57 2011 +++ src/sys/kern/vfs_vnode.c Sat Apr 2 04:45:24 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: vfs_vnode.c,v 1.1 2011/04/02 04:28:57 rmind Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.2 2011/04/02 04:45:24 rmind Exp $ */ /*- - * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.1 2011/04/02 04:28:57 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.2 2011/04/02 04:45:24 rmind Exp $"); #include #include @@ -124,11 +124,11 @@ static vnodelst_t vnode_hold_list; static vnodelst_t vrele_list; -/* static */ kmutex_t vrele_lock; -/* static */ kcondvar_t vrele_cv; +static kmutex_t vrele_lock; +static kcondvar_t vrele_cv; static lwp_t * vrele_lwp; -/* static */ int vrele_pending; -/* static */ int vrele_gen; +static int vrele_pending; +static int vrele_gen; static vnode_t * getcleanvnode(void); static void vrele_thread(void *); @@ -840,6 +840,20 @@ } } +void +vrele_flush(void) +{ + int gen; + + mutex_enter(&vrele_lock); + gen = vrele_gen; + while (vrele_pending && gen == vrele_gen) { + cv_broadcast(&vrele_cv); + cv_wait(&vrele_cv, &vrele_lock); + } + mutex_exit(&vrele_lock); +} + /* * Vnode reference, where a reference is already held by some other * object (for example, a file structure). Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.224 src/sys/sys/vnode.h:1.225 --- src/sys/sys/vnode.h:1.224 Sat Apr 2 04:28:57 2011 +++ src/sys/sys/vnode.h Sat Apr 2 04:45:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.224 2011/04/02 04:28:57 rmind Exp $ */ +/* $NetBSD: vnode.h,v 1.225 2011/04/02 04:45:24 rmind Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -581,6 +581,7 @@ int vrecycle(struct vnode *, kmutex_t *, struct lwp *); void vrele(struct vnode *); void vrele_async(struct vnode *); +void vrele_flush(void); int vtruncbuf(struct vnode *, daddr_t, bool, int); void vwakeup(struct buf *); void vwait(struct vnode *, int);
CVS commit: src/sys/uvm
Module Name:src Committed By: rmind Date: Fri Apr 1 00:47:12 UTC 2011 Modified Files: src/sys/uvm: uvm_page.c Log Message: uvm_pageidlezero: use try-lock to not occupy uvm_fpageqlock, which may be on demand by other CPUs. Reduces lock contention in some workloads on many CPU (8+) systems. Tested by tls@. To generate a diff of this commit: cvs rdiff -u -r1.171 -r1.172 src/sys/uvm/uvm_page.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_page.c diff -u src/sys/uvm/uvm_page.c:1.171 src/sys/uvm/uvm_page.c:1.172 --- src/sys/uvm/uvm_page.c:1.171 Wed Feb 2 17:53:42 2011 +++ src/sys/uvm/uvm_page.c Fri Apr 1 00:47:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_page.c,v 1.171 2011/02/02 17:53:42 chuck Exp $ */ +/* $NetBSD: uvm_page.c,v 1.172 2011/04/01 00:47:11 rmind Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.171 2011/02/02 17:53:42 chuck Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.172 2011/04/01 00:47:11 rmind Exp $"); #include "opt_ddb.h" #include "opt_uvmhist.h" @@ -1716,6 +1716,7 @@ struct pgfreelist *pgfl, *gpgfl; struct uvm_cpu *ucpu; int free_list, firstbucket, nextbucket; + bool lcont = false; ucpu = curcpu()->ci_data.cpu_uvm; if (!ucpu->page_idle_zero || @@ -1723,7 +1724,10 @@ ucpu->page_idle_zero = false; return; } - mutex_enter(&uvm_fpageqlock); + if (!mutex_tryenter(&uvm_fpageqlock)) { + /* Contention: let other CPUs to use the lock. */ + return; + } firstbucket = ucpu->page_free_nextcolor; nextbucket = firstbucket; do { @@ -1735,7 +1739,7 @@ gpgfl = &uvm.page_free[free_list]; while ((pg = LIST_FIRST(&pgfl->pgfl_buckets[ nextbucket].pgfl_queues[PGFL_UNKNOWN])) != NULL) { -if (sched_curcpu_runnable_p()) { +if (lcont || sched_curcpu_runnable_p()) { goto quit; } LIST_REMOVE(pg, pageq.list); /* global list */ @@ -1773,7 +1777,12 @@ #endif /* PMAP_PAGEIDLEZERO */ pg->flags |= PG_ZERO; -mutex_spin_enter(&uvm_fpageqlock); +if (!mutex_tryenter(&uvm_fpageqlock)) { + lcont = true; + mutex_spin_enter(&uvm_fpageqlock); +} else { + lcont = false; +} pg->pqflags = PQ_FREE; LIST_INSERT_HEAD(&gpgfl->pgfl_buckets[ nextbucket].pgfl_queues[PGFL_ZEROS],