From owner-p4-projects@FreeBSD.ORG Wed Jul 28 08:21:39 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 682A81065DAC; Wed, 28 Jul 2010 08:21:37 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3847B1065D14 for ; Wed, 28 Jul 2010 08:21:36 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5EDFA8FC21 for ; Wed, 28 Jul 2010 08:21:36 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id o6S8LaSg009157 for ; Wed, 28 Jul 2010 08:21:36 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id o6S8LaSo009155 for perforce@freebsd.org; Wed, 28 Jul 2010 08:21:36 GMT (envelope-from trasz@freebsd.org) Date: Wed, 28 Jul 2010 08:21:36 GMT Message-Id: <201007280821.o6S8LaSo009155@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 181469 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jul 2010 08:21:39 -0000 http://p4web.freebsd.org/@@181469?ac=10 Change 181469 by trasz@trasz_victim on 2010/07/26 17:24:54 Implement RUSAGE_CORE. Affected files ... .. //depot/projects/soc2009/trasz_limits/TODO#18 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/imgact_elf.c#14 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#21 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_sig.c#15 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/TODO#18 (text+ko) ==== @@ -5,6 +5,7 @@ - maximum file size (RUSAGE_FSIZE), in megabytes - number of processes (RUSAGE_NPROC) - virtual memory usage (address space limit) (RUSAGE_VMEM), in megabytes + - maximum core size (RUSAGE_CORE), in megabytes (core, as in ELF program state dump) Limits to do: @@ -16,7 +17,6 @@ - swap usage (RUSAGE_SWAP), in megabytes - number of file descriptors (RUSAGE_NOFILE) - amount of memory consumed by socket buffers (RUSAGE_SBSIZE), in megabytes - - maximum core size (RUSAGE_CORE), in megabytes (core, as in ELF program state dump) Milestone 2: ==== //depot/projects/soc2009/trasz_limits/sys/kern/imgact_elf.c#14 (text+ko) ==== @@ -35,6 +35,7 @@ #include "opt_core.h" #include +#include #include #include #include @@ -1103,6 +1104,12 @@ hdrsize = 0; __elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count); +#ifdef CONTAINERS + if (rusage_add(td->td_proc, RUSAGE_CORE, hdrsize + seginfo.size)) { + error = EFAULT; + goto done; + } +#endif if (hdrsize + seginfo.size >= limit) { error = EFAULT; goto done; ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#21 (text+ko) ==== @@ -62,6 +62,7 @@ switch (resource) { case RUSAGE_CPU: + case RUSAGE_CORE: return (0); default: return (1); @@ -74,6 +75,7 @@ switch (resource) { case RUSAGE_CPU: + case RUSAGE_CORE: case RUSAGE_NPROC: return (0); default: @@ -391,10 +393,8 @@ #ifdef HRL if (diff > 0) { error = hrl_enforce_proc(p, resource, diff); - if (error) { - mtx_unlock(&container_lock); + if (error) return (error); - } } #endif container_alloc_resource(&p->p_container, resource, diff); ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_sig.c#15 (text+ko) ==== @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -3209,7 +3210,12 @@ */ limit = (off_t)lim_cur(p, RLIMIT_CORE); PROC_UNLOCK(p); +#ifdef CONTAINERS + if (limit == 0 && rusage_add(td->td_proc, RUSAGE_CORE, 1) == 0) { + rusage_sub(td->td_proc, RUSAGE_CORE, 1); +#else if (limit == 0) { +#endif #ifdef AUDIT audit_proc_coredump(td, name, EFBIG); #endif