Date: Sun, 29 Aug 2010 20:53:02 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 183048 for review Message-ID: <201008292053.o7TKr2dI074891@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@183048?ac=10 Change 183048 by trasz@trasz_victim on 2010/08/29 20:52:43 RUSAGE_NTHR. Affected files ... .. //depot/projects/soc2009/trasz_limits/TODO#28 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#27 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#25 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#20 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#92 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_thr.c#7 edit .. //depot/projects/soc2009/trasz_limits/sys/sys/container.h#12 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/TODO#28 (text+ko) ==== @@ -12,12 +12,12 @@ - number of file descriptors (RUSAGE_NOFILE) - swap usage (RUSAGE_SWAP), in megabytes - amount of memory consumed by socket buffers (RUSAGE_SBSIZE), in megabytes + - number of kernel-visible threads (RUSAGE_NTHR) Limits to do: Milestone 2: - - number of kernel-visible threads (RUSAGE_NTHR) - number of vnodes (RUSAGE_NVNODE) - number of sockets (RUSAGE_NSOCK) - number of queued SysV messages (RUSAGE_MSGQQUEUED) ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#27 (text+ko) ==== @@ -91,6 +91,7 @@ case RUSAGE_CORE: case RUSAGE_MEMLOCK: case RUSAGE_NPROC: + case RUSAGE_NTHR: return (0); default: return (1); ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#25 (text+ko) ==== @@ -181,6 +181,9 @@ } KASSERT(p->p_numthreads == 1, ("exit1: proc %p exiting with %d threads", p, p->p_numthreads)); +#ifdef CONTAINERS + rusage_sub(p, RUSAGE_NTHR, 1); +#endif /* * Wakeup anyone in procfs' PIOCWAIT. They should have a hold * on our vmspace, so we should block below until they have ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#20 (text+ko) ==== @@ -365,6 +365,11 @@ error = EAGAIN; goto fail; } + error = rusage_add(newproc, RUSAGE_NTHR, 1); + if (error) { + error = EAGAIN; + goto fail; + } #endif /* ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#92 (text+ko) ==== @@ -103,6 +103,16 @@ { "vmem", RUSAGE_VMEM }, { "npts", RUSAGE_NPTS }, { "swap", RUSAGE_SWAP }, + { "nthr", RUSAGE_NTHR }, + { "nvnode", RUSAGE_NVNODE }, + { "nsock", RUSAGE_NSOCK }, + { "msgqqueued", RUSAGE_MSGQQUEUED }, + { "msgqsize", RUSAGE_MSGQSIZE }, + { "nmsgq", RUSAGE_NMSGQ }, + { "nsem", RUSAGE_NSEM }, + { "nsemop", RUSAGE_NSEMOP }, + { "nshm", RUSAGE_NSHM }, + { "shmsize", RUSAGE_SHMSIZE }, { NULL, -1 }}; static struct dict actionnames[] = { ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_thr.c#7 (text+ko) ==== @@ -29,6 +29,7 @@ #include "opt_compat.h" #include "opt_posix.h" +#include <sys/container.h> #include <sys/param.h> #include <sys/kernel.h> #include <sys/lock.h> @@ -174,11 +175,17 @@ return (EINVAL); } } +#ifdef CONTAINERS + if (rusage_add(p, RUSAGE_NTHR, 1)) + return (EPROCLIM); +#endif /* Initialize our td */ newtd = thread_alloc(0); - if (newtd == NULL) - return (ENOMEM); + if (newtd == NULL) { + error = ENOMEM; + goto fail; + } /* * Try the copyout as soon as we allocate the td so we don't @@ -194,7 +201,8 @@ (parent_tid != NULL && suword_lwpid(parent_tid, newtd->td_tid))) { thread_free(newtd); - return (EFAULT); + error = EFAULT; + goto fail; } bzero(&newtd->td_startzero, @@ -211,7 +219,7 @@ if (error != 0) { thread_free(newtd); crfree(td->td_ucred); - return (error); + goto fail; } } else { /* Set up our machine context. */ @@ -224,7 +232,7 @@ if (error != 0) { thread_free(newtd); crfree(td->td_ucred); - return (error); + goto fail; } } @@ -253,6 +261,12 @@ thread_unlock(newtd); return (0); + +fail: +#ifdef CONTAINERS + rusage_sub(p, RUSAGE_NTHR, 1); +#endif + return (error); } int @@ -296,6 +310,9 @@ } PROC_SUNLOCK(p); PROC_UNLOCK(p); +#ifdef CONTAINERS + rusage_sub(p, RUSAGE_NTHR, 1); +#endif return (0); } ==== //depot/projects/soc2009/trasz_limits/sys/sys/container.h#12 (text+ko) ==== @@ -65,7 +65,17 @@ #define RUSAGE_VMEM 10 #define RUSAGE_NPTS 11 #define RUSAGE_SWAP 12 -#define RUSAGE_MAX RUSAGE_SWAP +#define RUSAGE_NTHR 13 +#define RUSAGE_NVNODE 14 +#define RUSAGE_NSOCK 15 +#define RUSAGE_MSGQQUEUED 16 +#define RUSAGE_MSGQSIZE 17 +#define RUSAGE_NMSGQ 18 +#define RUSAGE_NSEM 19 +#define RUSAGE_NSEMOP 20 +#define RUSAGE_NSHM 21 +#define RUSAGE_SHMSIZE 22 +#define RUSAGE_MAX RUSAGE_SHMSIZE /* * 'container' defines resource consumption for a particular
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008292053.o7TKr2dI074891>
