PERFORCE change 182034 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Sat Aug 7 16:31:27 UTC 2010
http://p4web.freebsd.org/@@182034?ac=10
Change 182034 by trasz at trasz_victim on 2010/08/07 16:31:22
RUSAGE_STACK.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/TODO#24 edit
.. //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#19 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/TODO#24 (text+ko) ====
@@ -8,12 +8,12 @@
- maximum core size (RUSAGE_CORE), in megabytes (core, as in ELF program state dump)
- locked memory usage (RUSAGE_MEMLOCK), in megabytes
- resident set size (physical memory usage) (RUSAGE_RSS), in megabytes
+ - stack size (RUSAGE_STACK), in megabytes,
Limits to do:
Milestone 1:
- - stack size (RUSAGE_STACK), in megabytes,
- swap usage (RUSAGE_SWAP), in megabytes
- number of file descriptors (RUSAGE_NOFILE)
- amount of memory consumed by socket buffers (RUSAGE_SBSIZE), in megabytes
==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#19 (text+ko) ====
@@ -3219,6 +3219,10 @@
rlim_t stacklim, vmemlim;
int is_procstack, rv;
struct uidinfo *uip;
+#ifdef CONTAINERS
+ uint64_t limit;
+ int error;
+#endif
Retry:
PROC_LOCK(p);
@@ -3317,6 +3321,13 @@
vm_map_unlock_read(map);
return (KERN_NO_SPACE);
}
+#ifdef CONTAINERS
+ if (is_procstack &&
+ rusage_set(p, RUSAGE_STACK, ctob(vm->vm_ssize) + grow_amount)) {
+ vm_map_unlock_read(map);
+ return (KERN_NO_SPACE);
+ }
+#endif
/* Round up the grow amount modulo SGROWSIZ */
grow_amount = roundup (grow_amount, sgrowsiz);
@@ -3325,12 +3336,25 @@
if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > stacklim)) {
grow_amount = stacklim - ctob(vm->vm_ssize);
}
+#ifdef CONTAINERS
+ limit = rusage_get_limit(p, RUSAGE_STACK);
+ if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > limit))
+ grow_amount = limit - ctob(vm->vm_ssize);
+#endif
/* If we would blow our VMEM resource limit, no go */
if (map->size + grow_amount > vmemlim) {
vm_map_unlock_read(map);
- return (KERN_NO_SPACE);
+ rv = KERN_NO_SPACE;
+ goto out;
+ }
+#ifdef CONTAINERS
+ if (rusage_set(p, RUSAGE_VMEM, map->size + grow_amount)) {
+ vm_map_unlock_read(map);
+ rv = KERN_NO_SPACE;
+ goto out;
}
+#endif
if (vm_map_lock_upgrade(map))
goto Retry;
@@ -3425,6 +3449,16 @@
: VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
}
+out:
+#ifdef CONTAINERS
+ if (rv != KERN_SUCCESS) {
+ error = rusage_set(p, RUSAGE_VMEM, map->size);
+ KASSERT(error == 0, ("decreasing RUSAGE_VMEM failed"));
+ error = rusage_set(p, RUSAGE_STACK, ctob(vm->vm_ssize));
+ KASSERT(error == 0, ("decreasing RUSAGE_STACK failed"));
+ }
+#endif
+
return (rv);
}
More information about the p4-projects
mailing list