diff options
author | 2014-04-08 14:04:11 +0000 | |
---|---|---|
committer | 2014-04-08 14:04:11 +0000 | |
commit | 77fb67b890bb42a674ae239a251401b297a071a3 (patch) | |
tree | 8a92ec3f3ef87abe6553fffcc26cde7042e05871 | |
parent | add an error detection mechanism. People not used to doing ports often mess (diff) | |
download | wireguard-openbsd-77fb67b890bb42a674ae239a251401b297a071a3.tar.xz wireguard-openbsd-77fb67b890bb42a674ae239a251401b297a071a3.zip |
Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.
miod@ likes it, ok guenther@
-rw-r--r-- | lib/libc/gen/sysconf.c | 15 | ||||
-rw-r--r-- | sbin/sysctl/sysctl.c | 3 | ||||
-rw-r--r-- | usr.bin/systat/vmstat.c | 5 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 18 | ||||
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 7 | ||||
-rw-r--r-- | usr.sbin/snmpd/mib.c | 9 |
6 files changed, 28 insertions, 29 deletions
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index f02faa5c01c..7e8d2ca6569 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysconf.c,v 1.18 2013/03/24 20:04:35 guenther Exp $ */ +/* $OpenBSD: sysconf.c,v 1.19 2014/04/08 14:04:11 mpi Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. @@ -36,9 +36,10 @@ #include <sys/sysctl.h> #include <sys/time.h> #include <sys/resource.h> -#include <sys/vmmeter.h> #include <sys/socket.h> +#include <uvm/uvm_extern.h> + #include <errno.h> #include <grp.h> #include <pthread.h> @@ -444,14 +445,14 @@ sysconf(int name) } case _SC_AVPHYS_PAGES: { - struct vmtotal vmtotal; + struct uvmexp uvmexp; mib[0] = CTL_VM; - mib[1] = VM_METER; - len = sizeof(vmtotal); - if (sysctl(mib, namelen, &vmtotal, &len, NULL, 0) == -1) + mib[1] = VM_UVMEXP; + len = sizeof(uvmexp); + if (sysctl(mib, namelen, &uvmexp, &len, NULL, 0) == -1) return (-1); - return (vmtotal.t_free); + return (uvmexp.free); } case _SC_NPROCESSORS_CONF: diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 9bbae17004f..7fa6d030868 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.199 2014/01/23 03:00:04 guenther Exp $ */ +/* $OpenBSD: sysctl.c,v 1.200 2014/04/08 14:04:11 mpi Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -43,6 +43,7 @@ #include <sys/tty.h> #include <sys/namei.h> #include <sys/sensors.h> +#include <sys/vmmeter.h> #include <net/route.h> #include <net/if.h> diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 80c57f81fe4..ddb97741684 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.75 2013/10/31 02:00:11 deraadt Exp $ */ +/* $OpenBSD: vmstat.c,v 1.76 2014/04/08 14:04:11 mpi Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -43,8 +43,7 @@ #include <sys/proc.h> #include <sys/namei.h> #include <sys/sysctl.h> - -#include <uvm/uvm_extern.h> +#include <sys/vmmeter.h> #include <ctype.h> #include <errno.h> diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 0837ec8ea38..ac4baf74755 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.76 2013/03/23 21:12:32 tedu Exp $ */ +/* $OpenBSD: machine.c,v 1.77 2014/04/08 14:04:11 mpi Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -209,10 +209,10 @@ void get_system_info(struct system_info *si) { static int sysload_mib[] = {CTL_VM, VM_LOADAVG}; - static int vmtotal_mib[] = {CTL_VM, VM_METER}; + static int uvmexp_mib[] = {CTL_VM, VM_UVMEXP}; static int bcstats_mib[] = {CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT}; struct loadavg sysload; - struct vmtotal vmtotal; + struct uvmexp uvmexp; struct bcachestats bcstats; double *infoloadp; size_t size; @@ -255,10 +255,10 @@ get_system_info(struct system_info *si) /* get total -- systemwide main memory usage structure */ - size = sizeof(vmtotal); - if (sysctl(vmtotal_mib, 2, &vmtotal, &size, NULL, 0) < 0) { + size = sizeof(uvmexp); + if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) < 0) { warn("sysctl failed"); - bzero(&vmtotal, sizeof(vmtotal)); + bzero(&uvmexp, sizeof(uvmexp)); } size = sizeof(bcstats); if (sysctl(bcstats_mib, 3, &bcstats, &size, NULL, 0) < 0) { @@ -267,10 +267,10 @@ get_system_info(struct system_info *si) } /* convert memory stats to Kbytes */ memory_stats[0] = -1; - memory_stats[1] = pagetok(vmtotal.t_arm); - memory_stats[2] = pagetok(vmtotal.t_rm); + memory_stats[1] = pagetok(uvmexp.active); + memory_stats[2] = pagetok(uvmexp.npages - uvmexp.free); memory_stats[3] = -1; - memory_stats[4] = pagetok(vmtotal.t_free); + memory_stats[4] = pagetok(uvmexp.free); memory_stats[5] = -1; memory_stats[6] = pagetok(bcstats.numbufpages); memory_stats[7] = -1; diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 3259a036d61..9b798eb7998 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,5 @@ /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ -/* $OpenBSD: vmstat.c,v 1.127 2013/11/26 21:08:12 deraadt Exp $ */ +/* $OpenBSD: vmstat.c,v 1.128 2014/04/08 14:04:11 mpi Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -42,6 +42,8 @@ #include <sys/sysctl.h> #include <sys/device.h> #include <sys/pool.h> +#include <sys/vmmeter.h> + #include <time.h> #include <nlist.h> #include <kvm.h> @@ -358,7 +360,8 @@ dovmstat(u_int interval, int reps) #define rate(x) ((unsigned)((((unsigned)x) + halfuptime) / uptime)) /* round */ #define pgtok(a) ((a) * ((unsigned int)uvmexp.pagesize >> 10)) (void)printf("%6u %7u ", - pgtok(total.t_avm), pgtok(total.t_free)); + pgtok(uvmexp.active + uvmexp.swpginuse), + pgtok(uvmexp.free)); (void)printf("%4u ", rate(uvmexp.faults - ouvmexp.faults)); (void)printf("%3u ", rate(uvmexp.pdreact - ouvmexp.pdreact)); (void)printf("%3u ", rate(uvmexp.pageins - ouvmexp.pageins)); diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index e124a03fc12..03387c9f2d7 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.66 2013/10/01 12:41:47 reyk Exp $ */ +/* $OpenBSD: mib.c,v 1.67 2014/04/08 14:04:11 mpi Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -573,7 +573,6 @@ mib_hrstorage(struct oid *oid, struct ber_oid *o, struct ber_element **elm) int mib[] = { CTL_HW, 0 }; u_int64_t physmem, realmem; struct uvmexp uvm; - struct vmtotal vm; size_t len; static struct ber_oid *sop, so[] = { { { MIB_hrStorageOther } }, @@ -596,10 +595,6 @@ mib_hrstorage(struct oid *oid, struct ber_oid *o, struct ber_element **elm) len = sizeof(uvm); if (sysctl(mib, sizeofa(mib), &uvm, &len, NULL, 0) == -1) return (-1); - mib[1] = VM_METER; - len = sizeof(vm); - if (sysctl(mib, sizeofa(mib), &vm, &len, NULL, 0) == -1) - return (-1); maxsize = 10; /* Disks */ @@ -628,7 +623,7 @@ mib_hrstorage(struct oid *oid, struct ber_oid *o, struct ber_element **elm) descr = "Physical memory"; units = uvm.pagesize; size = physmem / uvm.pagesize; - used = size - vm.t_free; + used = size - uvm.free; sop = &so[1]; break; case 2: |