Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Load the struct rusage text, data, and stack fields from...
details: https://anonhg.NetBSD.org/src/rev/d4730bcbf05e
branches: trunk
changeset: 832332:d4730bcbf05e
user: christos <christos%NetBSD.org@localhost>
date: Mon May 07 21:03:45 2018 +0000
description:
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.
diffstat:
sys/kern/kern_exit.c | 5 +++--
sys/kern/kern_resource.c | 16 ++++++++++++++--
sys/sys/resourcevar.h | 3 ++-
3 files changed, 19 insertions(+), 5 deletions(-)
diffs (87 lines):
diff -r 5d275a771a9c -r d4730bcbf05e sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c Mon May 07 21:00:14 2018 +0000
+++ b/sys/kern/kern_exit.c Mon May 07 21:03:45 2018 +0000
@@ -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 @@
* we run at this moment, nothing runs in userland
* anymore.
*/
+ ruspace(p); /* Update our vm resource use */
uvm_proc_exit(p);
/*
diff -r 5d275a771a9c -r d4730bcbf05e sys/kern/kern_resource.c
--- a/sys/kern/kern_resource.c Mon May 07 21:00:14 2018 +0000
+++ b/sys/kern/kern_resource.c Mon May 07 21:03:45 2018 +0000
@@ -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 @@
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);
@@ -595,6 +596,17 @@
}
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)
{
long *ip, *ip2;
diff -r 5d275a771a9c -r d4730bcbf05e sys/sys/resourcevar.h
--- a/sys/sys/resourcevar.h Mon May 07 21:00:14 2018 +0000
+++ b/sys/sys/resourcevar.h Mon May 07 21:03:45 2018 +0000
@@ -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_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 *);
Home |
Main Index |
Thread Index |
Old Index