Load the struct rusage text, data, and stack fields from the vmspace struct.
Before they were all 0. We update them when we call getrusage() or on process exit() so that the children rusage is accounted for.
This commit is contained in:
parent
61768d92a9
commit
e0983e96df
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_exit.c,v 1.270 2017/11/07 19:44:04 christos Exp $ */
|
||||
/* $NetBSD: kern_exit.c,v 1.271 2018/05/07 21:03:45 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -67,7 +67,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.270 2017/11/07 19:44:04 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.271 2018/05/07 21:03:45 christos Exp $");
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
#include "opt_dtrace.h"
|
||||
@ -325,6 +325,7 @@ exit1(struct lwp *l, int exitcode, int signo)
|
||||
* we run at this moment, nothing runs in userland
|
||||
* anymore.
|
||||
*/
|
||||
ruspace(p); /* Update our vm resource use */
|
||||
uvm_proc_exit(p);
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_resource.c,v 1.177 2018/04/08 11:43:01 mlelstv Exp $ */
|
||||
/* $NetBSD: kern_resource.c,v 1.178 2018/05/07 21:03:45 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.177 2018/04/08 11:43:01 mlelstv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.178 2018/05/07 21:03:45 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -577,6 +577,7 @@ getrusage1(struct proc *p, int who, struct rusage *ru) {
|
||||
switch (who) {
|
||||
case RUSAGE_SELF:
|
||||
mutex_enter(p->p_lock);
|
||||
ruspace(p);
|
||||
memcpy(ru, &p->p_stats->p_ru, sizeof(*ru));
|
||||
calcru(p, &ru->ru_utime, &ru->ru_stime, NULL, NULL);
|
||||
rulwps(p, ru);
|
||||
@ -594,6 +595,17 @@ getrusage1(struct proc *p, int who, struct rusage *ru) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ruspace(struct proc *p)
|
||||
{
|
||||
struct vmspace *vm = p->p_vmspace;
|
||||
struct rusage *ru = &p->p_stats->p_ru;
|
||||
|
||||
ru->ru_ixrss = vm->vm_tsize << (PAGE_SHIFT - 10);
|
||||
ru->ru_idrss = vm->vm_dsize << (PAGE_SHIFT - 10);
|
||||
ru->ru_isrss = vm->vm_ssize << (PAGE_SHIFT - 10);
|
||||
}
|
||||
|
||||
void
|
||||
ruadd(struct rusage *ru, struct rusage *ru2)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: resourcevar.h,v 1.56 2015/10/18 00:28:15 jmcneill Exp $ */
|
||||
/* $NetBSD: resourcevar.h,v 1.57 2018/05/07 21:03:45 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -115,6 +115,7 @@ void lim_setcorename(struct proc *, char *, size_t);
|
||||
void lim_free(struct plimit *);
|
||||
|
||||
void resource_init(void);
|
||||
void ruspace(struct proc *);
|
||||
void ruadd(struct rusage *, struct rusage *);
|
||||
void rulwps(proc_t *, struct rusage *);
|
||||
struct pstats *pstatscopy(struct pstats *);
|
||||
|
Loading…
Reference in New Issue
Block a user