1*8452SJohn.Wren.Kennedy@Sun.COM /*
2*8452SJohn.Wren.Kennedy@Sun.COM * CDDL HEADER START
3*8452SJohn.Wren.Kennedy@Sun.COM *
4*8452SJohn.Wren.Kennedy@Sun.COM * The contents of this file are subject to the terms of the
5*8452SJohn.Wren.Kennedy@Sun.COM * Common Development and Distribution License (the "License").
6*8452SJohn.Wren.Kennedy@Sun.COM * You may not use this file except in compliance with the License.
7*8452SJohn.Wren.Kennedy@Sun.COM *
8*8452SJohn.Wren.Kennedy@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*8452SJohn.Wren.Kennedy@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*8452SJohn.Wren.Kennedy@Sun.COM * See the License for the specific language governing permissions
11*8452SJohn.Wren.Kennedy@Sun.COM * and limitations under the License.
12*8452SJohn.Wren.Kennedy@Sun.COM *
13*8452SJohn.Wren.Kennedy@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*8452SJohn.Wren.Kennedy@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*8452SJohn.Wren.Kennedy@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*8452SJohn.Wren.Kennedy@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*8452SJohn.Wren.Kennedy@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*8452SJohn.Wren.Kennedy@Sun.COM *
19*8452SJohn.Wren.Kennedy@Sun.COM * CDDL HEADER END
20*8452SJohn.Wren.Kennedy@Sun.COM */
21*8452SJohn.Wren.Kennedy@Sun.COM /*
22*8452SJohn.Wren.Kennedy@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23*8452SJohn.Wren.Kennedy@Sun.COM * Use is subject to license terms.
24*8452SJohn.Wren.Kennedy@Sun.COM */
25*8452SJohn.Wren.Kennedy@Sun.COM
26*8452SJohn.Wren.Kennedy@Sun.COM #include "mdinclude.h"
27*8452SJohn.Wren.Kennedy@Sun.COM
28*8452SJohn.Wren.Kennedy@Sun.COM /*
29*8452SJohn.Wren.Kennedy@Sun.COM * Display an arbitrary bitmap by showing the set bits in the array.
30*8452SJohn.Wren.Kennedy@Sun.COM * Output will be <start>-<end> for ranges or <position> for singleton bits.
31*8452SJohn.Wren.Kennedy@Sun.COM */
32*8452SJohn.Wren.Kennedy@Sun.COM static void
print_mm_bm(unsigned char * bm,uint_t size,char * bm_name)33*8452SJohn.Wren.Kennedy@Sun.COM print_mm_bm(unsigned char *bm, uint_t size, char *bm_name)
34*8452SJohn.Wren.Kennedy@Sun.COM {
35*8452SJohn.Wren.Kennedy@Sun.COM int i;
36*8452SJohn.Wren.Kennedy@Sun.COM int first_set = -1;
37*8452SJohn.Wren.Kennedy@Sun.COM int need_comma = 0;
38*8452SJohn.Wren.Kennedy@Sun.COM
39*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s set bits: ", bm_name);
40*8452SJohn.Wren.Kennedy@Sun.COM for (i = 0; i < size; i++) {
41*8452SJohn.Wren.Kennedy@Sun.COM if (isset(bm, i)) {
42*8452SJohn.Wren.Kennedy@Sun.COM if (first_set == -1) {
43*8452SJohn.Wren.Kennedy@Sun.COM first_set = i;
44*8452SJohn.Wren.Kennedy@Sun.COM }
45*8452SJohn.Wren.Kennedy@Sun.COM } else {
46*8452SJohn.Wren.Kennedy@Sun.COM if (first_set != -1) {
47*8452SJohn.Wren.Kennedy@Sun.COM if (first_set != (i-1)) {
48*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s%u-%u",
49*8452SJohn.Wren.Kennedy@Sun.COM (need_comma ? "," : ""),
50*8452SJohn.Wren.Kennedy@Sun.COM first_set, (i-1));
51*8452SJohn.Wren.Kennedy@Sun.COM } else {
52*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s%u",
53*8452SJohn.Wren.Kennedy@Sun.COM (need_comma ? "," : ""), first_set);
54*8452SJohn.Wren.Kennedy@Sun.COM }
55*8452SJohn.Wren.Kennedy@Sun.COM need_comma = 1;
56*8452SJohn.Wren.Kennedy@Sun.COM first_set = -1;
57*8452SJohn.Wren.Kennedy@Sun.COM }
58*8452SJohn.Wren.Kennedy@Sun.COM }
59*8452SJohn.Wren.Kennedy@Sun.COM }
60*8452SJohn.Wren.Kennedy@Sun.COM if (first_set != -1) {
61*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s%u-%u", (need_comma ? "," : ""), first_set,
62*8452SJohn.Wren.Kennedy@Sun.COM size-1);
63*8452SJohn.Wren.Kennedy@Sun.COM }
64*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("\n");
65*8452SJohn.Wren.Kennedy@Sun.COM }
66*8452SJohn.Wren.Kennedy@Sun.COM
67*8452SJohn.Wren.Kennedy@Sun.COM /*
68*8452SJohn.Wren.Kennedy@Sun.COM * Print uchar_t sized count fields (typically un_pernode_dirty_map entries)
69*8452SJohn.Wren.Kennedy@Sun.COM */
70*8452SJohn.Wren.Kennedy@Sun.COM
71*8452SJohn.Wren.Kennedy@Sun.COM static void
print_mm_cnt_c(unsigned char * bm,uint_t size,char * bm_name)72*8452SJohn.Wren.Kennedy@Sun.COM print_mm_cnt_c(unsigned char *bm, uint_t size, char *bm_name)
73*8452SJohn.Wren.Kennedy@Sun.COM {
74*8452SJohn.Wren.Kennedy@Sun.COM int i;
75*8452SJohn.Wren.Kennedy@Sun.COM int need_comma = 0;
76*8452SJohn.Wren.Kennedy@Sun.COM
77*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s set counts: ", bm_name);
78*8452SJohn.Wren.Kennedy@Sun.COM for (i = 0; i < size; i++) {
79*8452SJohn.Wren.Kennedy@Sun.COM if (bm[i]) {
80*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s(%d,%3d)", (need_comma ? "," : ""), i,
81*8452SJohn.Wren.Kennedy@Sun.COM (uint_t)bm[i]);
82*8452SJohn.Wren.Kennedy@Sun.COM need_comma = 1;
83*8452SJohn.Wren.Kennedy@Sun.COM }
84*8452SJohn.Wren.Kennedy@Sun.COM }
85*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("\n");
86*8452SJohn.Wren.Kennedy@Sun.COM }
87*8452SJohn.Wren.Kennedy@Sun.COM
88*8452SJohn.Wren.Kennedy@Sun.COM static void
print_mm_cnt_w(unsigned short * bm,uint_t size,char * bm_name)89*8452SJohn.Wren.Kennedy@Sun.COM print_mm_cnt_w(unsigned short *bm, uint_t size, char *bm_name)
90*8452SJohn.Wren.Kennedy@Sun.COM {
91*8452SJohn.Wren.Kennedy@Sun.COM int i;
92*8452SJohn.Wren.Kennedy@Sun.COM int need_comma = 0;
93*8452SJohn.Wren.Kennedy@Sun.COM
94*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s set counts: ", bm_name);
95*8452SJohn.Wren.Kennedy@Sun.COM for (i = 0; i < size; i++) {
96*8452SJohn.Wren.Kennedy@Sun.COM if (bm[i]) {
97*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("%s(%d,%5d)", (need_comma ? "," : ""), i,
98*8452SJohn.Wren.Kennedy@Sun.COM (uint_t)bm[i]);
99*8452SJohn.Wren.Kennedy@Sun.COM need_comma = 1;
100*8452SJohn.Wren.Kennedy@Sun.COM }
101*8452SJohn.Wren.Kennedy@Sun.COM }
102*8452SJohn.Wren.Kennedy@Sun.COM mdb_printf("\n");
103*8452SJohn.Wren.Kennedy@Sun.COM }
104*8452SJohn.Wren.Kennedy@Sun.COM
105*8452SJohn.Wren.Kennedy@Sun.COM /*
106*8452SJohn.Wren.Kennedy@Sun.COM * Print the associated bitmaps for the specified mm_unit_t
107*8452SJohn.Wren.Kennedy@Sun.COM * These are:
108*8452SJohn.Wren.Kennedy@Sun.COM * un_pernode_dirty_bm
109*8452SJohn.Wren.Kennedy@Sun.COM * un_goingclean_bm
110*8452SJohn.Wren.Kennedy@Sun.COM * un_dirty_bm
111*8452SJohn.Wren.Kennedy@Sun.COM * un_goingdirty_bm
112*8452SJohn.Wren.Kennedy@Sun.COM * un_resync_bm
113*8452SJohn.Wren.Kennedy@Sun.COM *
114*8452SJohn.Wren.Kennedy@Sun.COM * Associated counts for unit:
115*8452SJohn.Wren.Kennedy@Sun.COM * un_pernode_dirty_sum[] (uchar_t)
116*8452SJohn.Wren.Kennedy@Sun.COM * un_outstanding_writes[] (ushort_t)
117*8452SJohn.Wren.Kennedy@Sun.COM *
118*8452SJohn.Wren.Kennedy@Sun.COM */
119*8452SJohn.Wren.Kennedy@Sun.COM
120*8452SJohn.Wren.Kennedy@Sun.COM /* ARGSUSED */
121*8452SJohn.Wren.Kennedy@Sun.COM int
printmmbm(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)122*8452SJohn.Wren.Kennedy@Sun.COM printmmbm(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
123*8452SJohn.Wren.Kennedy@Sun.COM {
124*8452SJohn.Wren.Kennedy@Sun.COM mm_unit_t mm, *mmp;
125*8452SJohn.Wren.Kennedy@Sun.COM unsigned char *rr_dirty_bm, *rr_goingclean_bm, *rr_goingdirty_bm;
126*8452SJohn.Wren.Kennedy@Sun.COM unsigned char *rr_resync_bm;
127*8452SJohn.Wren.Kennedy@Sun.COM uintptr_t un_dbm, un_gcbm, un_gdbm, un_rrbm, un_pnds, un_ow;
128*8452SJohn.Wren.Kennedy@Sun.COM uint_t num_rr, rr_bitmap_size;
129*8452SJohn.Wren.Kennedy@Sun.COM int i;
130*8452SJohn.Wren.Kennedy@Sun.COM uintptr_t un_pernode_bm;
131*8452SJohn.Wren.Kennedy@Sun.COM unsigned char *rr_pernode_dirty, *rr_pnds;
132*8452SJohn.Wren.Kennedy@Sun.COM unsigned short *rr_ow;
133*8452SJohn.Wren.Kennedy@Sun.COM /* just enough for un_pernode_dirty_bm[] plus three digits */
134*8452SJohn.Wren.Kennedy@Sun.COM char pernode_str[25];
135*8452SJohn.Wren.Kennedy@Sun.COM
136*8452SJohn.Wren.Kennedy@Sun.COM if (argc != 0)
137*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_USAGE);
138*8452SJohn.Wren.Kennedy@Sun.COM
139*8452SJohn.Wren.Kennedy@Sun.COM if (!(flags & DCMD_ADDRSPEC)) {
140*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("No mm_unit_t address specified");
141*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
142*8452SJohn.Wren.Kennedy@Sun.COM }
143*8452SJohn.Wren.Kennedy@Sun.COM
144*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(&mm, sizeof (mm_unit_t), addr) == -1) {
145*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read mm_unit_t at %p\n", addr);
146*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
147*8452SJohn.Wren.Kennedy@Sun.COM }
148*8452SJohn.Wren.Kennedy@Sun.COM
149*8452SJohn.Wren.Kennedy@Sun.COM mmp = &mm;
150*8452SJohn.Wren.Kennedy@Sun.COM
151*8452SJohn.Wren.Kennedy@Sun.COM num_rr = mm.un_rrd_num;
152*8452SJohn.Wren.Kennedy@Sun.COM
153*8452SJohn.Wren.Kennedy@Sun.COM un_dbm = (uintptr_t)mmp->un_dirty_bm;
154*8452SJohn.Wren.Kennedy@Sun.COM un_gcbm = (uintptr_t)mmp->un_goingclean_bm;
155*8452SJohn.Wren.Kennedy@Sun.COM un_gdbm = (uintptr_t)mmp->un_goingdirty_bm;
156*8452SJohn.Wren.Kennedy@Sun.COM un_rrbm = (uintptr_t)mmp->un_resync_bm;
157*8452SJohn.Wren.Kennedy@Sun.COM un_pnds = (uintptr_t)mmp->un_pernode_dirty_sum;
158*8452SJohn.Wren.Kennedy@Sun.COM un_ow = (uintptr_t)mmp->un_outstanding_writes;
159*8452SJohn.Wren.Kennedy@Sun.COM
160*8452SJohn.Wren.Kennedy@Sun.COM rr_bitmap_size = howmany(num_rr, NBBY);
161*8452SJohn.Wren.Kennedy@Sun.COM rr_dirty_bm = (unsigned char *)mdb_alloc(rr_bitmap_size,
162*8452SJohn.Wren.Kennedy@Sun.COM UM_SLEEP|UM_GC);
163*8452SJohn.Wren.Kennedy@Sun.COM rr_goingclean_bm = (unsigned char *)mdb_alloc(rr_bitmap_size,
164*8452SJohn.Wren.Kennedy@Sun.COM UM_SLEEP|UM_GC);
165*8452SJohn.Wren.Kennedy@Sun.COM rr_goingdirty_bm = (unsigned char *)mdb_alloc(rr_bitmap_size,
166*8452SJohn.Wren.Kennedy@Sun.COM UM_SLEEP|UM_GC);
167*8452SJohn.Wren.Kennedy@Sun.COM rr_resync_bm = (unsigned char *)mdb_alloc(rr_bitmap_size,
168*8452SJohn.Wren.Kennedy@Sun.COM UM_SLEEP|UM_GC);
169*8452SJohn.Wren.Kennedy@Sun.COM rr_pnds = (unsigned char *)mdb_alloc(num_rr, UM_SLEEP|UM_GC);
170*8452SJohn.Wren.Kennedy@Sun.COM rr_ow = (unsigned short *)mdb_alloc(num_rr * sizeof (unsigned short),
171*8452SJohn.Wren.Kennedy@Sun.COM UM_SLEEP|UM_GC);
172*8452SJohn.Wren.Kennedy@Sun.COM
173*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_dirty_bm, rr_bitmap_size, un_dbm) == -1) {
174*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read un_dirty_bm at %p\n", un_dbm);
175*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
176*8452SJohn.Wren.Kennedy@Sun.COM }
177*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_goingclean_bm, rr_bitmap_size, un_gcbm) == -1) {
178*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read un_goingclean_bm at %p\n", un_gcbm);
179*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
180*8452SJohn.Wren.Kennedy@Sun.COM }
181*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_goingdirty_bm, rr_bitmap_size, un_gdbm) == -1) {
182*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read un_goingdirty_bm at %p\n", un_gdbm);
183*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
184*8452SJohn.Wren.Kennedy@Sun.COM }
185*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_resync_bm, rr_bitmap_size, un_rrbm) == -1) {
186*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read un_resync_bm at %p\n", un_rrbm);
187*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
188*8452SJohn.Wren.Kennedy@Sun.COM }
189*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_pnds, num_rr, un_pnds) == -1) {
190*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read un_pernode_dirty_sum at %p\n",
191*8452SJohn.Wren.Kennedy@Sun.COM un_pnds);
192*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
193*8452SJohn.Wren.Kennedy@Sun.COM }
194*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_ow, num_rr * sizeof (unsigned short), un_ow) == -1) {
195*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read un_outstanding_writes at %p\n", un_ow);
196*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
197*8452SJohn.Wren.Kennedy@Sun.COM }
198*8452SJohn.Wren.Kennedy@Sun.COM
199*8452SJohn.Wren.Kennedy@Sun.COM print_mm_bm(rr_dirty_bm, num_rr, "un_dirty_bm");
200*8452SJohn.Wren.Kennedy@Sun.COM print_mm_bm(rr_goingclean_bm, num_rr, "un_goingclean_bm");
201*8452SJohn.Wren.Kennedy@Sun.COM print_mm_bm(rr_goingdirty_bm, num_rr, "un_goingdirty_bm");
202*8452SJohn.Wren.Kennedy@Sun.COM print_mm_bm(rr_resync_bm, num_rr, "un_resync_bm");
203*8452SJohn.Wren.Kennedy@Sun.COM
204*8452SJohn.Wren.Kennedy@Sun.COM /*
205*8452SJohn.Wren.Kennedy@Sun.COM * Load all the un_pernode_bm[] entries and iterate through the non-
206*8452SJohn.Wren.Kennedy@Sun.COM * NULL entries
207*8452SJohn.Wren.Kennedy@Sun.COM */
208*8452SJohn.Wren.Kennedy@Sun.COM rr_pernode_dirty = (unsigned char *)mdb_alloc(rr_bitmap_size,
209*8452SJohn.Wren.Kennedy@Sun.COM UM_SLEEP|UM_GC);
210*8452SJohn.Wren.Kennedy@Sun.COM
211*8452SJohn.Wren.Kennedy@Sun.COM for (i = 0; i < 128; i++) {
212*8452SJohn.Wren.Kennedy@Sun.COM un_pernode_bm = (uintptr_t)mmp->un_pernode_dirty_bm[i];
213*8452SJohn.Wren.Kennedy@Sun.COM if (un_pernode_bm) {
214*8452SJohn.Wren.Kennedy@Sun.COM mdb_snprintf(pernode_str, sizeof (pernode_str),
215*8452SJohn.Wren.Kennedy@Sun.COM "un_pernode_dirty_bm[%d]", i);
216*8452SJohn.Wren.Kennedy@Sun.COM if (mdb_vread(rr_pernode_dirty, rr_bitmap_size,
217*8452SJohn.Wren.Kennedy@Sun.COM un_pernode_bm) == -1) {
218*8452SJohn.Wren.Kennedy@Sun.COM mdb_warn("failed to read %s at %p\n",
219*8452SJohn.Wren.Kennedy@Sun.COM pernode_str, un_pernode_bm);
220*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_ERR);
221*8452SJohn.Wren.Kennedy@Sun.COM }
222*8452SJohn.Wren.Kennedy@Sun.COM print_mm_bm(rr_pernode_dirty, num_rr, pernode_str);
223*8452SJohn.Wren.Kennedy@Sun.COM }
224*8452SJohn.Wren.Kennedy@Sun.COM }
225*8452SJohn.Wren.Kennedy@Sun.COM print_mm_cnt_c(rr_pnds, num_rr, "un_pernode_dirty_sum");
226*8452SJohn.Wren.Kennedy@Sun.COM
227*8452SJohn.Wren.Kennedy@Sun.COM print_mm_cnt_w(rr_ow, num_rr, "un_outstanding_writes");
228*8452SJohn.Wren.Kennedy@Sun.COM
229*8452SJohn.Wren.Kennedy@Sun.COM return (DCMD_OK);
230*8452SJohn.Wren.Kennedy@Sun.COM }
231