Date: Thu, 23 Dec 2010 17:38:50 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 187163 for review Message-ID: <201012231738.oBNHcoen088421@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@187163?ac=10 Change 187163 by trasz@trasz_victim on 2010/12/23 17:37:47 Rework swap usage accounting. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#16 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#16 (text+ko) ==== @@ -192,6 +192,9 @@ if (incr & PAGE_MASK) panic("swap_reserve: & PAGE_MASK"); + if (rusage_add(curproc, RUSAGE_SWAP, incr)) + return (0); + res = 0; mtx_lock(&sw_dev_mtx); r = swap_reserved + incr; @@ -211,12 +214,7 @@ if (res) { PROC_LOCK(curproc); UIDINFO_VMSIZE_LOCK(uip); - /* - * XXX: What if rusage_add() succeeds, and lim_cur() check fails? - */ - if ( - rusage_add(curproc, RUSAGE_SWAP, incr) && - (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; @@ -235,6 +233,9 @@ curproc->p_pid, uip->ui_uid, incr); } + if (!res) + rusage_sub(curproc, RUSAGE_SWAP, incr); + return (res); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012231738.oBNHcoen088421>