From owner-p4-projects@FreeBSD.ORG Sun Jan 15 17:19:59 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id ED2DE16A422; Sun, 15 Jan 2006 17:19:58 +0000 (GMT) X-Original-To: perforce@freebsd.org 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 ABEC716A41F for ; Sun, 15 Jan 2006 17:19:58 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1578F43D48 for ; Sun, 15 Jan 2006 17:19:58 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k0FHJvP4099448 for ; Sun, 15 Jan 2006 17:19:57 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k0FHJvP3099445 for perforce@freebsd.org; Sun, 15 Jan 2006 17:19:57 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 15 Jan 2006 17:19:57 GMT Message-Id: <200601151719.k0FHJvP3099445@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 89728 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jan 2006 17:19:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=89728 Change 89728 by rwatson@rwatson_peppercorn on 2006/01/15 17:19:04 Allocate ipq fragment reassembly queue headers using UMA rather than the mbuf allocator. Affected files ... .. //depot/projects/netsmp/src/sys/netinet/ip_input.c#7 edit Differences ... ==== //depot/projects/netsmp/src/sys/netinet/ip_input.c#7 (text+ko) ==== @@ -107,17 +107,6 @@ &ip_keepfaith, 0, "Enable packet capture for FAITH IPv4->IPv6 translater daemon"); -static int nipq = 0; /* total # of reass queues */ -static int maxnipq; -SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragpackets, CTLFLAG_RW, - &maxnipq, 0, - "Maximum number of IPv4 fragment reassembly queue entries"); - -static int maxfragsperpacket; -SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragsperpacket, CTLFLAG_RW, - &maxfragsperpacket, 0, - "Maximum number of IPv4 fragments allowed per packet"); - static int ip_sendsourcequench = 0; SYSCTL_INT(_net_inet_ip, OID_AUTO, sendsourcequench, CTLFLAG_RW, &ip_sendsourcequench, 0, @@ -166,22 +155,41 @@ SYSCTL_STRUCT(_net_inet_ip, IPCTL_STATS, stats, CTLFLAG_RW, &ipstat, ipstat, "IP statistics (struct ipstat, netinet/ip_var.h)"); -/* Packet reassembly stuff */ +/* + * IP datagram reassembly. + */ #define IPREASS_NHASH_LOG2 6 #define IPREASS_NHASH (1 << IPREASS_NHASH_LOG2) #define IPREASS_HMASK (IPREASS_NHASH - 1) #define IPREASS_HASH(x,y) \ (((((x) & 0xF) | ((((x) >> 8) & 0xF) << 4)) ^ (y)) & IPREASS_HMASK) +/* + * For historical reasons, the max ipq size is maintained outside of the UMA + * zone. At some point, it would be good to start using the UMA zone max. + */ +static uma_zone_t ipq_zone; static TAILQ_HEAD(ipqhead, ipq) ipq[IPREASS_NHASH]; -struct mtx ipqlock; -struct callout ipport_tick_callout; +static struct mtx ipqlock; #define IPQ_LOCK() mtx_lock(&ipqlock) #define IPQ_UNLOCK() mtx_unlock(&ipqlock) #define IPQ_LOCK_INIT() mtx_init(&ipqlock, "ipqlock", NULL, MTX_DEF) #define IPQ_LOCK_ASSERT() mtx_assert(&ipqlock, MA_OWNED) +static int nipq = 0; /* total # of reass queues */ +static int maxnipq; +SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragpackets, CTLFLAG_RW, + &maxnipq, 0, + "Maximum number of IPv4 fragment reassembly queue entries"); + +static int maxfragsperpacket; +SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragsperpacket, CTLFLAG_RW, + &maxfragsperpacket, 0, + "Maximum number of IPv4 fragments allowed per packet"); + +struct callout ipport_tick_callout; + #ifdef IPCTL_DEFMTU SYSCTL_INT(_net_inet_ip, IPCTL_DEFMTU, mtu, CTLFLAG_RW, &ip_mtu, 0, "Default MTU"); @@ -249,6 +257,8 @@ TAILQ_INIT(&ipq[i]); maxnipq = nmbclusters / 32; maxfragsperpacket = 16; + ipq_zone = uma_zcreate("ipq", sizeof(struct ipq), NULL, NULL, NULL, + NULL, UMA_ALIGN_PTR, 0); /* Start ipport_tick. */ callout_init(&ipport_tick_callout, CALLOUT_MPSAFE); @@ -865,12 +875,12 @@ * If first fragment to arrive, create a reassembly queue. */ if (fp == NULL) { - if ((t = m_get(M_DONTWAIT, MT_FTABLE)) == NULL) + fp = uma_zalloc(ipq_zone, M_NOWAIT); + if (fp == NULL) goto dropfrag; - fp = mtod(t, struct ipq *); #ifdef MAC if (mac_init_ipq(fp, M_NOWAIT) != 0) { - m_free(t); + uma_zfree(ipq_zone, fp); goto dropfrag; } mac_create_ipq(m, fp); @@ -1038,7 +1048,7 @@ ip->ip_dst = fp->ipq_dst; TAILQ_REMOVE(head, fp, ipq_list); nipq--; - (void) m_free(dtom(fp)); + uma_zfree(ipq_zone, fp); m->m_len += (ip->ip_hl << 2); m->m_data -= (ip->ip_hl << 2); /* some debugging cruft by sklower, below, will go away soon */ @@ -1079,7 +1089,7 @@ m_freem(q); } TAILQ_REMOVE(fhp, fp, ipq_list); - (void) m_free(dtom(fp)); + uma_zfree(ipq_zone, fp); nipq--; }