From 5855d1ccdc16c2b2e30ba2c13654715587719e9f Mon Sep 17 00:00:00 2001 From: Andrey Zonov Date: Wed, 14 May 2014 14:01:13 -0700 Subject: [PATCH 2/2] Lock-less limits --- sys/compat/linux/linux_misc.c | 9 +++++---- sys/compat/svr4/svr4_misc.c | 21 +++++++++++---------- sys/compat/svr4/svr4_resource.c | 17 +++++++++-------- sys/dev/drm2/i915/i915_gem.c | 7 ++++--- sys/fs/fdescfs/fdesc_vfsops.c | 5 +++-- sys/i386/ibcs2/ibcs2_misc.c | 25 +++++++++++++------------ sys/kern/imgact_elf.c | 9 ++++++--- sys/kern/kern_descrip.c | 5 +++-- sys/kern/kern_proc.c | 5 +++-- sys/kern/kern_resource.c | 23 ++++++++++++++++------- sys/kern/subr_uio.c | 5 +++-- sys/kern/sysv_shm.c | 5 +++-- sys/kern/uipc_sockbuf.c | 5 +++-- sys/kern/vfs_vnops.c | 7 +++++-- sys/sys/resourcevar.h | 2 ++ sys/vm/vm_map.c | 9 +++++---- sys/vm/vm_mmap.c | 24 ++++++++++++------------ sys/vm/vm_unix.c | 5 +++-- 18 files changed, 109 insertions(+), 79 deletions(-) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index ff5e8a2..f6d3836 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1238,9 +1239,9 @@ linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args) if (which == -1) return (EINVAL); - PROC_LOCK(p); + psz_read_lock() lim_rlimit(p, which, &bsd_rlim); - PROC_UNLOCK(p); + psz_read_unlock() #ifdef COMPAT_LINUX32 rlim.rlim_cur = (unsigned int)bsd_rlim.rlim_cur; @@ -1281,9 +1282,9 @@ linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args) if (which == -1) return (EINVAL); - PROC_LOCK(p); + psz_read_lock(); lim_rlimit(p, which, &bsd_rlim); - PROC_UNLOCK(p); + psz_read_unlock(); rlim.rlim_cur = (l_ulong)bsd_rlim.rlim_cur; rlim.rlim_max = (l_ulong)bsd_rlim.rlim_max; diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 0db5453..26678bb 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -893,9 +894,9 @@ svr4_sys_ulimit(td, uap) switch (uap->cmd) { case SVR4_GFILLIM: - PROC_LOCK(td->td_proc); + psz_read_lock(); *retval = lim_cur(td->td_proc, RLIMIT_FSIZE) / 512; - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -905,17 +906,17 @@ svr4_sys_ulimit(td, uap) struct rlimit krl; krl.rlim_cur = uap->newlimit * 512; - PROC_LOCK(td->td_proc); + psz_read_lock(); krl.rlim_max = lim_max(td->td_proc, RLIMIT_FSIZE); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); error = kern_setrlimit(td, RLIMIT_FSIZE, &krl); if (error) return error; - PROC_LOCK(td->td_proc); + psz_read_lock(); *retval = lim_cur(td->td_proc, RLIMIT_FSIZE); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -926,9 +927,9 @@ svr4_sys_ulimit(td, uap) struct vmspace *vm = td->td_proc->p_vmspace; register_t r; - PROC_LOCK(td->td_proc); + psz_read_lock(); r = lim_cur(td->td_proc, RLIMIT_DATA); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); if (r == -1) r = 0x7fffffff; @@ -940,9 +941,9 @@ svr4_sys_ulimit(td, uap) } case SVR4_GDESLIM: - PROC_LOCK(td->td_proc); + psz_read_lock(); *retval = lim_cur(td->td_proc, RLIMIT_NOFILE); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); if (*retval == -1) *retval = 0x7fffffff; return 0; diff --git a/sys/compat/svr4/svr4_resource.c b/sys/compat/svr4/svr4_resource.c index efa0bcf..bb58677 100644 --- a/sys/compat/svr4/svr4_resource.c +++ b/sys/compat/svr4/svr4_resource.c @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -130,9 +131,9 @@ svr4_sys_getrlimit(td, uap) if (rl == -1) return EINVAL; - PROC_LOCK(td->td_proc); + psz_read_lock(); lim_rlimit(td->td_proc, rl, &blim); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); /* * Our infinity, is their maxfiles. @@ -181,9 +182,9 @@ svr4_sys_setrlimit(td, uap) if ((error = copyin(uap->rlp, &slim, sizeof(slim))) != 0) return error; - PROC_LOCK(td->td_proc); + psz_read_lock(); lim_rlimit(td->td_proc, rl, &curlim); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); /* * if the limit is SVR4_RLIM_INFINITY, then we set it to our @@ -228,9 +229,9 @@ svr4_sys_getrlimit64(td, uap) if (rl == -1) return EINVAL; - PROC_LOCK(td->td_proc); + psz_read_lock(); lim_rlimit(td->td_proc, rl, &blim); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); /* * Our infinity, is their maxfiles. @@ -279,9 +280,9 @@ svr4_sys_setrlimit64(td, uap) if ((error = copyin(uap->rlp, &slim, sizeof(slim))) != 0) return error; - PROC_LOCK(td->td_proc); + psz_read_lock(); lim_rlimit(td->td_proc, rl, &curlim); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); /* * if the limit is SVR4_RLIM64_INFINITY, then we set it to our diff --git a/sys/dev/drm2/i915/i915_gem.c b/sys/dev/drm2/i915/i915_gem.c index a3acb60..348e508 100644 --- a/sys/dev/drm2/i915/i915_gem.c +++ b/sys/dev/drm2/i915/i915_gem.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1280,13 +1281,13 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, p = curproc; map = &p->p_vmspace->vm_map; size = round_page(args->size); - PROC_LOCK(p); + psz_read_lock(); if (map->size + size > lim_cur(p, RLIMIT_VMEM)) { - PROC_UNLOCK(p); + psz_read_unlock(); error = ENOMEM; goto out; } - PROC_UNLOCK(p); + psz_read_unlock(); addr = 0; vm_object_reference(obj->vm_obj); diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c index cb5e3c0..d8ef916 100644 --- a/sys/fs/fdescfs/fdesc_vfsops.c +++ b/sys/fs/fdescfs/fdesc_vfsops.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -194,9 +195,9 @@ fdesc_statfs(mp, sbp) * limit is ever reduced below the current number * of open files... ] */ - PROC_LOCK(td->td_proc); + psz_read_lock(); lim = lim_cur(td->td_proc, RLIMIT_NOFILE); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); fdp = td->td_proc->p_fd; FILEDESC_SLOCK(fdp); limit = racct_get_limit(td->td_proc, RACCT_NOFILE); diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index 0eeb6de..ff0210f 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -108,30 +109,30 @@ ibcs2_ulimit(td, uap) p = td->td_proc; switch (uap->cmd) { case IBCS2_GETFSIZE: - PROC_LOCK(p); + psz_read_lock(); td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE); - PROC_UNLOCK(p); + psz_read_unlock(); if (td->td_retval[0] == -1) td->td_retval[0] = 0x7fffffff; return 0; case IBCS2_SETFSIZE: - PROC_LOCK(p); + psz_read_lock(); rl.rlim_max = lim_max(p, RLIMIT_FSIZE); - PROC_UNLOCK(p); + psz_read_unlock(); rl.rlim_cur = uap->newlimit; error = kern_setrlimit(td, RLIMIT_FSIZE, &rl); if (!error) { - PROC_LOCK(p); + psz_read_lock(); td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE); - PROC_UNLOCK(p); + psz_read_unlock(); } else { DPRINTF(("failed ")); } return error; case IBCS2_GETPSIZE: - PROC_LOCK(p); + psz_read_lock(); td->td_retval[0] = lim_cur(p, RLIMIT_RSS); /* XXX */ - PROC_UNLOCK(p); + psz_read_unlock(); return 0; case IBCS2_GETDTABLESIZE: uap->cmd = IBCS2_SC_OPEN_MAX; @@ -798,9 +799,9 @@ ibcs2_sysconf(td, uap) break; case IBCS2_SC_CHILD_MAX: - PROC_LOCK(p); + psz_read_lock(); td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NPROC); - PROC_UNLOCK(p); + psz_read_unlock(); return 0; case IBCS2_SC_CLK_TCK: @@ -812,9 +813,9 @@ ibcs2_sysconf(td, uap) break; case IBCS2_SC_OPEN_MAX: - PROC_LOCK(p); + psz_read_lock(); td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NOFILE); - PROC_UNLOCK(p); + psz_read_unlock(); return 0; case IBCS2_SC_JOB_CONTROL: diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 591094e..ab96f1e 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -907,6 +908,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; vmspace->vm_dsize = data_size >> PAGE_SHIFT; vmspace->vm_daddr = (caddr_t)(uintptr_t)data_addr; + PROC_UNLOCK(imgp->proc); /* * We load the dynamic linker where a userland call @@ -914,9 +916,10 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) * calculation is that it leaves room for the heap to grow to * its maximum allowed size. */ + psz_read_lock(); addr = round_page((vm_offset_t)vmspace->vm_daddr + lim_max(imgp->proc, RLIMIT_DATA)); - PROC_UNLOCK(imgp->proc); + psz_read_unlock(); imgp->entry_addr = entry; @@ -1889,10 +1892,10 @@ note_procstat_rlimit(void *arg, struct sbuf *sb, size_t *sizep) KASSERT(*sizep == size, ("invalid size")); structsize = sizeof(rlim); sbuf_bcat(sb, &structsize, sizeof(structsize)); - PROC_LOCK(p); + psz_read_lock(); for (i = 0; i < RLIM_NLIMITS; i++) lim_rlimit(p, i, &rlim[i]); - PROC_UNLOCK(p); + psz_read_unlock(); sbuf_bcat(sb, rlim, sizeof(rlim)); } *sizep = size; diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 88b26af..7dedceb 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -777,9 +778,9 @@ getmaxfd(struct proc *p) { int maxfd; - PROC_LOCK(p); + psz_read_lock(); maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc); - PROC_UNLOCK(p); + psz_read_unlock(); return (maxfd); } diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index e38d011..0065c78 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2498,9 +2499,9 @@ sysctl_kern_proc_rlimit(SYSCTL_HANDLER_ARGS) * Retrieve limit. */ if (req->oldptr != NULL) { - PROC_LOCK(p); + psz_read_lock(); lim_rlimit(p, which, &rlim); - PROC_UNLOCK(p); + psz_read_unlock(); } error = SYSCTL_OUT(req, &rlim, sizeof(rlim)); if (error != 0) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index f4914fa..cfcf1c0 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -576,9 +577,9 @@ ogetrlimit(td, uap) if (uap->which >= RLIM_NLIMITS) return (EINVAL); p = td->td_proc; - PROC_LOCK(p); + psz_read_lock(); lim_rlimit(p, uap->which, &rl); - PROC_UNLOCK(p); + psz_read_unlock(); /* * XXX would be more correct to convert only RLIM_INFINITY to the @@ -752,7 +753,7 @@ kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which, p->p_sysent->sv_fixlimit(limp, which); *alimp = *limp; if (newlim != NULL) - p->p_limit = newlim; + psz_update_ptr(&p->p_limit, newlim); PROC_UNLOCK(p); if (newlim != NULL) lim_free(oldlim); @@ -808,9 +809,9 @@ sys_getrlimit(td, uap) if (uap->which >= RLIM_NLIMITS) return (EINVAL); p = td->td_proc; - PROC_LOCK(p); + psz_read_lock(); lim_rlimit(p, uap->which, &rlim); - PROC_UNLOCK(p); + psz_read_unlock(); error = copyout(&rlim, uap->rlp, sizeof(struct rlimit)); return (error); } @@ -1163,6 +1164,14 @@ lim_fork(struct proc *p1, struct proc *p2) lim_cb, p2, C_PREL(1)); } +static void +lim_free_cb(struct psz_cb *cb) +{ + struct plimit *limp = psz2struct(cb, struct plimit, pl_psz_cb); + + free(limp, M_PLIMIT); +} + void lim_free(limp) struct plimit *limp; @@ -1170,7 +1179,7 @@ lim_free(limp) KASSERT(limp->pl_refcnt > 0, ("plimit refcnt underflow")); if (refcount_release(&limp->pl_refcnt)) - free((void *)limp, M_PLIMIT); + psz_enqueue(lim_free_cb, &limp->pl_psz_cb); } /* @@ -1220,7 +1229,7 @@ void lim_rlimit(struct proc *p, int which, struct rlimit *rlp) { - PROC_LOCK_ASSERT(p, MA_OWNED); + /* PROC_LOCK_ASSERT(p, MA_OWNED); */ KASSERT(which >= 0 && which < RLIM_NLIMITS, ("request for invalid resource limit")); *rlp = p->p_limit->pl_rlimit[which]; diff --git a/sys/kern/subr_uio.c b/sys/kern/subr_uio.c index 13c678d..eb0f781 100644 --- a/sys/kern/subr_uio.c +++ b/sys/kern/subr_uio.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -404,10 +405,10 @@ copyout_map(struct thread *td, vm_offset_t *addr, size_t sz) /* * Map somewhere after heap in process memory. */ - PROC_LOCK(td->td_proc); + psz_read_lock(); *addr = round_page((vm_offset_t)vms->vm_daddr + lim_max(td->td_proc, RLIMIT_DATA)); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); /* round size up to page boundry */ size = (vm_size_t)round_page(sz); diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 4144d94..178a48a 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -403,10 +404,10 @@ kern_shmat(td, shmid, shmaddr, shmflg) * This is just a hint to vm_map_find() about where to * put it. */ - PROC_LOCK(p); + psz_read_lock(); attach_va = round_page((vm_offset_t)p->p_vmspace->vm_daddr + lim_max(p, RLIMIT_DATA)); - PROC_UNLOCK(p); + psz_read_unlock(); } vm_object_reference(shmseg->object); diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index d804d9a..703a611 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -303,9 +304,9 @@ sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so, if (cc > sb_max_adj) return (0); if (td != NULL) { - PROC_LOCK(td->td_proc); + psz_read_lock(); sbsize_limit = lim_cur(td->td_proc, RLIMIT_SBSIZE); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); } else sbsize_limit = RLIM_INFINITY; if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc, diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 7d5cea0..5a4b154 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1996,14 +1997,16 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, if (vp->v_type != VREG || td == NULL) return (0); - PROC_LOCK(td->td_proc); + psz_read_lock(); if ((uoff_t)uio->uio_offset + uio->uio_resid > lim_cur(td->td_proc, RLIMIT_FSIZE)) { + psz_read_unlock(); + PROC_LOCK(td->td_proc); kern_psignal(td->td_proc, SIGXFSZ); PROC_UNLOCK(td->td_proc); return (EFBIG); } - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); return (0); } diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index 1a35a9e..4593a64 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -33,6 +33,7 @@ #ifndef _SYS_RESOURCEVAR_H_ #define _SYS_RESOURCEVAR_H_ +#include #include #include #ifdef _KERNEL @@ -76,6 +77,7 @@ struct pstats { */ struct plimit { struct rlimit pl_rlimit[RLIM_NLIMITS]; + struct psz_cb pl_psz_cb; int pl_refcnt; /* number of references */ }; diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 35f2147..c7b75a3 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3359,10 +3360,10 @@ vm_map_stack(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, growsize = sgrowsiz; init_ssize = (max_ssize < growsize) ? max_ssize : growsize; vm_map_lock(map); - PROC_LOCK(curproc); + psz_read_lock(); lmemlim = lim_cur(curproc, RLIMIT_MEMLOCK); vmemlim = lim_cur(curproc, RLIMIT_VMEM); - PROC_UNLOCK(curproc); + psz_read_unlock(); if (!old_mlock && map->flags & MAP_WIREFUTURE) { if (ptoa(pmap_wired_count(map->pmap)) + init_ssize > lmemlim) { rv = KERN_NO_SPACE; @@ -3493,11 +3494,11 @@ vm_map_growstack(struct proc *p, vm_offset_t addr) #endif Retry: - PROC_LOCK(p); + psz_read_lock(); lmemlim = lim_cur(p, RLIMIT_MEMLOCK); stacklim = lim_cur(p, RLIMIT_STACK); vmemlim = lim_cur(p, RLIMIT_VMEM); - PROC_UNLOCK(p); + psz_read_unlock(); vm_map_lock_read(map); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 0fc5bb4..7118d34 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -305,14 +306,13 @@ sys_mmap(td, uap) * There should really be a pmap call to determine a reasonable * location. */ - PROC_LOCK(td->td_proc); + psz_read_lock(); + rlim_t lim = lim_max(td->td_proc, RLIMIT_DATA); + psz_read_unlock(); if (addr == 0 || (addr >= round_page((vm_offset_t)vms->vm_taddr) && - addr < round_page((vm_offset_t)vms->vm_daddr + - lim_max(td->td_proc, RLIMIT_DATA)))) - addr = round_page((vm_offset_t)vms->vm_daddr + - lim_max(td->td_proc, RLIMIT_DATA)); - PROC_UNLOCK(td->td_proc); + addr < round_page((vm_offset_t)vms->vm_daddr + lim))) + addr = round_page((vm_offset_t)vms->vm_daddr + lim); } if (flags & MAP_ANON) { /* @@ -1083,13 +1083,13 @@ vm_mlock(struct proc *proc, struct ucred *cred, const void *addr0, size_t len) if (npages > vm_page_max_wired) return (ENOMEM); map = &proc->p_vmspace->vm_map; - PROC_LOCK(proc); nsize = ptoa(npages + pmap_wired_count(map->pmap)); + psz_read_lock(); if (nsize > lim_cur(proc, RLIMIT_MEMLOCK)) { - PROC_UNLOCK(proc); + psz_read_unlock(); return (ENOMEM); } - PROC_UNLOCK(proc); + psz_read_unlock(); if (npages + vm_cnt.v_wire_count > vm_page_max_wired) return (EAGAIN); #ifdef RACCT @@ -1142,12 +1142,12 @@ sys_mlockall(td, uap) * a hard resource limit, return ENOMEM. */ if (!old_mlock && uap->how & MCL_CURRENT) { - PROC_LOCK(td->td_proc); + psz_read_lock(); if (map->size > lim_cur(td->td_proc, RLIMIT_MEMLOCK)) { - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); return (ENOMEM); } - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); } #ifdef RACCT PROC_LOCK(td->td_proc); diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index edb6ecc..1af7788 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -83,11 +84,11 @@ sys_obreak(td, uap) int error = 0; boolean_t do_map_wirefuture; - PROC_LOCK(td->td_proc); + psz_read_lock(); datalim = lim_cur(td->td_proc, RLIMIT_DATA); lmemlim = lim_cur(td->td_proc, RLIMIT_MEMLOCK); vmemlim = lim_cur(td->td_proc, RLIMIT_VMEM); - PROC_UNLOCK(td->td_proc); + psz_read_unlock(); do_map_wirefuture = FALSE; new = round_page((vm_offset_t)uap->nsize); -- 1.9.0