From owner-freebsd-arch@FreeBSD.ORG Fri Apr 25 14:26:28 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 684A01065674 for ; Fri, 25 Apr 2008 14:26:28 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id B70198FC18 for ; Fri, 25 Apr 2008 14:26:27 +0000 (UTC) (envelope-from andre@freebsd.org) Received: (qmail 45542 invoked from network); 25 Apr 2008 13:02:29 -0000 Received: from localhost (HELO [127.0.0.1]) ([127.0.0.1]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 25 Apr 2008 13:02:29 -0000 Message-ID: <4811E384.5020604@freebsd.org> Date: Fri, 25 Apr 2008 15:58:28 +0200 From: Andre Oppermann User-Agent: Thunderbird 1.5.0.14 (Windows/20071210) MIME-Version: 1.0 To: gnn@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org Subject: Re: Accounting for mbufs and clusters assigned to a socket buffer X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2008 14:26:28 -0000 gnn@freebsd.org wrote: > Howdy, > > The following patch updates the kernel (CURRENT as of 23 April or so) > and netstat(1) to show not only the bytes in the receive and send > queues but also the mbuf and cluster usage per socket buffer. I'd be > interested in people's comments on this. I'd like to extend such > counting to show more information, in particular how much of a cluster > or mbuf is actually in use. The intent of tracking that information is good. However there are some problems with your approach: M_EXT does not mean the mbuf has a 2k cluster attached. It could by any external storage. That is a 2k (classic) cluster, a 4k (page size) cluster, a 9k cluster, a VM page (sendfile), and so on. The field sb_mbcnt already gives you the aggregated gross storage space in use for the socket. And sb_cc tells how much actual payload it contains. Just printing the already available sb_mbcnt in netstat is probably sufficient to get a good real memory usage picture. sb_mbcnt is already exported in xsb and doesn't require a KPI change. -- Andre