summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2014-05-06 11:50:13 +0000
committermpi <mpi@openbsd.org>2014-05-06 11:50:13 +0000
commit512dfaa60ec59661b8e5334d886db1901c2f9faa (patch)
tree56c3abc3a74ed3e4f91d6ecdc32bb6a587a39596
parentExplicitly zero out the ibufs before releasing the memory to make sure (diff)
downloadwireguard-openbsd-512dfaa60ec59661b8e5334d886db1901c2f9faa.tar.xz
wireguard-openbsd-512dfaa60ec59661b8e5334d886db1901c2f9faa.zip
Include <sys/vmmeter.h> directly instead of relying on it being
pulled by <uvm/uvm_extern.h> 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 <sys/vmmeter.h> from <uvm/uvm_extern.h> to give some more time to port maintainers to fix their ports. ok guenther@ as part of a larger diff.
-rw-r--r--sys/arch/amd64/amd64/fpu.c3
-rw-r--r--sys/kern/kern_fork.c3
-rw-r--r--sys/miscfs/procfs/procfs_vfsops.c9
-rw-r--r--sys/uvm/uvm_extern.h4
-rw-r--r--sys/uvm/uvm_meter.c9
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 <sys/user.h>
#include <sys/ioctl.h>
#include <sys/device.h>
-#include <sys/vmmeter.h>
#include <sys/signalvar.h>
#include <uvm/uvm_extern.h>
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 <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/vnode.h>
+#include <sys/vmmeter.h>
#include <sys/file.h>
#include <sys/acct.h>
#include <sys/ktrace.h>
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 <sys/proc.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <uvm/uvm_extern.h>
+#include <sys/vmmeter.h>
#include <sys/sysctl.h>
#include <sys/exec.h>
@@ -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)