socsvn commit: r240250 - soc2012/rudot/sys/kern
rudot at FreeBSD.org
rudot at FreeBSD.org
Fri Aug 10 17:48:11 UTC 2012
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)
More information about the svn-soc-all
mailing list