From owner-svn-src-head@FreeBSD.ORG Sun Mar 17 09:02:23 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4CF07623 for ; Sun, 17 Mar 2013 09:02:23 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 9FE64868 for ; Sun, 17 Mar 2013 09:02:22 +0000 (UTC) Received: (qmail 84498 invoked from network); 17 Mar 2013 10:13:57 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 17 Mar 2013 10:13:57 -0000 Message-ID: <51458691.4090107@freebsd.org> Date: Sun, 17 Mar 2013 10:02:09 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: Gleb Smirnoff Subject: Re: svn commit: r248417 - head/sys/sys References: <201303170739.r2H7djP1098888@svn.freebsd.org> In-Reply-To: <201303170739.r2H7djP1098888@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 09:02:23 -0000 On 17.03.2013 08:39, Gleb Smirnoff wrote: > Author: glebius > Date: Sun Mar 17 07:39:45 2013 > New Revision: 248417 > URL: http://svnweb.freebsd.org/changeset/base/248417 > > Log: > Add MEXT_ALIGN() macro, similar to M_ALIGN() and MH_ALIGN(), but for > mbufs with external buffer. While you are cleaning up the mbuf usage wouldn't it make sense to remove these macros, instead of adding new ones, and use m_align() which handles all these cases internally? IMHO we should not have the caller worry about the different types of mbuf's but to be able to apply a particular function which then does the right thing. This would remove a lot of duplicated code all over the tree again. While discussing m_align() it should be extended to do the inverse from aligning to the end as well. Many times mbufs have to have an offset from the start of the mbuf as well (ethernet). A negative len value could be used for that like in a_adj(). PS: It's really great you're doing this spring-cleaning. The mbuf area is littered with historic, complex and duplicate macros, functions and code. -- Andre > Modified: > head/sys/sys/mbuf.h > > Modified: head/sys/sys/mbuf.h > ============================================================================== > --- head/sys/sys/mbuf.h Sun Mar 17 07:37:10 2013 (r248416) > +++ head/sys/sys/mbuf.h Sun Mar 17 07:39:45 2013 (r248417) > @@ -195,7 +195,7 @@ struct mbuf { > #define M_FIRSTFRAG 0x00001000 /* packet is first fragment */ > #define M_LASTFRAG 0x00002000 /* packet is last fragment */ > #define M_SKIP_FIREWALL 0x00004000 /* skip firewall processing */ > -#define M_FREELIST 0x00008000 /* mbuf is on the free list */ > + /* 0x00008000 free */ > #define M_VLANTAG 0x00010000 /* ether_vtag is valid */ > #define M_PROMISC 0x00020000 /* packet was not for us */ > #define M_NOFREE 0x00040000 /* do not free mbuf, embedded in cluster */ > @@ -708,6 +708,18 @@ m_last(struct mbuf *m) > } while (0) > > /* > + * As above, for mbuf with external storage. > + */ > +#define MEXT_ALIGN(m, len) do { \ > + KASSERT((m)->m_flags & M_EXT, \ > + ("%s: MEXT_ALIGN not an M_EXT mbuf", __func__)); \ > + KASSERT((m)->m_data == (m)->m_ext.ext_buf, \ > + ("%s: MEXT_ALIGN not a virgin mbuf", __func__)); \ > + (m)->m_data += ((m)->m_ext.ext_size - (len)) & \ > + ~(sizeof(long) - 1); \ > +} while (0) > + > +/* > * Compute the amount of space available before the current start of data in > * an mbuf. > * > >