Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Aug 2010 21:00:28 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 183090 for review
Message-ID:  <201008302100.o7UL0SWe007353@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@183090?ac=10

Change 183090 by trasz@trasz_victim on 2010/08/30 21:00:15

	RUSAGE_SWAP.  It's slow and ugly, but will have to do for now.  It
	will be redone after tackling SysV shm.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#7 edit
.. //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#20 edit
.. //depot/projects/soc2009/trasz_limits/sys/vm/vm_pageout.c#14 edit

Differences ...

==== //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#7 (text+ko) ====

@@ -75,6 +75,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
+#include <sys/container.h>
 #include <sys/kernel.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
@@ -207,8 +208,14 @@
 	if (res) {
 		PROC_LOCK(curproc);
 		UIDINFO_VMSIZE_LOCK(uip);
-		if ((overcommit & SWAP_RESERVE_RLIMIT_ON) != 0 &&
+		if (
+#ifdef CONTAINERS
+		    rusage_add(curproc, RUSAGE_SWAP, incr) &&
+#endif
+#ifndef HRL
+		    (overcommit & SWAP_RESERVE_RLIMIT_ON) != 0 &&
 		    uip->ui_vmsize + incr > lim_cur(curproc, RLIMIT_SWAP) &&
+#endif
 		    priv_check(curthread, PRIV_VM_SWAP_NORLIMIT))
 			res = 0;
 		else
@@ -251,6 +258,9 @@
 {
 	struct uidinfo *uip;
 
+#ifdef CONTAINERS
+	rusage_sub(curproc, RUSAGE_SWAP, decr);
+#endif
 	PROC_LOCK(curproc);
 	uip = curthread->td_ucred->cr_ruidinfo;
 	swap_release_by_uid(decr, uip);

==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#20 (text+ko) ====

@@ -418,6 +418,7 @@
 	rusage_set(p, RUSAGE_RSS, 0);
 	rusage_set(p, RUSAGE_MEMLOCK, 0);
 	rusage_set(p, RUSAGE_VMEM, 0);
+	rusage_set(p, RUSAGE_SWAP, 0);
 #endif
 }
 

==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_pageout.c#14 (text+ko) ====

@@ -1709,6 +1709,18 @@
 				size = vmspace_resident_count(vm);
 				rusage_set(p, RUSAGE_RSS, IDX_TO_OFF(size));
 			}
+
+			/*
+			 * This is the ugly (and temporary, hopefully) part
+			 * of dealing with RUSAGE_SWAP.  Basically, we increase
+			 * swap counters in the proper place, and decrease them
+			 * here.  Doing it properly will require adding either
+			 * proc or ucred pointer to vm objects; before I do that,
+			 * I want to get a better feeling on how the memory
+			 * management works.  In other words, it's post-shm task.
+			 */
+			size = vmspace_swap_count(vm);
+			rusage_set(p, RUSAGE_SWAP, IDX_TO_OFF(size));
 #endif
 			vmspace_free(vm);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008302100.o7UL0SWe007353>