Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Sep 2012 05:49:01 +0000
From:      rudot@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r241351 - soc2012/rudot/sys/kern
Message-ID:  <20120907054901.7D0F3106566B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120907054901.7D0F3106566B>