From owner-svn-src-head@FreeBSD.ORG Sun Oct 18 12:55:40 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 484E8106566C; Sun, 18 Oct 2009 12:55:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3774B8FC13; Sun, 18 Oct 2009 12:55:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9ICte8U069288; Sun, 18 Oct 2009 12:55:40 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9ICtelB069286; Sun, 18 Oct 2009 12:55:40 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200910181255.n9ICtelB069286@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 18 Oct 2009 12:55:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198201 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2009 12:55:40 -0000 Author: kib Date: Sun Oct 18 12:55:39 2009 New Revision: 198201 URL: http://svn.freebsd.org/changeset/base/198201 Log: Remove spurious call to priv_check(PRIV_VM_SWAP_NOQUOTA). Call priv_check(PRIV_VM_SWAP_NORLIMIT) only when per-uid limit is actually exceed. Both changes aim at calling priv_check(9) only for the cases when privilege is actually exercised by the process. Reported and tested by: rwatson Reviewed by: alc MFC after: 3 days Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Sun Oct 18 12:48:23 2009 (r198200) +++ head/sys/vm/swap_pager.c Sun Oct 18 12:55:39 2009 (r198201) @@ -176,7 +176,7 @@ swap_reserve(vm_ooffset_t incr) int swap_reserve_by_uid(vm_ooffset_t incr, struct uidinfo *uip) { - vm_ooffset_t r, s, max; + vm_ooffset_t r, s; int res, error; static int curfail; static struct timeval lastfail; @@ -185,7 +185,6 @@ swap_reserve_by_uid(vm_ooffset_t incr, s panic("swap_reserve: & PAGE_MASK"); res = 0; - error = priv_check(curthread, PRIV_VM_SWAP_NOQUOTA); mtx_lock(&sw_dev_mtx); r = swap_reserved + incr; if (overcommit & SWAP_RESERVE_ALLOW_NONWIRED) { @@ -204,10 +203,9 @@ swap_reserve_by_uid(vm_ooffset_t incr, s if (res) { PROC_LOCK(curproc); UIDINFO_VMSIZE_LOCK(uip); - error = priv_check(curthread, PRIV_VM_SWAP_NORLIMIT); - max = (error != 0) ? lim_cur(curproc, RLIMIT_SWAP) : 0; - if (max != 0 && uip->ui_vmsize + incr > max && - (overcommit & SWAP_RESERVE_RLIMIT_ON) != 0) + if ((overcommit & SWAP_RESERVE_RLIMIT_ON) != 0 && + uip->ui_vmsize + incr > lim_cur(curproc, RLIMIT_SWAP) && + priv_check(curthread, PRIV_VM_SWAP_NORLIMIT)) res = 0; else uip->ui_vmsize += incr;