From owner-freebsd-net@FreeBSD.ORG Sat Dec 1 21:33:04 2007 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3EACF16A419 for ; Sat, 1 Dec 2007 21:33:04 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id 0406F13C447 for ; Sat, 1 Dec 2007 21:33:03 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id 20A282C2B9B for ; Sat, 1 Dec 2007 15:04:29 -0600 (CST) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xTPc2T2FY97o; Sat, 1 Dec 2007 15:04:28 -0600 (CST) Received: from [216.63.78.18] (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id 299592C2AD3; Sat, 1 Dec 2007 15:04:28 -0600 (CST) Message-ID: <4751CC5B.3080402@cs.rice.edu> Date: Sat, 01 Dec 2007 15:04:27 -0600 From: Alan Cox User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20070805 X-Accept-Language: en-us, en MIME-Version: 1.0 To: net@freebsd.org Content-Type: multipart/mixed; boundary="------------020500040502090607020205" Cc: Alan Cox Subject: physically contiguous jumbo frames X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Dec 2007 21:33:04 -0000 This is a multi-part message in MIME format. --------------020500040502090607020205 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The reimplementation of contigmalloc(9) in HEAD and RELENG_7 makes the allocation of physically contiguous jumbo frames a real possibility. If you're using jumbo frames, please test the attached patch. Andrew Gallatin has already tested this patch with mxge and asked that I bump __FreeBSD_version. Thanks, Alan --------------020500040502090607020205 Content-Type: text/plain; name="jumbo_contig.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="jumbo_contig.patch" Index: kern/kern_mbuf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_mbuf.c,v retrieving revision 1.34 diff -p -u -r1.34 kern_mbuf.c --- kern/kern_mbuf.c 26 Oct 2007 16:33:47 -0000 1.34 +++ kern/kern_mbuf.c 27 Nov 2007 11:25:59 -0000 @@ -166,6 +166,10 @@ static void mb_zfini_pack(void *, int); static void mb_reclaim(void *); static void mbuf_init(void *); +static void *mbuf_jumbo_alloc(uma_zone_t, int, u_int8_t *, int); +static void mbuf_jumbo_free(void *, int, u_int8_t); + +static MALLOC_DEFINE(M_JUMBOFRAME, "jumboframes", "mbuf jumbo frame buffers"); /* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */ CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); @@ -226,6 +230,8 @@ mbuf_init(void *dummy) UMA_ALIGN_PTR, UMA_ZONE_REFCNT); if (nmbjumbo9 > 0) uma_zone_set_max(zone_jumbo9, nmbjumbo9); + uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); + uma_zone_set_freef(zone_jumbo9, mbuf_jumbo_free); zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, mb_ctor_clust, mb_dtor_clust, @@ -237,6 +243,8 @@ mbuf_init(void *dummy) UMA_ALIGN_PTR, UMA_ZONE_REFCNT); if (nmbjumbo16 > 0) uma_zone_set_max(zone_jumbo16, nmbjumbo16); + uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); + uma_zone_set_freef(zone_jumbo16, mbuf_jumbo_free); zone_ext_refcnt = uma_zcreate(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), NULL, NULL, @@ -274,6 +282,31 @@ mbuf_init(void *dummy) } /* + * UMA backend page allocator for the jumbo frame zones. + * + * Allocates kernel virtual memory that is backed by contiguous physical + * pages. + */ +static void * +mbuf_jumbo_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) +{ + + *flags = UMA_SLAB_PRIV; + return (contigmalloc(bytes, M_JUMBOFRAME, wait, (vm_paddr_t)0, + ~(vm_paddr_t)0, 1, 0)); +} + +/* + * UMA backend page deallocator for the jumbo frame zones. + */ +static void +mbuf_jumbo_free(void *mem, int size, u_int8_t flags) +{ + + contigfree(mem, size, M_JUMBOFRAME); +} + +/* * Constructor for Mbuf master zone. * * The 'arg' pointer points to a mb_args structure which Index: sys/param.h =================================================================== RCS file: /home/ncvs/src/sys/sys/param.h,v retrieving revision 1.315 diff -p -u -r1.315 param.h --- sys/param.h 28 Nov 2007 21:54:46 -0000 1.315 +++ sys/param.h 30 Nov 2007 18:34:29 -0000 @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 800004 /* Master, propagated to newvers */ +#define __FreeBSD_version 800005 /* Master, propagated to newvers */ #ifndef LOCORE #include --------------020500040502090607020205--