PERFORCE change 187163 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Dec 23 17:38:51 UTC 2010


http://p4web.freebsd.org/@@187163?ac=10

Change 187163 by trasz at 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);
 }
 


More information about the p4-projects mailing list