From 512dfaa60ec59661b8e5334d886db1901c2f9faa Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 6 May 2014 11:50:13 +0000 Subject: [PATCH] Include directly instead of relying on it being pulled by and turn uvm_total() into a private function. The preferred way to get memory stats is through the VM_UVMEXP sysctl(3) since VM_METER is just a wrapper on top of it. In the kernel, use `uvmexp' directly instead of uvm_total(). This change does not remove from to give some more time to port maintainers to fix their ports. ok guenther@ as part of a larger diff. --- sys/arch/amd64/amd64/fpu.c | 3 +-- sys/kern/kern_fork.c | 3 ++- sys/miscfs/procfs/procfs_vfsops.c | 9 +++------ sys/uvm/uvm_extern.h | 4 +--- sys/uvm/uvm_meter.c | 9 ++++----- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c index fbc781a987d..0882c4b2726 100644 --- a/sys/arch/amd64/amd64/fpu.c +++ b/sys/arch/amd64/amd64/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.28 2014/03/29 18:09:28 guenther Exp $ */ +/* $OpenBSD: fpu.c,v 1.29 2014/05/06 11:50:13 mpi Exp $ */ /* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /*- @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index b2ff5552d91..adbabb331d9 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.165 2014/05/04 05:03:26 guenther Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.166 2014/05/06 11:50:14 mpi Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/miscfs/procfs/procfs_vfsops.c b/sys/miscfs/procfs/procfs_vfsops.c index c1d2e3022df..21c008b9e7b 100644 --- a/sys/miscfs/procfs/procfs_vfsops.c +++ b/sys/miscfs/procfs/procfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_vfsops.c,v 1.29 2013/04/15 15:32:19 jsing Exp $ */ +/* $OpenBSD: procfs_vfsops.c,v 1.30 2014/05/06 11:50:14 mpi Exp $ */ /* $NetBSD: procfs_vfsops.c,v 1.25 1996/02/09 22:40:53 christos Exp $ */ /* @@ -169,13 +169,10 @@ procfs_start(struct mount *mp, int flags, struct proc *p) int procfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) { - struct vmtotal vmtotals; - - uvm_total(&vmtotals); sbp->f_bsize = PAGE_SIZE; sbp->f_iosize = PAGE_SIZE; - sbp->f_blocks = vmtotals.t_vm; - sbp->f_bfree = vmtotals.t_vm - vmtotals.t_avm; + sbp->f_blocks = uvmexp.npages - uvmexp.free + uvmexp.swpginuse; + sbp->f_bfree = uvmexp.npages - uvmexp.free - uvmexp.active; sbp->f_bavail = 0; sbp->f_files = maxprocess; /* approx */ sbp->f_ffree = maxprocess - nprocesses; /* approx */ diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index d6eae9c297f..4dd4ee8bb54 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.113 2014/05/03 22:44:36 guenther Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.114 2014/05/06 11:50:14 mpi Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -484,7 +484,6 @@ struct loadavg; struct proc; struct pmap; struct vmspace; -struct vmtotal; struct mount; struct vnode; struct core; @@ -678,7 +677,6 @@ void uvmspace_share(struct proc *, struct proc *); void uvm_meter(void); int uvm_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); -void uvm_total(struct vmtotal *); /* uvm_mmap.c */ int uvm_mmap(vm_map_t, vaddr_t *, vsize_t, diff --git a/sys/uvm/uvm_meter.c b/sys/uvm/uvm_meter.c index a4ea174aa40..2c0f5c49aec 100644 --- a/sys/uvm/uvm_meter.c +++ b/sys/uvm/uvm_meter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_meter.c,v 1.31 2014/04/13 23:14:15 tedu Exp $ */ +/* $OpenBSD: uvm_meter.c,v 1.32 2014/05/06 11:50:14 mpi Exp $ */ /* $NetBSD: uvm_meter.c,v 1.21 2001/07/14 06:36:03 matt Exp $ */ /* @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include @@ -79,10 +79,9 @@ static fixpt_t cexp[3] = { 0.9944598480048967 * FSCALE, /* exp(-1/180) */ }; -/* - * prototypes - */ + static void uvm_loadav(struct loadavg *); +void uvm_total(struct vmtotal *); /* * uvm_meter: calculate load average and wake up the swapper (if needed) -- 2.20.1