Date: Fri, 10 Aug 2012 17:48:10 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r240250 - soc2012/rudot/sys/kern Message-ID: <20120810174810.99EAB106566B@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rudot Date: Fri Aug 10 17:48:09 2012 New Revision: 240250 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240250 Log: add %cpu resource to ucred containers on racct_proc_exit() Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 16:26:15 2012 (r240249) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Aug 10 17:48:09 2012 (r240250) @@ -159,7 +159,7 @@ RACCT_IN_MILLIONS, [RACCT_PCTCPU] = RACCT_DECAYING | RACCT_DENIABLE }; -static const fixpt_t RACCT_DECAY_FACTOR = 0.9 * FSCALE; +static const fixpt_t RACCT_DECAY_FACTOR = 0.3 * FSCALE; #ifdef SCHED_4BSD /* @@ -475,7 +475,7 @@ racct->r_resources[resource] += amount; if (racct->r_resources[resource] < 0) { - KASSERT(RACCT_IS_SLOPPY(resource), + KASSERT(RACCT_IS_SLOPPY(resource) | RACCT_IS_DECAYING(resource), ("racct_alloc_resource: usage < 0")); racct->r_resources[resource] = 0; } @@ -888,6 +888,8 @@ { int i; uint64_t runtime; + struct timeval wallclock; + u_int pct_estimate, pct; PROC_LOCK(p); /* @@ -900,8 +902,16 @@ if (runtime < p->p_prev_runtime) runtime = p->p_prev_runtime; #endif + microuptime(&wallclock); + timevalsub(&wallclock, &p->p_stats->p_start); + pct_estimate = (runtime * 100) / + ((uint64_t)wallclock.tv_sec * 1000000 + + wallclock.tv_usec); + pct = racct_getpcpu(p, pct_estimate); + mtx_lock(&racct_lock); racct_set_locked(p, RACCT_CPU, runtime); + racct_add_cred_locked(p->p_ucred, RACCT_PCTCPU, pct_estimate); for (i = 0; i <= RACCT_MAX; i++) { if (p->p_racct->r_resources[i] == 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120810174810.99EAB106566B>