aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_acct.c
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2007-06-01 01:12:45 +0000
committerJeff Roberson <jeff@FreeBSD.org>2007-06-01 01:12:45 +0000
commit1c4bcd050a4f7163d68f608db860aef5fad81d6c (patch)
tree9c09dcc76185c3dc30b048a5f2eb972f3bb8a849 /sys/kern/kern_acct.c
parent9163fee71f130ea1488b39a785bf5d08075936f5 (diff)
downloadsrc-1c4bcd050a4f7163d68f608db860aef5fad81d6c.tar.gz
src-1c4bcd050a4f7163d68f608db860aef5fad81d6c.zip
- Move rusage from being per-process in struct pstats to per-thread in
td_ru. This removes the requirement for per-process synchronization in statclock() and mi_switch(). This was previously supported by sched_lock which is going away. All modifications to rusage are now done in the context of the owning thread. reads proceed without locks. - Aggregate exiting threads rusage in thread_exit() such that the exiting thread's rusage is not lost. - Provide a new routine, rufetch() to fetch an aggregate of all rusage structures from all threads in a process. This routine must be used in any place requiring a rusage from a process prior to it's exit. The exited process's rusage is still available via p_ru. - Aggregate tick statistics only on demand via rufetch() or when a thread exits. Tick statistics are kept in the thread and protected by sched_lock until it exits. Initial patch by: attilio Reviewed by: attilio, bde (some objections), arch (mostly silent)
Notes
Notes: svn path=/head/; revision=170174
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r--sys/kern/kern_acct.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index f1b0b8f2a8df..69a171afa84f 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -337,7 +337,7 @@ acct_process(struct thread *td)
struct timeval ut, st, tmp;
struct plimit *newlim, *oldlim;
struct proc *p;
- struct rusage *r;
+ struct rusage ru;
int t, ret, vfslocked;
/*
@@ -370,6 +370,7 @@ acct_process(struct thread *td)
bcopy(p->p_comm, acct.ac_comm, sizeof acct.ac_comm);
/* (2) The amount of user and system time that was used */
+ rufetch(p, &ru);
calcru(p, &ut, &st);
acct.ac_utime = encode_timeval(ut);
acct.ac_stime = encode_timeval(st);
@@ -383,19 +384,18 @@ acct_process(struct thread *td)
acct.ac_etime = encode_timeval(tmp);
/* (4) The average amount of memory used */
- r = &p->p_stats->p_ru;
tmp = ut;
timevaladd(&tmp, &st);
/* Convert tmp (i.e. u + s) into hz units to match ru_i*. */
t = tmp.tv_sec * hz + tmp.tv_usec / tick;
if (t)
- acct.ac_mem = encode_long((r->ru_ixrss + r->ru_idrss +
- + r->ru_isrss) / t);
+ acct.ac_mem = encode_long((ru.ru_ixrss + ru.ru_idrss +
+ + ru.ru_isrss) / t);
else
acct.ac_mem = 0;
/* (5) The number of disk I/O operations done */
- acct.ac_io = encode_long(r->ru_inblock + r->ru_oublock);
+ acct.ac_io = encode_long(ru.ru_inblock + ru.ru_oublock);
/* (6) The UID and GID of the process */
acct.ac_uid = p->p_ucred->cr_ruid;