85 lines
2.4 KiB
Plaintext
85 lines
2.4 KiB
Plaintext
$OpenBSD: patch-machine_c,v 1.5 2014/09/17 14:39:20 espie Exp $
|
|
--- machine.c.orig Fri May 4 07:24:08 2012
|
|
+++ machine.c Wed Sep 17 08:38:07 2014
|
|
@@ -35,14 +35,16 @@
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/param.h>
|
|
+#include <sys/sched.h>
|
|
+#include <sys/mount.h>
|
|
+#include <sys/proc.h>
|
|
+#include <sys/swap.h>
|
|
+#include <sys/sysctl.h>
|
|
+
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
-#include <sys/sysctl.h>
|
|
-#include <sys/dkstat.h>
|
|
-#include <sys/mount.h>
|
|
-#include <sys/swap.h>
|
|
#include <err.h>
|
|
#include <errno.h>
|
|
|
|
@@ -215,10 +217,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;
|
|
@@ -261,10 +263,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) {
|
|
@@ -273,10 +275,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;
|
|
@@ -506,15 +508,9 @@ format_next_process(caddr_t handle, char *(*get_userid
|
|
pmondata.memsize = pagetok(PROCSIZE(pp)) / 1024.0;
|
|
}
|
|
|
|
- if (pp->p_wchan) {
|
|
- if (pp->p_wmesg)
|
|
- p_wait = pp->p_wmesg;
|
|
- else {
|
|
- snprintf(waddr, sizeof(waddr), "%llx",
|
|
- (unsigned long long)(pp->p_wchan & ~KERNBASE));
|
|
- p_wait = waddr;
|
|
- }
|
|
- } else
|
|
+ if (pp->p_wmesg[0])
|
|
+ p_wait = pp->p_wmesg;
|
|
+ else
|
|
p_wait = "-";
|
|
|
|
/* format this entry */
|