From owner-p4-projects@FreeBSD.ORG Thu Jan 1 20:37:38 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3768B16A4D0; Thu, 1 Jan 2004 20:37:38 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1227416A4CE for ; Thu, 1 Jan 2004 20:37:38 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AB9343D1F for ; Thu, 1 Jan 2004 20:37:35 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i024bZ0B051895 for ; Thu, 1 Jan 2004 20:37:35 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i024bYZU051892 for perforce@freebsd.org; Thu, 1 Jan 2004 20:37:35 -0800 (PST) (envelope-from sam@freebsd.org) Date: Thu, 1 Jan 2004 20:37:35 -0800 (PST) Message-Id: <200401020437.i024bYZU051892@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 44662 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jan 2004 04:37:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=44662 Change 44662 by sam@sam_ebb on 2004/01/01 20:36:55 o mbuf tag inlining optimizations o add free method to mbuf tags for zone allocation Affected files ... .. //depot/projects/netperf+sockets/sys/kern/uipc_mbuf2.c#3 edit .. //depot/projects/netperf+sockets/sys/sys/mbuf.h#5 edit Differences ... ==== //depot/projects/netperf+sockets/sys/kern/uipc_mbuf2.c#3 (text+ko) ==== @@ -310,6 +310,17 @@ return n; } +/* Free a packet tag. */ +static void +_m_tag_free(struct m_tag *t) +{ +#ifdef MAC + if (t->m_tag_id == PACKET_TAG_MACLABEL) + mac_destroy_mbuf_tag(t); +#endif + free(t, M_PACKET_TAGS); +} + /* Get a packet tag structure along with specified data following. */ struct m_tag * m_tag_alloc(u_int32_t cookie, int type, int len, int wait) @@ -321,39 +332,11 @@ t = malloc(len + sizeof(struct m_tag), M_PACKET_TAGS, wait); if (t == NULL) return NULL; - t->m_tag_id = type; - t->m_tag_len = len; - t->m_tag_cookie = cookie; + m_tag_setup(t, cookie, type, len); + t->m_tag_free = _m_tag_free; return t; } -/* Free a packet tag. */ -void -m_tag_free(struct m_tag *t) -{ -#ifdef MAC - if (t->m_tag_id == PACKET_TAG_MACLABEL) - mac_destroy_mbuf_tag(t); -#endif - free(t, M_PACKET_TAGS); -} - -/* Prepend a packet tag. */ -void -m_tag_prepend(struct mbuf *m, struct m_tag *t) -{ - KASSERT(m && t, ("m_tag_prepend: null argument, m %p t %p", m, t)); - SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); -} - -/* Unlink a packet tag. */ -void -m_tag_unlink(struct mbuf *m, struct m_tag *t) -{ - KASSERT(m && t, ("m_tag_unlink: null argument, m %p t %p", m, t)); - SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); -} - /* Unlink and free a packet tag. */ void m_tag_delete(struct mbuf *m, struct m_tag *t) @@ -473,24 +456,3 @@ } return 1; } - -/* Initialize tags on an mbuf. */ -void -m_tag_init(struct mbuf *m) -{ - SLIST_INIT(&m->m_pkthdr.tags); -} - -/* Get first tag in chain. */ -struct m_tag * -m_tag_first(struct mbuf *m) -{ - return SLIST_FIRST(&m->m_pkthdr.tags); -} - -/* Get next tag in chain. */ -struct m_tag * -m_tag_next(struct mbuf *m, struct m_tag *t) -{ - return SLIST_NEXT(t, m_tag_link); -} ==== //depot/projects/netperf+sockets/sys/sys/mbuf.h#5 (text+ko) ==== @@ -83,6 +83,7 @@ u_int16_t m_tag_id; /* Tag ID */ u_int16_t m_tag_len; /* Length of data */ u_int32_t m_tag_cookie; /* ABI/Module ID */ + void (*m_tag_free)(struct m_tag *); }; /* @@ -552,19 +553,82 @@ /* Packet tag routines. */ struct m_tag *m_tag_alloc(u_int32_t, int, int, int); -void m_tag_free(struct m_tag *); -void m_tag_prepend(struct mbuf *, struct m_tag *); -void m_tag_unlink(struct mbuf *, struct m_tag *); void m_tag_delete(struct mbuf *, struct m_tag *); void m_tag_delete_chain(struct mbuf *, struct m_tag *); struct m_tag *m_tag_locate(struct mbuf *, u_int32_t, int, struct m_tag *); struct m_tag *m_tag_copy(struct m_tag *, int); int m_tag_copy_chain(struct mbuf *, struct mbuf *, int); -void m_tag_init(struct mbuf *); -struct m_tag *m_tag_first(struct mbuf *); -struct m_tag *m_tag_next(struct mbuf *, struct m_tag *); void m_tag_delete_nonpersistent(struct mbuf *); +/* + * Initialize the list of tags associated with an mbuf. + */ +static __inline void +m_tag_init(struct mbuf *m) +{ + SLIST_INIT(&m->m_pkthdr.tags); +} + +/* + * Setup the contents of a tag. Note that this does not + * fillin the free method; the caller is expected to do that. + * + * XXX probably should be called m_tag_init; but that was + * already taken. + */ +static __inline void +m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len) +{ + t->m_tag_id = type; + t->m_tag_len = len; + t->m_tag_cookie = cookie; +} + +/* + * Reclaim resources associated with a tag. + */ +static __inline void +m_tag_free(struct m_tag *t) +{ + (*t->m_tag_free)(t); +} + +/* + * Return the first tag associated with an mbuf. + */ +static __inline struct m_tag * +m_tag_first(struct mbuf *m) +{ + return SLIST_FIRST(&m->m_pkthdr.tags); +} + +/* + * Return the next tag in the list of tags associated with an mbuf. + */ +static __inline struct m_tag * +m_tag_next(struct mbuf *m, struct m_tag *t) +{ + return SLIST_NEXT(t, m_tag_link); +} + +/* + * Prepend a tag to the list of tags associated with an mbuf. + */ +static __inline void +m_tag_prepend(struct mbuf *m, struct m_tag *t) +{ + SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); +} + +/* + * Unlink a tag from the list of tags associated with an mbuf. + */ +static __inline void +m_tag_unlink(struct mbuf *m, struct m_tag *t) +{ + SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); +} + /* These are for OpenBSD compatibility. */ #define MTAG_ABI_COMPAT 0 /* compatibility ABI */ @@ -577,7 +641,8 @@ static __inline struct m_tag * m_tag_find(struct mbuf *m, int type, struct m_tag *start) { - return m_tag_locate(m, MTAG_ABI_COMPAT, type, start); + return SLIST_EMPTY(&m->m_pkthdr.tags) ? + NULL : m_tag_locate(m, MTAG_ABI_COMPAT, type, start); } #endif /* _KERNEL */