1/* $NetBSD: uvm_stat.c,v 1.37 2011/05/17 04:18:07 mrg Exp $ */
2
3/*
4 * Copyright (c) 1997 Charles D. Cranor and Washington University.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * from: Id: uvm_stat.c,v 1.1.2.3 1997/12/19 15:01:00 mrg Exp
28 */
29
30/*
31 * uvm_stat.c
32 */
33
34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.37 2011/05/17 04:18:07 mrg Exp $");
36
37#include "opt_readahead.h"
38#include "opt_ddb.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/cpu.h>
43
44#include <uvm/uvm.h>
45#include <uvm/uvm_ddb.h>
46
47#ifdef DDB
48
49/*
50 * uvmexp_print: ddb hook to print interesting uvm counters
51 */
52void
53uvmexp_print(void (*pr)(const char *, ...)
54 __attribute__((__format__(__printf__,1,2))))
55{
56 int active, inactive;
57 CPU_INFO_ITERATOR cii;
58 struct cpu_info *ci;
59
60 uvm_estimatepageable(&active, &inactive);
61
62 (*pr)("Current UVM status:\n");
63 (*pr)(" pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n, ncolors=%d",
64 uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask,
65 uvmexp.pageshift, uvmexp.ncolors);
66 (*pr)(" %d VM pages: %d active, %d inactive, %d wired, %d free\n",
67 uvmexp.npages, active, inactive, uvmexp.wired,
68 uvmexp.free);
69 (*pr)(" pages %d anon, %d file, %d exec\n",
70 uvmexp.anonpages, uvmexp.filepages, uvmexp.execpages);
71 (*pr)(" freemin=%d, free-target=%d, wired-max=%d\n",
72 uvmexp.freemin, uvmexp.freetarg, uvmexp.wiredmax);
73
74 for (CPU_INFO_FOREACH(cii, ci)) {
75 (*pr)(" cpu%u:\n", cpu_index(ci));
76 (*pr)(" faults=%" PRIu64 ", traps=%" PRIu64 ", "
77 "intrs=%" PRIu64 ", ctxswitch=%" PRIu64 "\n",
78 ci->ci_data.cpu_nfault, ci->ci_data.cpu_ntrap,
79 ci->ci_data.cpu_nintr, ci->ci_data.cpu_nswtch);
80 (*pr)(" softint=%" PRIu64 ", syscalls=%" PRIu64 "\n",
81 ci->ci_data.cpu_nsoft, ci->ci_data.cpu_nsyscall);
82 }
83
84 (*pr)(" fault counts:\n");
85 (*pr)(" noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n",
86 uvmexp.fltnoram, uvmexp.fltnoanon, uvmexp.fltpgwait,
87 uvmexp.fltpgrele);
88 (*pr)(" ok relocks(total)=%d(%d), anget(retrys)=%d(%d), "
89 "amapcopy=%d\n", uvmexp.fltrelckok, uvmexp.fltrelck,
90 uvmexp.fltanget, uvmexp.fltanretry, uvmexp.fltamcopy);
91 (*pr)(" neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n",
92 uvmexp.fltnamap, uvmexp.fltnomap, uvmexp.fltlget, uvmexp.fltget);
93 (*pr)(" cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n",
94 uvmexp.flt_anon, uvmexp.flt_acow, uvmexp.flt_obj, uvmexp.flt_prcopy,
95 uvmexp.flt_przero);
96
97 (*pr)(" daemon and swap counts:\n");
98 (*pr)(" woke=%d, revs=%d, scans=%d, obscans=%d, anscans=%d\n",
99 uvmexp.pdwoke, uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdobscan,
100 uvmexp.pdanscan);
101 (*pr)(" busy=%d, freed=%d, reactivate=%d, deactivate=%d\n",
102 uvmexp.pdbusy, uvmexp.pdfreed, uvmexp.pdreact, uvmexp.pddeact);
103 (*pr)(" pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts,
104 uvmexp.pdpending, uvmexp.nswget);
105 (*pr)(" nswapdev=%d, swpgavail=%d\n",
106 uvmexp.nswapdev, uvmexp.swpgavail);
107 (*pr)(" swpages=%d, swpginuse=%d, swpgonly=%d, paging=%d\n",
108 uvmexp.swpages, uvmexp.swpginuse, uvmexp.swpgonly, uvmexp.paging);
109}
110#endif
111
112#if defined(READAHEAD_STATS)
113
114#define UVM_RA_EVCNT_DEFINE(name) \
115struct evcnt uvm_ra_##name = \
116EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "readahead", #name); \
117EVCNT_ATTACH_STATIC(uvm_ra_##name);
118
119UVM_RA_EVCNT_DEFINE(total);
120UVM_RA_EVCNT_DEFINE(hit);
121UVM_RA_EVCNT_DEFINE(miss);
122
123#endif /* defined(READAHEAD_STATS) */
124