aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>2004-09-20 08:52:04 +0000
committerBrian Somers <brian@FreeBSD.org>2004-09-20 08:52:04 +0000
commita04946cf6ecdbcb344bddb246cd0f5b377268022 (patch)
tree89f989e68ef4800f4e516c65ea1ad8ebdf3d23f4 /sys
parent82ad8eff9ebeba3a1761795bf80e12789bd3515c (diff)
downloadsrc-a04946cf6ecdbcb344bddb246cd0f5b377268022.tar.gz
src-a04946cf6ecdbcb344bddb246cd0f5b377268022.zip
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
Notes
Notes: svn path=/head/; revision=135510
Diffstat (limited to 'sys')
-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 c2b749fb0e0d..cfbc9d550541 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)