diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2000-08-19 08:32:59 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2000-08-19 08:32:59 +0000 |
commit | df0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4 (patch) | |
tree | 47f526cc36bae230ba5426a392413b1b46c0d678 /usr.bin | |
parent | 2f92e39a0fe52366609e44e5a1978feb243c8755 (diff) | |
download | FreeBSD-src-df0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4.zip FreeBSD-src-df0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4.tar.gz |
Replace the mbuf external reference counting code with something
that should be better.
The old code counted references to mbuf clusters by using the offset
of the cluster from the start of memory allocated for mbufs and
clusters as an index into an array of chars, which did the reference
counting. If the external storage was not a cluster then reference
counting had to be done by the code using that external storage.
NetBSD's system of linked lists of mbufs was cosidered, but Alfred
felt it would have locking issues when the kernel was made more
SMP friendly.
The system implimented uses a pool of unions to track external
storage. The union contains an int for counting the references and
a pointer for forming a free list. The reference counts are
incremented and decremented atomically and so should be SMP friendly.
This system can track reference counts for any sort of external
storage.
Access to the reference counting stuff is now through macros defined
in mbuf.h, so it should be easier to make changes to the system in
the future.
The possibility of storing the reference count in one of the
referencing mbufs was considered, but was rejected 'cos it would
often leave extra mbufs allocated. Storing the reference count in
the cluster was also considered, but because the external storage
may not be a cluster this isn't an option.
The size of the pool of reference counters is available in the
stats provided by "netstat -m".
PR: 19866
Submitted by: Bosko Milekic <bmilekic@dsuper.net>
Reviewed by: alfred (glanced at by others on -net)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/mbuf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c index 6ad3fdb..32c0751 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -176,9 +176,13 @@ mbpr() printf("%lu/%lu/%u mbuf clusters in use (current/peak/max)\n", mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters, nmbclusters); - totmem = mbstat.m_mbufs * MSIZE + mbstat.m_clusters * MCLBYTES; + printf("%lu/%lu m_ext reference counters (in use/allocated)\n", + mbstat.m_refcnt - mbstat.m_refree, mbstat.m_refcnt); + totmem = mbstat.m_mbufs * MSIZE + mbstat.m_clusters * MCLBYTES + + mbstat.m_refcnt * sizeof(union mext_refcnt); totfree = mbstat.m_clfree * MCLBYTES + - MSIZE * (mbstat.m_mbufs - totmbufs); + MSIZE * (mbstat.m_mbufs - totmbufs) + mbstat.m_refree * + sizeof(union mext_refcnt); printf("%u Kbytes allocated to network (%d%% in use)\n", totmem / 1024, (unsigned) (totmem - totfree) * 100 / totmem); printf("%lu requests for memory denied\n", mbstat.m_drops); |