From owner-svn-src-user@FreeBSD.ORG Thu Oct 10 20:06:34 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E20D3BAB; Thu, 10 Oct 2013 20:06:34 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CF527291C; Thu, 10 Oct 2013 20:06:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9AK6YXi039350; Thu, 10 Oct 2013 20:06:34 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9AK6YVD039347; Thu, 10 Oct 2013 20:06:34 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201310102006.r9AK6YVD039347@svn.freebsd.org> From: Andre Oppermann Date: Thu, 10 Oct 2013 20:06:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256296 - in user/andre/mbuf_staging: kern sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Oct 2013 20:06:35 -0000 Author: andre Date: Thu Oct 10 20:06:34 2013 New Revision: 256296 URL: http://svnweb.freebsd.org/changeset/base/256296 Log: Internalize the various mbuf and cluster UMA zones into kern/kern_mbuf.c. De-inline m_free() as well. There is some fallout in dev/cxgb, dev/cxgbe and dev/sfxge who (ab)use the current (non-)API to some extent. I still have to look at them in details to determine if one of the existing APIs can be used instead or if a new allocator function is necessary. Modified: user/andre/mbuf_staging/kern/kern_mbuf.c user/andre/mbuf_staging/sys/mbuf.h Modified: user/andre/mbuf_staging/kern/kern_mbuf.c ============================================================================== --- user/andre/mbuf_staging/kern/kern_mbuf.c Thu Oct 10 20:03:54 2013 (r256295) +++ user/andre/mbuf_staging/kern/kern_mbuf.c Thu Oct 10 20:06:34 2013 (r256296) @@ -97,6 +97,17 @@ __FBSDID("$FreeBSD$"); * */ +/* + * Zones from which we allocate. + */ +uma_zone_t zone_mbuf; +uma_zone_t zone_clust; +uma_zone_t zone_pack; +uma_zone_t zone_jumbop; +uma_zone_t zone_jumbo9; +uma_zone_t zone_jumbo16; +uma_zone_t zone_ext_refcnt; + int nmbufs; /* limits number of mbufs */ int nmbclusters; /* limits number of mbuf clusters */ int nmbjumbop; /* limits number of page size jumbo clusters */ @@ -108,6 +119,8 @@ static quad_t maxmbufmem; /* overall rea SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN, &maxmbufmem, 0, "Maximum real memory allocatable to various mbuf types"); +static uma_zone_t m_getzone(int); + /* * tunable_mbinit() has to be run before any mbuf allocations are done. */ @@ -261,17 +274,6 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbufs, "Maximum number of mbufs allowed"); /* - * Zones from which we allocate. - */ -uma_zone_t zone_mbuf; -uma_zone_t zone_clust; -uma_zone_t zone_pack; -uma_zone_t zone_jumbop; -uma_zone_t zone_jumbo9; -uma_zone_t zone_jumbo16; -uma_zone_t zone_ext_refcnt; - -/* * Local prototypes. */ static int mb_ctor_mbuf(void *, int, void *, int); @@ -640,7 +642,7 @@ mb_ctor_pack(void *mem, int size, void * return (error); } -uma_zone_t +static uma_zone_t m_getzone(int size) { uma_zone_t zone; @@ -979,6 +981,20 @@ m_getm2(struct mbuf *m, int len, int how return (m); } +struct mbuf * +m_free(struct mbuf *m) +{ + struct mbuf *n = m->m_next; + + if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE)) + m_tag_delete_chain(m, NULL); + if (m->m_flags & M_EXT) + mb_free_ext(m); + else if ((m->m_flags & M_NOFREE) == 0) + uma_zfree(zone_mbuf, m); + return (n); +} + /* * Free an entire chain of mbufs and associated external buffers, if * applicable. Modified: user/andre/mbuf_staging/sys/mbuf.h ============================================================================== --- user/andre/mbuf_staging/sys/mbuf.h Thu Oct 10 20:03:54 2013 (r256295) +++ user/andre/mbuf_staging/sys/mbuf.h Thu Oct 10 20:06:34 2013 (r256296) @@ -502,25 +502,13 @@ struct mbuf { #endif /* - * Network buffer allocation API - * - * The rest of it is defined in kern/kern_mbuf.c + * Network buffer allocation API is defined in kern/kern_mbuf.c */ -extern uma_zone_t zone_mbuf; -extern uma_zone_t zone_clust; -extern uma_zone_t zone_pack; -extern uma_zone_t zone_jumbop; -extern uma_zone_t zone_jumbo9; -extern uma_zone_t zone_jumbo16; -extern uma_zone_t zone_ext_refcnt; - void mb_free_ext(struct mbuf *); int m_pkthdr_init(struct mbuf *, int); -uma_zone_t m_getzone(int size); int m_gettype(int); void m_extaddref(struct mbuf *, caddr_t, u_int, u_int *, int (*)(struct mbuf *, void *, void *), void *, void *); -uma_zone_t m_getzone(int); int m_init(struct mbuf *, uma_zone_t, int, int, short, int); struct mbuf *m_get(int, short); struct mbuf *m_getclr(int, short); @@ -719,6 +707,7 @@ struct mbuf *m_dup(struct mbuf *, int); int m_dup_pkthdr(struct mbuf *, struct mbuf *, int); u_int m_fixhdr(struct mbuf *); struct mbuf *m_fragment(struct mbuf *, int, int); +struct mbuf *m_free(struct mbuf *); void m_freem(struct mbuf *); struct mbuf *m_get2(int, int, short, int); struct mbuf *m_getjcl(int, short, int, int); @@ -917,20 +906,6 @@ m_tag_find(struct mbuf *m, int type, str m_tag_locate(m, MTAG_ABI_COMPAT, type, start)); } -static __inline struct mbuf * -m_free(struct mbuf *m) -{ - struct mbuf *n = m->m_next; - - if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE)) - m_tag_delete_chain(m, NULL); - if (m->m_flags & M_EXT) - mb_free_ext(m); - else if ((m->m_flags & M_NOFREE) == 0) - uma_zfree(zone_mbuf, m); - return (n); -} - static int inline rt_m_getfib(struct mbuf *m) {