From owner-freebsd-net@FreeBSD.ORG Fri Sep 10 13:10:59 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2BF0816A4CE for ; Fri, 10 Sep 2004 13:10:59 +0000 (GMT) Received: from charade.trit.org (charade.trit.org [65.19.139.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id 174F543D45 for ; Fri, 10 Sep 2004 13:10:59 +0000 (GMT) (envelope-from dd@freebsd.org) Received: by charade.trit.org (Postfix, from userid 408) id EAE2441; Fri, 10 Sep 2004 13:10:58 +0000 (UTC) Received: from harpoon.trit.org (pub-4.ica.trit.net [69.107.245.244]) by charade.trit.org (Postfix) with ESMTP id CB83066; Fri, 10 Sep 2004 13:10:57 +0000 (UTC) Received: from harpoon.trit.org (localhost [127.0.0.1]) by harpoon.trit.org (8.13.1/8.12.9) with ESMTP id i8ADAVHp007631; Fri, 10 Sep 2004 13:10:31 GMT (envelope-from dd@freebsd.org) Received: (from dima@localhost) by harpoon.trit.org (8.13.1/8.12.11/Submit) id i8ADAVcX007630; Fri, 10 Sep 2004 13:10:31 GMT (envelope-from dd@freebsd.org) X-Authentication-Warning: harpoon.trit.org: dima set sender to dd@freebsd.org using -f Date: Fri, 10 Sep 2004 13:10:31 +0000 From: Dima Dorfman To: Brian Somers Message-ID: <20040910131030.GB7453@trit.org> References: <20040909214600.12bb5fd5@dev.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040909214600.12bb5fd5@dev.lan.Awfulhak.org> User-Agent: Mutt/1.4i X-PGP-Key: 69FAE582 (http://www.trit.org/~dima/dima.asc) X-PGP-Fingerprint: B340 8338 7DA3 4D61 7632 098E 0730 055B 69FA E582 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on charade.trit.org X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 cc: freebsd-net@freebsd.org Subject: Re: uma_zcreate() call from kern_mbuf.c - bug? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2004 13:10:59 -0000 Brian Somers 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)