summaryrefslogtreecommitdiffstats
path: root/sys/alpha
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2000-08-19 08:32:59 +0000
committerdwmalone <dwmalone@FreeBSD.org>2000-08-19 08:32:59 +0000
commitdf0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4 (patch)
tree47f526cc36bae230ba5426a392413b1b46c0d678 /sys/alpha
parent2f92e39a0fe52366609e44e5a1978feb243c8755 (diff)
downloadFreeBSD-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 'sys/alpha')
-rw-r--r--sys/alpha/alpha/machdep.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c
index 02643ae..e5124d4 100644
--- a/sys/alpha/alpha/machdep.c
+++ b/sys/alpha/alpha/machdep.c
@@ -370,18 +370,16 @@ again:
(16*(ARG_MAX+(PAGE_SIZE*3))));
/*
- * Finally, allocate mbuf pool. Since mclrefcnt is an off-size
- * we use the more space efficient malloc in place of kmem_alloc.
+ * Finally, allocate mbuf pool.
*/
{
vm_offset_t mb_map_size;
- mb_map_size = nmbufs * MSIZE + nmbclusters * MCLBYTES;
+ mb_map_size = nmbufs * MSIZE + nmbclusters * MCLBYTES +
+ (nmbclusters + nmbufs / 4) * sizeof(union mext_refcnt);
mb_map_size = roundup2(mb_map_size, max(MCLBYTES, PAGE_SIZE));
- mclrefcnt = malloc(mb_map_size / MCLBYTES, M_MBUF, M_NOWAIT);
- bzero(mclrefcnt, mb_map_size / MCLBYTES);
- mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr,
- mb_map_size);
+ mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl,
+ &maxaddr, mb_map_size);
mb_map->system_map = 1;
}
OpenPOWER on IntegriCloud