From owner-svn-soc-all@FreeBSD.ORG Fri Sep 7 05:49:02 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 7D0F3106566B for ; Fri, 7 Sep 2012 05:49:01 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 07 Sep 2012 05:49:01 +0000 Date: Fri, 07 Sep 2012 05:49:01 +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: <20120907054901.7D0F3106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r241351 - 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: Fri, 07 Sep 2012 05:49:02 -0000 Author: rudot Date: Fri Sep 7 05:49:00 2012 New Revision: 241351 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=241351 Log: use RACCT_IN_MILLIONS for pcpu resource Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Fri Sep 7 02:38:07 2012 (r241350) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Sep 7 05:49:00 2012 (r241351) @@ -162,7 +162,8 @@ RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, [RACCT_WALLCLOCK] = RACCT_IN_MILLIONS, - [RACCT_PCTCPU] = RACCT_DECAYING | RACCT_DENIABLE }; + [RACCT_PCTCPU] = + RACCT_DECAYING | RACCT_DENIABLE | RACCT_IN_MILLIONS }; static const fixpt_t RACCT_DECAY_FACTOR = 0.3 * FSCALE; @@ -299,7 +300,7 @@ * of the ccpu variable. In ULE it is defined to be zero which saves us some * work. */ -static u_int +static uint64_t racct_getpcpu(struct proc *p, u_int pcpu) { u_int swtime; @@ -365,10 +366,11 @@ #ifdef SCHED_4BSD if (swtime <= CCPU_EXP_MAX) - return ((100 * p_pctcpu) / (FSCALE - ccpu_exp[swtime])); + return ((100 * (uint64_t)p_pctcpu * 1000000) / + (FSCALE - ccpu_exp[swtime])); #endif - return ((100 * p_pctcpu) / FSCALE); + return ((100 * (uint64_t)p_pctcpu * 1000000) / FSCALE); } static void @@ -498,8 +500,8 @@ * 100% cpu usage. So we set a boundary here to 100%. */ if ((resource == RACCT_PCTCPU) && - (racct->r_resources[RACCT_PCTCPU] > 100)) - racct->r_resources[RACCT_PCTCPU] = 100; + (racct->r_resources[RACCT_PCTCPU] > 100 * 1000000)) + racct->r_resources[RACCT_PCTCPU] = 100 * 1000000; } static int @@ -908,7 +910,7 @@ int i; uint64_t runtime; struct timeval wallclock; - u_int pct_estimate, pct; + uint64_t pct_estimate, pct; PROC_LOCK(p); /* @@ -923,7 +925,7 @@ #endif microuptime(&wallclock); timevalsub(&wallclock, &p->p_stats->p_start); - pct_estimate = (runtime * 100) / + pct_estimate = (1000000 * runtime * 100) / ((uint64_t)wallclock.tv_sec * 1000000 + wallclock.tv_usec); pct = racct_getpcpu(p, pct_estimate); @@ -1102,7 +1104,7 @@ struct proc *p; struct timeval wallclock; uint64_t runtime; - u_int pct, pct_estimate; + uint64_t pct, pct_estimate; int over_limits; for (;;) { @@ -1138,7 +1140,7 @@ runtime = p->p_prev_runtime; #endif p->p_prev_runtime = runtime; - pct_estimate = (runtime * 100) / + pct_estimate = (1000000 * runtime * 100) / ((uint64_t)wallclock.tv_sec * 1000000 + wallclock.tv_usec); pct = racct_getpcpu(p, pct_estimate);