From owner-freebsd-net@FreeBSD.ORG Fri Feb 1 13:04:52 2013 Return-Path: Delivered-To: net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DA04E1BD for ; Fri, 1 Feb 2013 13:04:52 +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 C1A4239C for ; Fri, 1 Feb 2013 13:04:51 +0000 (UTC) Received: (qmail 42639 invoked from network); 1 Feb 2013 14:24:23 -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 ; 1 Feb 2013 14:24:23 -0000 Message-ID: <510BBD66.4080903@freebsd.org> Date: Fri, 01 Feb 2013 14:04:38 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: Gleb Smirnoff Subject: Re: m_get2() name References: <20130201120414.GG91075@FreeBSD.org> In-Reply-To: <20130201120414.GG91075@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: net@FreeBSD.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 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, 01 Feb 2013 13:04:52 -0000 On 01.02.2013 13:04, Gleb Smirnoff wrote: > Hi! > > The m_get2() function allocates a single mbuf with enough space > to hold specified amount of data. It can return either a single mbuf, > an mbuf with a standard cluster, page size cluster, or jumbo cluster. While m_get2() is a good function, I'm not too happy with it returning jumbo clusters. The size of jumbo cluster is not well specified and can be anything above 2K, from 4K to 16K or more. The network stack hacker can't rely on any particular size above PAGE_SIZE to be present. So I recommend to make PAGE_SIZE the largest cluster size to be available in a single mbuf allocator. PAGE_SIZE is a known quantity and plays well with the allocator. Anything larger than PAGE_SIZE causes contig_malloc to be used as the requirement is physically contiguous pages for those clusters. After some uptime this may become more difficult to allocate and can lead to premature allocation failures while still plenty of memory would be around. The allocation overhead for such jumbo zones is higher in UMA than for PAGE_SIZE clusters. There is also some overlap with m_getm2() which returns an mbuf chain of specified size. The only difference being chain vs. single mbuf. m_get2() can be simply implemented on top of m_getm2() by using the flags field to restrict it to one mbuf only instead of a chain to avoid code duplication. > It is alredy utilized in pfsync, bpf, libalias and soon to be utilized > in ieee802111. There are probably more places in stack where it can be used. > > The question is about its name. Once introduced, I just gave it name > "m_get2" to avoid discussion with myself about bikeshed colour and continue > hacking. Now it is getting used wider, and before we branch any stable branch > off the head, we have last chance to rename it to smth more meaningful. This is mostly matter of "compatibility" we want keep with original BSD code. The right names would be m_get() and m_getm() for single mbuf and chain allocations of a certain supplied minimum size. As far as I see it the other BSDs have evolved quite a bit and a significant number of differences exists these days making porting more involved than just copying the files. Having a clean API would be only a minor additional inconvenience IMHO. -- Andre