Date: Sat, 7 Aug 2010 16:31:26 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 182034 for review Message-ID: <201008071631.o77GVQ3P013908@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@182034?ac=10 Change 182034 by trasz@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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008071631.o77GVQ3P013908>