From owner-p4-projects@FreeBSD.ORG Sun Aug 29 20:53:03 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2011A10656AD; Sun, 29 Aug 2010 20:53:03 +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 D6BF9106564A for ; Sun, 29 Aug 2010 20:53:02 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id C469E8FC14 for ; Sun, 29 Aug 2010 20:53:02 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id o7TKr2lY074894 for ; Sun, 29 Aug 2010 20:53:02 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id o7TKr2dI074891 for perforce@freebsd.org; Sun, 29 Aug 2010 20:53:02 GMT (envelope-from trasz@freebsd.org) Date: Sun, 29 Aug 2010 20:53:02 GMT Message-Id: <201008292053.o7TKr2dI074891@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.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 183048 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: Sun, 29 Aug 2010 20:53:03 -0000 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 #include #include #include @@ -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