Commit | Line | Data |
---|---|---|
bad4305f | 1 | #ifndef lint |
c02627d4 | 2 | static char sccsid[] = "@(#)mbuf.c 4.5 82/12/18"; |
bad4305f SL |
3 | #endif |
4 | ||
24bf5f10 | 5 | #include <sys/param.h> |
bad4305f SL |
6 | #include <sys/mbuf.h> |
7 | ||
8 | struct mbstat mbstat; | |
9 | extern int kmem; | |
10 | ||
02c6746b SL |
11 | static struct mbtypes { |
12 | int mt_type; | |
13 | char *mt_name; | |
14 | } mbtypes[] = { | |
15 | { MT_DATA, "data" }, | |
16 | { MT_HEADER, "packet headers" }, | |
17 | { MT_SOCKET, "socket structures" }, | |
18 | { MT_PCB, "protocol control blocks" }, | |
19 | { MT_RTABLE, "routing table entries" }, | |
20 | { MT_HTABLE, "IMP host table entries" }, | |
21 | #ifdef notdef | |
22 | { MT_ATABLE, "address resolution tables" }, | |
23 | #endif | |
24 | { MT_FTABLE, "fragment reassembly queue headers" }, | |
25 | { MT_SONAME, "socket names and addresses" }, | |
26 | { MT_ZOMBIE, "zombie process information" }, | |
27 | { MT_SOOPTS, "socket options" }, | |
28 | { 0, 0 } | |
29 | }; | |
30 | ||
bad4305f SL |
31 | /* |
32 | * Print mbuf statistics. | |
33 | */ | |
34 | mbpr(mbaddr) | |
35 | off_t mbaddr; | |
36 | { | |
02c6746b SL |
37 | register int totmem, totfree, totmbufs; |
38 | register struct mbtypes *mp; | |
24bf5f10 | 39 | |
bad4305f SL |
40 | if (mbaddr == 0) { |
41 | printf("mbstat: symbol not in namelist\n"); | |
42 | return; | |
43 | } | |
bad4305f | 44 | klseek(kmem, mbaddr, 0); |
24bf5f10 SL |
45 | if (read(kmem, &mbstat, sizeof (mbstat)) != sizeof (mbstat)) { |
46 | printf("mbstat: bad read\n"); | |
47 | return; | |
48 | } | |
02c6746b SL |
49 | printf("%d/%d mbufs in use:\n", |
50 | mbstat.m_mbufs - mbstat.m_mbfree, mbstat.m_mbufs); | |
51 | totmbufs = 0; | |
52 | for (mp = mbtypes; mp->mt_name; mp++) | |
53 | if (mbstat.m_mtypes[mp->mt_type]) { | |
54 | printf("\t%d mbufs allocated to %s\n", | |
55 | mbstat.m_mtypes[mp->mt_type], mp->mt_name); | |
56 | totmbufs += mbstat.m_mtypes[mp->mt_type]; | |
57 | } | |
58 | if (totmbufs != mbstat.m_mbufs - mbstat.m_mbfree) | |
59 | printf("*** %d mbufs missing ***\n", | |
60 | (mbstat.m_mbufs - mbstat.m_mbfree) - totmbufs); | |
84f2241b | 61 | printf("%d/%d mapped pages in use\n", |
24bf5f10 | 62 | mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters); |
24bf5f10 SL |
63 | totmem = mbstat.m_mbufs * MSIZE + mbstat.m_clusters * CLBYTES; |
64 | totfree = mbstat.m_mbfree * MSIZE + mbstat.m_clusters * CLBYTES; | |
02c6746b | 65 | printf("%d Kbytes allocated to network (%d%% in use)\n", |
c1567c4d | 66 | totmem / 1024, (totmem - totfree) * 100 / totmem); |
02c6746b | 67 | printf("%d requests for memory denied\n", mbstat.m_drops); |
bad4305f | 68 | } |