summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@humppa.nl>2014-04-10 16:32:47 +0200
committerJasper Lievisse Adriaanse <jasper@humppa.nl>2014-04-10 16:32:47 +0200
commit63ba7b2c1284c68ae3bb9362e700bd35e4cfdc5a (patch)
tree81d84d4e734052ce3da1b582d2d59420ad885bf4 /sysdeps
parent5371e8ec88ffed33480c1aebb4a16e822331b0b1 (diff)
downloadlibgtop-63ba7b2c1284c68ae3bb9362e700bd35e4cfdc5a.tar.gz
switch from VM_METER to VM_UVMEXP
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/openbsd/mem.c31
1 files changed, 4 insertions, 27 deletions
diff --git a/sysdeps/openbsd/mem.c b/sysdeps/openbsd/mem.c
index 6a49415b..fe8c914b 100644
--- a/sysdeps/openbsd/mem.c
+++ b/sysdeps/openbsd/mem.c
@@ -28,9 +28,7 @@
#include <sys/mount.h>
#include <sys/sysctl.h>
-#include <sys/vmmeter.h>
#include <uvm/uvm_extern.h>
-#include <uvm/uvm_param.h>
static const unsigned long _glibtop_sysdeps_mem =
(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) +
@@ -49,7 +47,6 @@ static int pageshift; /* log base 2 of the pagesize */
#define pagetok(size) ((size) << pageshift)
/* MIB array for sysctl */
-static int vmmeter_mib [] = { CTL_VM, VM_METER };
static int uvmexp_mib [] = { CTL_VM, VM_UVMEXP };
static int bcstats_mib [] = { CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT };
@@ -77,12 +74,8 @@ _glibtop_init_mem_s (glibtop *server)
void
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
{
- struct vmtotal vmt;
struct uvmexp uvmexp;
struct bcachestats bcstats;
- u_int v_used_count;
- u_int v_total_count;
- u_int v_free_count;
size_t length;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
@@ -93,13 +86,6 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
return;
/* Get the data from sysctl */
- length = sizeof (vmt);
- if (sysctl (vmmeter_mib, 2, &vmt, &length, NULL, 0)) {
- glibtop_warn_io_r (server, "sysctl (vm.vmmeter)");
- bzero(&vmt, sizeof(length));
- return;
- }
-
length = sizeof (uvmexp);
if (sysctl (uvmexp_mib, 2, &uvmexp, &length, NULL, 0)) {
glibtop_warn_io_r (server, "sysctl (vm.uvmexp)");
@@ -114,21 +100,12 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
return;
}
- /*
- * t_arm = active real memory
- * t_rm = total real memory in use
- * t_free = free memory pages
- */
- v_total_count = vmt.t_rm + vmt.t_free;
- v_used_count = vmt.t_rm;
- v_free_count = vmt.t_free;
-
/* convert memory stats to Kbytes */
- buf->total = (guint64) pagetok (v_total_count) << LOG1024;
- buf->used = (guint64) pagetok (v_used_count) << LOG1024;
- buf->free = (guint64) pagetok (v_free_count) << LOG1024;
+ buf->total = (guint64) pagetok (uvmexp.npages) << LOG1024;
+ buf->used = (guint64) pagetok (uvmexp.npages - uvmexp.free) << LOG1024;
+ buf->free = (guint64) pagetok (uvmexp.free) << LOG1024;
buf->locked = (guint64) pagetok (uvmexp.wired) << LOG1024;
- buf->shared = (guint64) pagetok (vmt.t_rmshr) << LOG1024;
+ buf->shared = (guint64) pagetok (0 /* XXX */) << LOG1024;
buf->cached = (guint64) pagetok (bcstats.numbufpages) << LOG1024;
buf->buffer = 0;