From owner-svn-soc-all@FreeBSD.ORG Wed Jun 13 16:42:49 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id B2D4D106564A for ; Wed, 13 Jun 2012 16:42:47 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 13 Jun 2012 16:42:47 +0000 Date: Wed, 13 Jun 2012 16:42:47 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120613164247.B2D4D106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r237615 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 16:42:49 -0000 Author: rudot Date: Wed Jun 13 16:42:47 2012 New Revision: 237615 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=237615 Log: per-user %cpu limits. First version - I let the code already present in the racct infrastructure do the work. Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Wed Jun 13 16:19:20 2012 (r237614) +++ soc2012/rudot/sys/kern/kern_racct.c Wed Jun 13 16:42:47 2012 (r237615) @@ -922,7 +922,7 @@ struct timeval wallclock; uint64_t runtime; u_int pct; - uint64_t limit; + int error; for (;;) { sx_slock(&allproc_lock); @@ -947,16 +947,10 @@ runtime = p->p_prev_runtime; #endif p->p_prev_runtime = runtime; - limit = racct_get_limit(p, RACCT_PCTCPU); pct = racct_getpcpu(p); mtx_lock(&racct_lock); - /* - * I use _force_ here because we always want to have - * the real value in the RACCT_PCTCPU resource - * regardless of the limits set. - */ - racct_set_force_locked(p, RACCT_PCTCPU, pct); - if (pct >= limit) { + error = racct_set_locked(p, RACCT_PCTCPU, pct); + if (error) { racct_proc_disable(p); } else if (racct_proc_disabled(p)) { racct_proc_enable(p);