diff options
author | jeff <jeff@FreeBSD.org> | 2007-06-01 01:12:45 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2007-06-01 01:12:45 +0000 |
commit | a7a8bac81f171b93c4770f51c694b15c84a2f9f8 (patch) | |
tree | 9c09dcc76185c3dc30b048a5f2eb972f3bb8a849 /sys/kern/kern_acct.c | |
parent | 062ed7352f59fb6db93a3f51ca6e64ec0cefca22 (diff) | |
download | FreeBSD-src-a7a8bac81f171b93c4770f51c694b15c84a2f9f8.zip FreeBSD-src-a7a8bac81f171b93c4770f51c694b15c84a2f9f8.tar.gz |
- 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)
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r-- | sys/kern/kern_acct.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index f1b0b8f..69a171a 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; |