Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2012 08:54:20 +0000
From:      rudot@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r240292 - soc2012/rudot/sys/kern
Message-ID:  <20120812085420.8ADEF106566B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rudot
Date: Sun Aug 12 08:54:19 2012
New Revision: 240292
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240292

Log:
  decaying pcpu - complete

Modified:
  soc2012/rudot/sys/kern/kern_racct.c

Modified: soc2012/rudot/sys/kern/kern_racct.c
==============================================================================
--- soc2012/rudot/sys/kern/kern_racct.c	Sun Aug 12 07:09:25 2012	(r240291)
+++ soc2012/rudot/sys/kern/kern_racct.c	Sun Aug 12 08:54:19 2012	(r240292)
@@ -308,9 +308,9 @@
 	fixpt_t p_pctcpu;
 	struct thread *td;
 
-	swtime = (ticks - p->p_swtick) / hz;
-	if ((swtime == 0) || ((p->p_flag & P_INMEM) == 0))
+	if ((p->p_flag & P_INMEM) == 0)
 		return (0);
+	swtime = (ticks - p->p_swtick) / hz;
 	if (swtime < RACCT_PCPU_SECS) {
 		/*
 		 * For short-lived processes, the sched_pctcpu() returns small
@@ -479,6 +479,12 @@
 		    ("racct_alloc_resource: usage < 0"));
 		racct->r_resources[resource] = 0;
 	}
+	
+	if (resource == RACCT_PCTCPU) {
+		if (racct->r_resources[RACCT_PCTCPU] > 100) {
+			racct->r_resources[RACCT_PCTCPU] = 100;
+		}
+	}
 }
 
 static int
@@ -608,16 +614,16 @@
 	}
 	available = INT64_MAX;
 
-#ifdef RCTL
-	available = rctl_pcpu_available(p);
-#endif
 	racct_alloc_resource(p->p_racct, resource, diff_proc);
 	if (diff_cred > 0)
 		racct_add_cred_locked(p->p_ucred, resource, diff_cred);
 	else if (diff_cred < 0)
 		racct_sub_cred_locked(p->p_ucred, resource, -diff_cred);
 
-	return (available <= diff_proc);
+#ifdef RCTL
+	available = rctl_pcpu_available(p);
+#endif
+	return (available <= 0);
 }
 
 static int



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