- printf("mbufs:");
- klseek(kmem, mbaddr, 0);
- if (read(kmem, &mbstat, sizeof (mbstat)) == sizeof (mbstat))
- printf(
- " mbufs %d mbfree %d clusters %d clfree %d drops %d\n",
- mbstat.m_mbufs, mbstat.m_mbfree,
- mbstat.m_clusters, mbstat.m_clfree, mbstat.m_drops);
+ if (kvm_read(mbaddr, (char *)&mbstat, sizeof (mbstat))
+ != sizeof (mbstat)) {
+ printf("mbstat: bad read\n");
+ return;
+ }
+ totmbufs = 0;
+ for (mp = mbtypes; mp->mt_name; mp++)
+ totmbufs += mbstat.m_mtypes[mp->mt_type];
+ printf("%u mbufs in use:\n", totmbufs);
+ for (mp = mbtypes; mp->mt_name; mp++)
+ if (mbstat.m_mtypes[mp->mt_type]) {
+ seen[mp->mt_type] = YES;
+ printf("\t%u mbufs allocated to %s\n",
+ mbstat.m_mtypes[mp->mt_type], mp->mt_name);
+ }
+ seen[MT_FREE] = YES;
+ for (i = 0; i < nmbtypes; i++)
+ if (!seen[i] && mbstat.m_mtypes[i]) {
+ printf("\t%u mbufs allocated to <mbuf type %d>\n",
+ mbstat.m_mtypes[i], i);
+ }
+ printf("%u/%u mapped pages in use\n",
+ mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);
+ totmem = totmbufs * MSIZE + mbstat.m_clusters * CLBYTES;
+ totfree = mbstat.m_clfree * CLBYTES;
+ printf("%u Kbytes allocated to network (%d%% in use)\n",
+ totmem / 1024, (totmem - totfree) * 100 / totmem);
+ printf("%u requests for memory denied\n", mbstat.m_drops);
+ printf("%u requests for memory delayed\n", mbstat.m_wait);
+ printf("%u calls to protocol drain routines\n", mbstat.m_drain);