diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2017-02-14 13:54:05 +0000 |
---|---|---|
committer | Andriy Gapon <avg@FreeBSD.org> | 2017-02-14 13:54:05 +0000 |
commit | 937c1b0757fec1c460e886ad897ed90872bb26cf (patch) | |
tree | 53902ccc486860c7ca8e53623d214c4411075299 /sys/kern | |
parent | 00ef17befe9ae904871c1fc31f4fb9fd61b0d32d (diff) | |
download | src-937c1b0757fec1c460e886ad897ed90872bb26cf.tar.gz src-937c1b0757fec1c460e886ad897ed90872bb26cf.zip |
try to fix RACCT_RSS accounting
There could be a race between the vm daemon setting RACCT_RSS based on
the vm space and vmspace_exit (called from exit1) resetting RACCT_RSS to
zero. In that case we can get a zombie process with non-zero RACCT_RSS.
If the process is jailed, that may break accounting for the jail.
There could be other consequences.
Fix this race in the vm daemon by updating RACCT_RSS only when a process
is in the normal state. Also, make accounting a little bit more
accurate by refreshing the page resident count after calling
vm_pageout_map_deactivate_pages().
Finally, add an assert that the RSS is zero when a process is reaped.
PR: 210315
Reviewed by: trasz
Differential Revision: https://reviews.freebsd.org/D9464
Notes
Notes:
svn path=/head/; revision=313730
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_racct.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 03677663d806..5dbeae995635 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -1010,10 +1010,13 @@ racct_proc_exit(struct proc *p) racct_set_locked(p, RACCT_CPU, runtime, 0); racct_add_cred_locked(p->p_ucred, RACCT_PCTCPU, pct); + KASSERT(p->p_racct->r_resources[RACCT_RSS] == 0, + ("process reaped with %ju allocated for RSS\n", + p->p_racct->r_resources[RACCT_RSS])); for (i = 0; i <= RACCT_MAX; i++) { if (p->p_racct->r_resources[i] == 0) continue; - if (!RACCT_IS_RECLAIMABLE(i)) + if (!RACCT_IS_RECLAIMABLE(i)) continue; racct_set_locked(p, i, 0, 0); } |