Date: Fri, 10 Sep 2004 13:10:31 +0000 From: Dima Dorfman <dd@freebsd.org> To: Brian Somers <brian@Awfulhak.org> Cc: freebsd-net@freebsd.org Subject: Re: uma_zcreate() call from kern_mbuf.c - bug? Message-ID: <20040910131030.GB7453@trit.org> In-Reply-To: <20040909214600.12bb5fd5@dev.lan.Awfulhak.org> References: <20040909214600.12bb5fd5@dev.lan.Awfulhak.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Brian Somers <brian@Awfulhak.org> wrote: > Of course m_get() et. al. seem to manage to get MSIZE aligned pointers back > from uma_zalloc_arg(zone_mbuf...) anyway, but surely that's an implementation > side effect and the align argument should be corrected. This change looks right to me, but I'm hardly an expert here. > There should probably also be a KASSERT here to ensure that MSIZE is sane This might be better as a CTASSERT: Index: kern_mbuf.c =================================================================== RCS file: /ref/cvsf/src/sys/kern/kern_mbuf.c,v retrieving revision 1.3 diff -u -r1.3 kern_mbuf.c --- kern_mbuf.c 2 Aug 2004 00:18:35 -0000 1.3 +++ kern_mbuf.c 10 Sep 2004 06:53:10 -0000 @@ -123,6 +123,9 @@ static void mb_reclaim(void *); static void mbuf_init(void *); +/* Ensure that MSIZE doesn't break dtom(). */ +CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); + /* * Initialize FreeBSD Network buffer allocation. */ @@ -135,7 +138,7 @@ * 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040910131030.GB7453>