[libgtop] switch from VM_METER to VM_UVMEXP
- From: Jasper Lievisse Adriaanse <jasperla src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgtop] switch from VM_METER to VM_UVMEXP
- Date: Thu, 10 Apr 2014 14:34:38 +0000 (UTC)
commit 63ba7b2c1284c68ae3bb9362e700bd35e4cfdc5a
Author: Jasper Lievisse Adriaanse <jasper humppa nl>
Date: Thu Apr 10 16:32:47 2014 +0200
switch from VM_METER to VM_UVMEXP
sysdeps/openbsd/mem.c | 31 ++++---------------------------
1 files changed, 4 insertions(+), 27 deletions(-)
---
diff --git a/sysdeps/openbsd/mem.c b/sysdeps/openbsd/mem.c
index 6a49415..fe8c914 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]