1/* 2 * Copyright (c) 1983, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)mbuf.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] =
| 1/* 2 * Copyright (c) 1983, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)mbuf.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] =
|
39 "$FreeBSD: head/usr.bin/netstat/mbuf.c 80720 2001-07-31 08:19:49Z bmilekic $";
| 39 "$FreeBSD: head/usr.bin/netstat/mbuf.c 84153 2001-09-30 01:58:39Z bmilekic $";
|
40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/mbuf.h> 44#include <sys/protosw.h> 45#include <sys/socket.h> 46#include <sys/sysctl.h> 47 48#include <err.h> 49#include <stdio.h> 50#include <stdlib.h> 51#include <string.h> 52#include "netstat.h" 53 54#define YES 1 55typedef int bool; 56
| 40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/mbuf.h> 44#include <sys/protosw.h> 45#include <sys/socket.h> 46#include <sys/sysctl.h> 47 48#include <err.h> 49#include <stdio.h> 50#include <stdlib.h> 51#include <string.h> 52#include "netstat.h" 53 54#define YES 1 55typedef int bool; 56
|
57/* XXX: mbtypes stats temporarily disactivated. */ 58#if 0
| |
59static struct mbtypenames {
| 57static struct mbtypenames {
|
60 int mt_type;
| 58 short mt_type;
|
61 char *mt_name; 62} mbtypenames[] = { 63 { MT_DATA, "data" }, 64 { MT_OOBDATA, "oob data" }, 65 { MT_CONTROL, "ancillary data" }, 66 { MT_HEADER, "packet headers" }, 67#ifdef MT_SOCKET 68 { MT_SOCKET, "socket structures" }, /* XXX */ 69#endif 70#ifdef MT_PCB 71 { MT_PCB, "protocol control blocks" }, /* XXX */ 72#endif 73#ifdef MT_RTABLE 74 { MT_RTABLE, "routing table entries" }, /* XXX */ 75#endif 76#ifdef MT_HTABLE 77 { MT_HTABLE, "IMP host table entries" }, /* XXX */ 78#endif 79#ifdef MT_ATABLE 80 { MT_ATABLE, "address resolution tables" }, 81#endif 82 { MT_FTABLE, "fragment reassembly queue headers" }, /* XXX */ 83 { MT_SONAME, "socket names and addresses" }, 84#ifdef MT_SOOPTS 85 { MT_SOOPTS, "socket options" }, 86#endif 87#ifdef MT_RIGHTS 88 { MT_RIGHTS, "access rights" }, 89#endif 90#ifdef MT_IFADDR 91 { MT_IFADDR, "interface addresses" }, /* XXX */ 92#endif 93 { 0, 0 } 94};
| 59 char *mt_name; 60} mbtypenames[] = { 61 { MT_DATA, "data" }, 62 { MT_OOBDATA, "oob data" }, 63 { MT_CONTROL, "ancillary data" }, 64 { MT_HEADER, "packet headers" }, 65#ifdef MT_SOCKET 66 { MT_SOCKET, "socket structures" }, /* XXX */ 67#endif 68#ifdef MT_PCB 69 { MT_PCB, "protocol control blocks" }, /* XXX */ 70#endif 71#ifdef MT_RTABLE 72 { MT_RTABLE, "routing table entries" }, /* XXX */ 73#endif 74#ifdef MT_HTABLE 75 { MT_HTABLE, "IMP host table entries" }, /* XXX */ 76#endif 77#ifdef MT_ATABLE 78 { MT_ATABLE, "address resolution tables" }, 79#endif 80 { MT_FTABLE, "fragment reassembly queue headers" }, /* XXX */ 81 { MT_SONAME, "socket names and addresses" }, 82#ifdef MT_SOOPTS 83 { MT_SOOPTS, "socket options" }, 84#endif 85#ifdef MT_RIGHTS 86 { MT_RIGHTS, "access rights" }, 87#endif 88#ifdef MT_IFADDR 89 { MT_IFADDR, "interface addresses" }, /* XXX */ 90#endif 91 { 0, 0 } 92};
|
95#endif /* 0 */
| |
96 97/* 98 * Print mbuf statistics. 99 */ 100void 101mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr, 102 u_long mblimaddr, u_long cllimaddr, u_long cpusaddr, u_long pgsaddr, 103 u_long mbpaddr) 104{
| 93 94/* 95 * Print mbuf statistics. 96 */ 97void 98mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr, 99 u_long mblimaddr, u_long cllimaddr, u_long cpusaddr, u_long pgsaddr, 100 u_long mbpaddr) 101{
|
105 int i, nmbufs, nmbclusters, page_size, num_objs;
| 102 int i, j, nmbufs, nmbclusters, page_size, num_objs;
|
106 u_int mbuf_limit, clust_limit; 107 u_long totspace[2], totused[2], totnum, totfree;
| 103 u_int mbuf_limit, clust_limit; 104 u_long totspace[2], totused[2], totnum, totfree;
|
| 105 short nmbtypes;
|
108 size_t mlen;
| 106 size_t mlen;
|
| 107 long *mbtypes = NULL;
|
109 struct mbstat *mbstat = NULL; 110 struct mbpstat **mbpstat = NULL;
| 108 struct mbstat *mbstat = NULL; 109 struct mbpstat **mbpstat = NULL;
|
111 112/* XXX: mbtypes stats temporarily disabled. */ 113#if 0 114 int nmbtypes; 115 size_t mbtypeslen;
| |
116 struct mbtypenames *mp;
| 110 struct mbtypenames *mp;
|
117 u_long *mbtypes = NULL;
| |
118 bool *seen = NULL; 119
| 111 bool *seen = NULL; 112
|
120 /* 121 * XXX 122 * We can't kread() mbtypeslen from a core image so we'll 123 * bogusly assume it's the same as in the running kernel. 124 */ 125 if (sysctlbyname("kern.ipc.mbtypes", NULL, &mbtypeslen, NULL, 0) < 0) { 126 warn("sysctl: retrieving mbtypes length"); 127 goto err; 128 } 129 if ((mbtypes = malloc(mbtypeslen)) == NULL) { 130 warn("malloc: %lu bytes for mbtypes", (u_long)mbtypeslen); 131 goto err; 132 } 133 134 nmbtypes = mbtypeslen / sizeof(*mbtypes); 135 if ((seen = calloc(nmbtypes, sizeof(*seen))) == NULL) { 136 warn("calloc"); 137 goto err; 138 } 139#endif 140
| |
141 mlen = sizeof *mbstat; 142 if ((mbstat = malloc(mlen)) == NULL) { 143 warn("malloc: cannot allocate memory for mbstat"); 144 goto err; 145 } 146 147 /* 148 * XXX: Unfortunately, for the time being, we have to fetch 149 * the total length of the per-CPU stats area via sysctl 150 * (regardless of whether we're looking at a core or not. 151 */ 152 if (sysctlbyname("kern.ipc.mb_statpcpu", NULL, &mlen, NULL, 0) < 0) { 153 warn("sysctl: retrieving mb_statpcpu len"); 154 goto err; 155 } 156 num_objs = (int)(mlen / sizeof(struct mbpstat)); 157 if ((mbpstat = calloc(num_objs, sizeof(struct mbpstat *))) == NULL) { 158 warn("calloc: cannot allocate memory for mbpstats pointers"); 159 goto err; 160 } 161 if ((mbpstat[0] = calloc(num_objs, sizeof(struct mbpstat))) == NULL) { 162 warn("calloc: cannot allocate memory for mbpstats"); 163 goto err; 164 } 165 166 if (mbaddr) { 167 if (kread(mbpaddr, (char *)mbpstat[0], mlen)) 168 goto err; 169 if (kread(mbaddr, (char *)mbstat, sizeof mbstat)) 170 goto err;
| 113 mlen = sizeof *mbstat; 114 if ((mbstat = malloc(mlen)) == NULL) { 115 warn("malloc: cannot allocate memory for mbstat"); 116 goto err; 117 } 118 119 /* 120 * XXX: Unfortunately, for the time being, we have to fetch 121 * the total length of the per-CPU stats area via sysctl 122 * (regardless of whether we're looking at a core or not. 123 */ 124 if (sysctlbyname("kern.ipc.mb_statpcpu", NULL, &mlen, NULL, 0) < 0) { 125 warn("sysctl: retrieving mb_statpcpu len"); 126 goto err; 127 } 128 num_objs = (int)(mlen / sizeof(struct mbpstat)); 129 if ((mbpstat = calloc(num_objs, sizeof(struct mbpstat *))) == NULL) { 130 warn("calloc: cannot allocate memory for mbpstats pointers"); 131 goto err; 132 } 133 if ((mbpstat[0] = calloc(num_objs, sizeof(struct mbpstat))) == NULL) { 134 warn("calloc: cannot allocate memory for mbpstats"); 135 goto err; 136 } 137 138 if (mbaddr) { 139 if (kread(mbpaddr, (char *)mbpstat[0], mlen)) 140 goto err; 141 if (kread(mbaddr, (char *)mbstat, sizeof mbstat)) 142 goto err;
|
171#if 0 172 if (kread(mbtaddr, (char *)mbtypes, mbtypeslen)) 173 goto err; 174#endif
| |
175 if (kread(nmbcaddr, (char *)&nmbclusters, sizeof(int))) 176 goto err; 177 if (kread(nmbufaddr, (char *)&nmbufs, sizeof(int))) 178 goto err; 179 if (kread(mblimaddr, (char *)&mbuf_limit, sizeof(u_int))) 180 goto err; 181 if (kread(cllimaddr, (char *)&clust_limit, sizeof(u_int))) 182 goto err; 183 if (kread(pgsaddr, (char *)&page_size, sizeof(int))) 184 goto err; 185 } else { 186 if (sysctlbyname("kern.ipc.mb_statpcpu", mbpstat[0], &mlen, 187 NULL, 0) < 0) { 188 warn("sysctl: retrieving mb_statpcpu"); 189 goto err; 190 } 191 mlen = sizeof *mbstat; 192 if (sysctlbyname("kern.ipc.mbstat", mbstat, &mlen, NULL, 0) 193 < 0) { 194 warn("sysctl: retrieving mbstat"); 195 goto err; 196 }
| 143 if (kread(nmbcaddr, (char *)&nmbclusters, sizeof(int))) 144 goto err; 145 if (kread(nmbufaddr, (char *)&nmbufs, sizeof(int))) 146 goto err; 147 if (kread(mblimaddr, (char *)&mbuf_limit, sizeof(u_int))) 148 goto err; 149 if (kread(cllimaddr, (char *)&clust_limit, sizeof(u_int))) 150 goto err; 151 if (kread(pgsaddr, (char *)&page_size, sizeof(int))) 152 goto err; 153 } else { 154 if (sysctlbyname("kern.ipc.mb_statpcpu", mbpstat[0], &mlen, 155 NULL, 0) < 0) { 156 warn("sysctl: retrieving mb_statpcpu"); 157 goto err; 158 } 159 mlen = sizeof *mbstat; 160 if (sysctlbyname("kern.ipc.mbstat", mbstat, &mlen, NULL, 0) 161 < 0) { 162 warn("sysctl: retrieving mbstat"); 163 goto err; 164 }
|
197#if 0 198 if (sysctlbyname("kern.ipc.mbtypes", mbtypes, &mbtypeslen, NULL, 199 0) < 0) { 200 warn("sysctl: retrieving mbtypes"); 201 goto err; 202 } 203#endif
| |
204 mlen = sizeof(int); 205 if (sysctlbyname("kern.ipc.nmbclusters", &nmbclusters, &mlen, 206 NULL, 0) < 0) { 207 warn("sysctl: retrieving nmbclusters"); 208 goto err; 209 } 210 mlen = sizeof(int); 211 if (sysctlbyname("kern.ipc.nmbufs", &nmbufs, &mlen, NULL, 0) 212 < 0) { 213 warn("sysctl: retrieving nmbufs"); 214 goto err; 215 } 216 mlen = sizeof(u_int); 217 if (sysctlbyname("kern.ipc.mbuf_limit", &mbuf_limit, &mlen, 218 NULL, 0) < 0) { 219 warn("sysctl: retrieving mbuf_limit"); 220 goto err; 221 } 222 mlen = sizeof(u_int); 223 if (sysctlbyname("kern.ipc.clust_limit", &clust_limit, &mlen, 224 NULL, 0) < 0) { 225 warn("sysctl: retrieving clust_limit"); 226 goto err; 227 } 228 mlen = sizeof(int); 229 if (sysctlbyname("hw.pagesize", &page_size, &mlen, NULL, 0) 230 < 0) { 231 warn("sysctl: retrieving hw.pagesize"); 232 goto err; 233 } 234 } 235
| 165 mlen = sizeof(int); 166 if (sysctlbyname("kern.ipc.nmbclusters", &nmbclusters, &mlen, 167 NULL, 0) < 0) { 168 warn("sysctl: retrieving nmbclusters"); 169 goto err; 170 } 171 mlen = sizeof(int); 172 if (sysctlbyname("kern.ipc.nmbufs", &nmbufs, &mlen, NULL, 0) 173 < 0) { 174 warn("sysctl: retrieving nmbufs"); 175 goto err; 176 } 177 mlen = sizeof(u_int); 178 if (sysctlbyname("kern.ipc.mbuf_limit", &mbuf_limit, &mlen, 179 NULL, 0) < 0) { 180 warn("sysctl: retrieving mbuf_limit"); 181 goto err; 182 } 183 mlen = sizeof(u_int); 184 if (sysctlbyname("kern.ipc.clust_limit", &clust_limit, &mlen, 185 NULL, 0) < 0) { 186 warn("sysctl: retrieving clust_limit"); 187 goto err; 188 } 189 mlen = sizeof(int); 190 if (sysctlbyname("hw.pagesize", &page_size, &mlen, NULL, 0) 191 < 0) { 192 warn("sysctl: retrieving hw.pagesize"); 193 goto err; 194 } 195 } 196
|
| 197 nmbtypes = mbstat->m_numtypes; 198 if ((seen = calloc(nmbtypes, sizeof(*seen))) == NULL) { 199 warn("calloc: cannot allocate memory for mbtypes seen flag"); 200 goto err; 201 } 202 if ((mbtypes = calloc(nmbtypes, sizeof(long *))) == NULL) { 203 warn("calloc: cannot allocate memory for mbtypes"); 204 goto err; 205 } 206
|
236 for (i = 0; i < num_objs; i++) 237 mbpstat[i] = mbpstat[0] + i; 238 239#undef MSIZE 240#define MSIZE (mbstat->m_msize) 241#undef MCLBYTES 242#define MCLBYTES (mbstat->m_mclbytes) 243#define MBPERPG (page_size / MSIZE) 244#define CLPERPG (page_size / MCLBYTES) 245#define GENLST (num_objs - 1) 246 247 printf("mbuf usage:\n"); 248 printf("\tGEN list:\t%lu/%lu (in use/in pool)\n", 249 (mbpstat[GENLST]->mb_mbpgs * MBPERPG - mbpstat[GENLST]->mb_mbfree), 250 (mbpstat[GENLST]->mb_mbpgs * MBPERPG)); 251 totnum = mbpstat[GENLST]->mb_mbpgs * MBPERPG; 252 totfree = mbpstat[GENLST]->mb_mbfree;
| 207 for (i = 0; i < num_objs; i++) 208 mbpstat[i] = mbpstat[0] + i; 209 210#undef MSIZE 211#define MSIZE (mbstat->m_msize) 212#undef MCLBYTES 213#define MCLBYTES (mbstat->m_mclbytes) 214#define MBPERPG (page_size / MSIZE) 215#define CLPERPG (page_size / MCLBYTES) 216#define GENLST (num_objs - 1) 217 218 printf("mbuf usage:\n"); 219 printf("\tGEN list:\t%lu/%lu (in use/in pool)\n", 220 (mbpstat[GENLST]->mb_mbpgs * MBPERPG - mbpstat[GENLST]->mb_mbfree), 221 (mbpstat[GENLST]->mb_mbpgs * MBPERPG)); 222 totnum = mbpstat[GENLST]->mb_mbpgs * MBPERPG; 223 totfree = mbpstat[GENLST]->mb_mbfree;
|
| 224 for (j = 1; j < nmbtypes; j++) 225 mbtypes[j] += mbpstat[GENLST]->mb_mbtypes[j];
|
253 totspace[0] = mbpstat[GENLST]->mb_mbpgs * page_size; 254 for (i = 0; i < (num_objs - 1); i++) { 255 if (mbpstat[i]->mb_active == 0) 256 continue; 257 printf("\tCPU #%d list:\t%lu/%lu (in use/in pool)\n", i, 258 (mbpstat[i]->mb_mbpgs * MBPERPG - mbpstat[i]->mb_mbfree), 259 (mbpstat[i]->mb_mbpgs * MBPERPG)); 260 totspace[0] += mbpstat[i]->mb_mbpgs * page_size; 261 totnum += mbpstat[i]->mb_mbpgs * MBPERPG; 262 totfree += mbpstat[i]->mb_mbfree;
| 226 totspace[0] = mbpstat[GENLST]->mb_mbpgs * page_size; 227 for (i = 0; i < (num_objs - 1); i++) { 228 if (mbpstat[i]->mb_active == 0) 229 continue; 230 printf("\tCPU #%d list:\t%lu/%lu (in use/in pool)\n", i, 231 (mbpstat[i]->mb_mbpgs * MBPERPG - mbpstat[i]->mb_mbfree), 232 (mbpstat[i]->mb_mbpgs * MBPERPG)); 233 totspace[0] += mbpstat[i]->mb_mbpgs * page_size; 234 totnum += mbpstat[i]->mb_mbpgs * MBPERPG; 235 totfree += mbpstat[i]->mb_mbfree;
|
| 236 for (j = 1; j < nmbtypes; j++) 237 mbtypes[j] += mbpstat[i]->mb_mbtypes[j];
|
263 } 264 totused[0] = totnum - totfree; 265 printf("\tTotal:\t\t%lu/%lu (in use/in pool)\n", totused[0], totnum); 266 printf("\tMaximum number allowed on each CPU list: %d\n", mbuf_limit); 267 printf("\tMaximum possible: %d\n", nmbufs);
| 238 } 239 totused[0] = totnum - totfree; 240 printf("\tTotal:\t\t%lu/%lu (in use/in pool)\n", totused[0], totnum); 241 printf("\tMaximum number allowed on each CPU list: %d\n", mbuf_limit); 242 printf("\tMaximum possible: %d\n", nmbufs);
|
| 243 printf("\tAllocated mbuf types:\n"); 244 for (mp = mbtypenames; mp->mt_name; mp++) { 245 if (mbtypes[mp->mt_type]) { 246 seen[mp->mt_type] = YES; 247 printf("\t %lu mbufs allocated to %s\n", 248 mbtypes[mp->mt_type], mp->mt_name); 249 } 250 } 251 for (i = 1; i < nmbtypes; i++) { 252 if (!seen[i] && mbtypes[i]) 253 printf("\t %lu mbufs allocated to <mbuf type: %d>\n", 254 mbtypes[i], i); 255 }
|
268 printf("\t%lu%% of mbuf map consumed\n", ((totspace[0] * 100) / (nmbufs 269 * MSIZE))); 270 271 printf("mbuf cluster usage:\n"); 272 printf("\tGEN list:\t%lu/%lu (in use/in pool)\n", 273 (mbpstat[GENLST]->mb_clpgs * CLPERPG - mbpstat[GENLST]->mb_clfree), 274 (mbpstat[GENLST]->mb_clpgs * CLPERPG)); 275 totnum = mbpstat[GENLST]->mb_clpgs * CLPERPG; 276 totfree = mbpstat[GENLST]->mb_clfree; 277 totspace[1] = mbpstat[GENLST]->mb_clpgs * page_size; 278 for (i = 0; i < (num_objs - 1); i++) { 279 if (mbpstat[i]->mb_active == 0) 280 continue; 281 printf("\tCPU #%d list:\t%lu/%lu (in use/in pool)\n", i, 282 (mbpstat[i]->mb_clpgs * CLPERPG - mbpstat[i]->mb_clfree), 283 (mbpstat[i]->mb_clpgs * CLPERPG)); 284 totspace[1] += mbpstat[i]->mb_clpgs * page_size; 285 totnum += mbpstat[i]->mb_clpgs * CLPERPG; 286 totfree += mbpstat[i]->mb_clfree; 287 } 288 totused[1] = totnum - totfree; 289 printf("\tTotal:\t\t%lu/%lu (in use/in pool)\n", totused[1], totnum); 290 printf("\tMaximum number allowed on each CPU list: %d\n", clust_limit); 291 printf("\tMaximum possible: %d\n", nmbclusters); 292 printf("\t%lu%% of cluster map consumed\n", ((totspace[1] * 100) / 293 (nmbclusters * MCLBYTES))); 294 295 printf("%lu KBytes of wired memory reserved (%lu%% in use)\n", 296 (totspace[0] + totspace[1]) / 1024, ((totused[0] * MSIZE + 297 totused[1] * MCLBYTES) * 100) / (totspace[0] + totspace[1])); 298 printf("%lu requests for memory denied\n", mbstat->m_drops); 299 printf("%lu requests for memory delayed\n", mbstat->m_wait); 300 printf("%lu calls to protocol drain routines\n", mbstat->m_drain); 301 302err:
| 256 printf("\t%lu%% of mbuf map consumed\n", ((totspace[0] * 100) / (nmbufs 257 * MSIZE))); 258 259 printf("mbuf cluster usage:\n"); 260 printf("\tGEN list:\t%lu/%lu (in use/in pool)\n", 261 (mbpstat[GENLST]->mb_clpgs * CLPERPG - mbpstat[GENLST]->mb_clfree), 262 (mbpstat[GENLST]->mb_clpgs * CLPERPG)); 263 totnum = mbpstat[GENLST]->mb_clpgs * CLPERPG; 264 totfree = mbpstat[GENLST]->mb_clfree; 265 totspace[1] = mbpstat[GENLST]->mb_clpgs * page_size; 266 for (i = 0; i < (num_objs - 1); i++) { 267 if (mbpstat[i]->mb_active == 0) 268 continue; 269 printf("\tCPU #%d list:\t%lu/%lu (in use/in pool)\n", i, 270 (mbpstat[i]->mb_clpgs * CLPERPG - mbpstat[i]->mb_clfree), 271 (mbpstat[i]->mb_clpgs * CLPERPG)); 272 totspace[1] += mbpstat[i]->mb_clpgs * page_size; 273 totnum += mbpstat[i]->mb_clpgs * CLPERPG; 274 totfree += mbpstat[i]->mb_clfree; 275 } 276 totused[1] = totnum - totfree; 277 printf("\tTotal:\t\t%lu/%lu (in use/in pool)\n", totused[1], totnum); 278 printf("\tMaximum number allowed on each CPU list: %d\n", clust_limit); 279 printf("\tMaximum possible: %d\n", nmbclusters); 280 printf("\t%lu%% of cluster map consumed\n", ((totspace[1] * 100) / 281 (nmbclusters * MCLBYTES))); 282 283 printf("%lu KBytes of wired memory reserved (%lu%% in use)\n", 284 (totspace[0] + totspace[1]) / 1024, ((totused[0] * MSIZE + 285 totused[1] * MCLBYTES) * 100) / (totspace[0] + totspace[1])); 286 printf("%lu requests for memory denied\n", mbstat->m_drops); 287 printf("%lu requests for memory delayed\n", mbstat->m_wait); 288 printf("%lu calls to protocol drain routines\n", mbstat->m_drain); 289 290err:
|
303#if 0
| |
304 if (mbtypes != NULL) 305 free(mbtypes); 306 if (seen != NULL) 307 free(seen);
| 291 if (mbtypes != NULL) 292 free(mbtypes); 293 if (seen != NULL) 294 free(seen);
|
308#endif
| |
309 if (mbstat != NULL) 310 free(mbstat); 311 if (mbpstat != NULL) { 312 if (mbpstat[0] != NULL) 313 free(mbpstat[0]); 314 free(mbpstat); 315 } 316 317 return; 318}
| 295 if (mbstat != NULL) 296 free(mbstat); 297 if (mbpstat != NULL) { 298 if (mbpstat[0] != NULL) 299 free(mbpstat[0]); 300 free(mbpstat); 301 } 302 303 return; 304}
|