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