summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mbuf.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2004-09-20 08:52:04 +0000
committerbrian <brian@FreeBSD.org>2004-09-20 08:52:04 +0000
commit255869f38742c021238fcbd7b42b873bd386abc1 (patch)
tree89f989e68ef4800f4e516c65ea1ad8ebdf3d23f4 /sys/kern/kern_mbuf.c
parent47d07987e28789eba8ae76f7d2389cba299f0e8a (diff)
downloadFreeBSD-src-255869f38742c021238fcbd7b42b873bd386abc1.zip
FreeBSD-src-255869f38742c021238fcbd7b42b873bd386abc1.tar.gz
CTASSERT that MSZIE is a power of 2 (otherwise dtom() breaks)
Ask uma_zcreate() to align mbufs to MSIZE bytes (otherwise dtom() breaks) As it happens, uma_zalloc_arg() always returned mbufs aligned to MSIZE anyway, but that was an implementation side-effect.... KASSERT -> CTASSERT suggested by: dd@ Approved by: silence on -net
Diffstat (limited to 'sys/kern/kern_mbuf.c')
-rw-r--r--sys/kern/kern_mbuf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index c2b749f..cfbc9d5 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -123,6 +123,9 @@ static void mb_fini_pack(void *, int);
static void mb_reclaim(void *);
static void mbuf_init(void *);
+/* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */
+CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE);
+
/*
* Initialize FreeBSD Network buffer allocation.
*/
@@ -135,7 +138,7 @@ mbuf_init(void *dummy)
* Configure UMA zones for Mbufs, Clusters, and Packets.
*/
zone_mbuf = uma_zcreate("Mbuf", MSIZE, mb_ctor_mbuf, mb_dtor_mbuf,
- NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_MAXBUCKET);
+ NULL, NULL, MSIZE - 1, UMA_ZONE_MAXBUCKET);
zone_clust = uma_zcreate("MbufClust", MCLBYTES, mb_ctor_clust,
mb_dtor_clust, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_REFCNT);
if (nmbclusters > 0)
OpenPOWER on IntegriCloud