From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 27 17:22:42 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF1471065674 for ; Sat, 27 Dec 2008 17:22:42 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B43E68FC12 for ; Sat, 27 Dec 2008 17:22:42 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTP id 3B4C546B09; Sat, 27 Dec 2008 12:22:42 -0500 (EST) Date: Sat, 27 Dec 2008 17:22:42 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: =?ISO-8859-2?Q?Nikola_Kne=BEevi=E6?= In-Reply-To: <623D1024-5DA0-4252-8DA9-FA86E0407DA8@gmail.com> Message-ID: References: <623D1024-5DA0-4252-8DA9-FA86E0407DA8@gmail.com> User-Agent: Alpine 1.10 (BSF 962 2008-03-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="621616949-850378452-1230398562=:47096" Cc: freebsd-hackers@freebsd.org Subject: Re: debugging mbuf allocation/dealocation X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Dec 2008 17:22:43 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --621616949-850378452-1230398562=:47096 Content-Type: TEXT/PLAIN; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8BIT On Sat, 27 Dec 2008, Nikola Knežević wrote: > After running the Click in a configuration which generates 150k packets > (using m_dup) and discards them (m_freem), I get this in netstat -m output: > 150258/1302/151560 mbufs in use (current/cache/total) > 256/828/1084/4672 mbuf clusters in use (current/cache/total/max) > 256/768 mbuf+clusters out of packet secondary zone in use (current/cache) > 0/135/135/2336 4k (page size) jumbo clusters in use (current/cache/total/max) > 0/0/0/1168 9k jumbo clusters in use (current/cache/total/max) > 0/0/0/584 16k jumbo clusters in use (current/cache/total/max) > 38076K/2521K/40598K bytes allocated to network (current/cache/total) > 0/0/0 requests for mbufs denied (mbufs/clusters/mbuf+clusters) > 0/0/0 requests for jumbo clusters denied (4k/9k/16k) > 0/0/0 sfbufs in use (current/peak/max) > 0 requests for sfbufs denied > 0 requests for sfbufs delayed > 0 requests for I/O initiated by sendfile > 0 calls to protocol drain routines > > So, my question is: how to debug this? How can I track the usage of mbufs, > profile it, and such? I'm running Click as a kernel module. Hi Nikola: You can use the KTR(4) facility to trace memory allocations and deallocations, logging them to memory, disk, etc. Unfortunately interpreting the data can be fairly tricky, as network leaks tend to happen over a long period of time, be stored in sockets, etc, but it's definitely possible and has been done. :-) Processing the results with a perl script goes a long way, as the allocated/freed pointers are included, etc. Robert N M Watson Computer Laboratory University of Cambridge --621616949-850378452-1230398562=:47096--