1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
$NetBSD: patch-uvm,v 1.2 2013/01/15 15:30:56 joerg Exp $
--- sys_netbsd.c.orig 2003-10-11 19:06:09.000000000 +0000
+++ sys_netbsd.c
@@ -25,7 +25,6 @@
#include <sys/resource.h>
#include <sys/sched.h>
-#include <uvm/uvm_object.h>
#include <uvm/uvm_extern.h>
#include <sys/swap.h>
@@ -78,9 +77,9 @@ int system_cpu(void)
int system_memory(void)
{
#define pagetob(size) ((size) << (uvmexp.pageshift))
- struct uvmexp uvmexp;
+ struct uvmexp_sysctl uvmexp;
int nswap, rnswap, i;
- int mib[] = { CTL_VM, VM_UVMEXP };
+ int mib[] = { CTL_VM, VM_UVMEXP2 };
size_t size = sizeof (uvmexp);
if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
@@ -91,12 +90,13 @@ int system_memory(void)
bm.swap_used = 0;
bm.swap_max = 0;
if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) != 0) {
- struct swapent *swdev = malloc(nswap * sizeof(*swdev));
- if((rnswap = swapctl(SWAP_STATS, swdev, nswap)) != nswap) {
+ struct swapent *swdev = malloc(nswap * sizeof(swdev));
+ if((rnswap = swapctl(SWAP_STATS, swdev, nswap)) == nswap) {
for (i = 0; i < nswap; i++) {
if (swdev[i].se_flags & SWF_ENABLE) {
- bm.swap_used += (swdev[i].se_inuse / (1024 / DEV_BSIZE));
- bm.swap_max += (swdev[i].se_nblks / (1024 / DEV_BSIZE));
+ /* actually, these are expected in bytes */
+ bm.swap_used += (swdev[i].se_inuse * DEV_BSIZE);
+ bm.swap_max += (swdev[i].se_nblks * DEV_BSIZE);
}
}
}
|