summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2007-06-09 18:56:11 +0000
committerattilio <attilio@FreeBSD.org>2007-06-09 18:56:11 +0000
commitc105658c88a2c2055d81325040ae51c145564d21 (patch)
tree5f11084a1ca726fd09afccfce5eb4c0055b06e97 /sys/kern/kern_resource.c
parent35719cd36d18abec5f4a2477062825a4a0fe6ead (diff)
downloadFreeBSD-src-c105658c88a2c2055d81325040ae51c145564d21.zip
FreeBSD-src-c105658c88a2c2055d81325040ae51c145564d21.tar.gz
The current rusage code show peculiar problems:
- Unsafeness on ruadd() in thread_exit() - Unatomicity of thread_exiit() in the exit1() operations This patch addresses these problems allocating p_fd as part of the process and modifying the way it is accessed. A small chunk of this patch, resolves a race about p_state in kern_wait(), since we have to be sure about the zombif-ing process. Submitted by: jeff Approved by: jeff (mentor)
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index a0e39b9..5982066 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1039,19 +1039,16 @@ rufetch(struct proc *p, struct rusage *ru)
{
struct thread *td;
- memset(ru, 0, sizeof(*ru));
PROC_SLOCK(p);
- if (p->p_ru == NULL) {
- KASSERT(p->p_numthreads > 0,
- ("rufetch: No threads or ru in proc %p", p));
+ *ru = p->p_ru;
+ if (p->p_numthreads > 0) {
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
ruxagg(&p->p_rux, td);
thread_unlock(td);
rucollect(ru, &td->td_ru);
}
- } else
- *ru = *p->p_ru;
+ }
PROC_SUNLOCK(p);
}
OpenPOWER on IntegriCloud