From owner-freebsd-net@FreeBSD.ORG Fri Sep 10 13:14:00 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 7B92E16A4CE; Fri, 10 Sep 2004 13:14:00 +0000 (GMT) Received: from gw.Awfulhak.org (awfulhak.demon.co.uk [80.177.173.150]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7452243D5A; Fri, 10 Sep 2004 13:13:59 +0000 (GMT) (envelope-from brian@Awfulhak.org) Received: from mail.awfulhak.org (www@localhost [127.0.0.1]) by gw.Awfulhak.org (8.12.11/8.12.11) with ESMTP id i8ADDc2b001768; Fri, 10 Sep 2004 14:13:38 +0100 (BST) (envelope-from brian@Awfulhak.org) Received: from 192.18.1.9 (SquirrelMail authenticated user brian); by mail.Awfulhak.org with HTTP; Fri, 10 Sep 2004 14:13:38 +0100 (BST) Message-ID: <42009.192.18.1.9.1094822018.squirrel@192.18.1.9> In-Reply-To: <20040910131030.GB7453@trit.org> References: <20040909214600.12bb5fd5@dev.lan.Awfulhak.org> <20040910131030.GB7453@trit.org> Date: Fri, 10 Sep 2004 14:13:38 +0100 (BST) From: "Brian Somers" To: "Dima Dorfman" User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.64 X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on gw.lan.Awfulhak.org cc: Brian Somers 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:14:00 -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) > > Agreed. I didn't know about CTASSERT()! Cheers. -- Brian Don't _EVER_ lose your sense of humour !