From owner-freebsd-current@FreeBSD.ORG Fri May 4 14:56:05 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 01C5B16A400 for ; Fri, 4 May 2007 14:56:05 +0000 (UTC) (envelope-from Benjamin.Close@clearchain.com) Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [203.16.214.135]) by mx1.freebsd.org (Postfix) with ESMTP id 8888E13C447 for ; Fri, 4 May 2007 14:56:04 +0000 (UTC) (envelope-from Benjamin.Close@clearchain.com) X-IronPort-AV: E=Sophos;i="4.14,492,1170595800"; d="scan'208";a="84389846" Received: from ppp71-194.lns3.adl2.internode.on.net (HELO mail.clearchain.com) ([121.44.71.194]) by ipmail03.adl2.internode.on.net with ESMTP; 05 May 2007 00:26:02 +0930 Received: from [192.168.155.248] ([192.168.155.248]) (authenticated bits=0) by mail.clearchain.com (8.13.8/8.13.8) with ESMTP id l44Etkr0048587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 5 May 2007 00:25:57 +0930 (CST) (envelope-from Benjamin.Close@clearchain.com) Message-ID: <463B496E.1070607@clearchain.com> Date: Sat, 05 May 2007 00:25:42 +0930 From: Benjamin Close User-Agent: Thunderbird 1.5.0.8 (X11/20061211) MIME-Version: 1.0 To: freebsd-current@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV version 0.90.2, clamav-milter version 0.90.2 on pegasus.clearchain.com X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (mail.clearchain.com [192.168.155.1]); Sat, 05 May 2007 00:25:59 +0930 (CST) X-Mailman-Approved-At: Fri, 04 May 2007 15:26:41 +0000 Subject: mbufs & EXT_EXTREF X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2007 14:56:05 -0000 Hi All, I'm working on a driver and am trying to use external storage previously allocated attached to mbufs. However, I'm finding the extracted example below seems to decrement the system mbuf usage count below zero, causing thing like vmstat -z to wrap negatively. void myfreefunc( void *, void * ) {} ... struct mbuf *m; m = m_getcl(M_DONTWAIT, MT_HEADER, M_EXT); if (m == NULL) { device_printf(sc->sc_dev, "could not allocate rx mbuf\n"); error = ENOBUFS; goto fail; } /* attach mybuffer to mbuf */ MEXTADD(m, mybuffer, MYBUFFERSIZE,myfreefunc, NULL,0,EXT_EXTREF); if ((m->m_flags & M_EXT) == 0) { m_freem(m); m=NULL; error = ENOBUFS; goto fail; } /* Free the cluster */ m_freem(m); Output from vmstat -z after running a equivilant example (this is after a number of runs, but even one run decrements from 1 alarge number) mbuf_packet: 256, 0, 321, 319, 22923, 0 mbuf: 256, 0, 18446744073709551553, 323, 95191, 0 mbuf_cluster: 2048, 25600, 640, 12, 640, 0 mbuf_jumbo_pagesize: 4096, 0, 1, 43, 26396, 0 mbuf_jumbo_9k: 9216, 0, 0, 0, 0, 0 mbuf_jumbo_16k: 16384, 0, 0, 0, 0, 0 mbuf_ext_refcnt: 4, 0, 0, 0, 0, 0 Originally I tried m_get as apposed to m_getcl but that panics the kernel in m_extadd+0x15 Can anyone shed some light on what I'm missing? I did notice whilst trying to trace this down, that m_getcl adds to zone_pack whilst mb_free_ext (called from m_free) frees from zone_mbuf for type EXT_EXTREF and thought that was odd. Cheers, Benjamin