From owner-freebsd-current@FreeBSD.ORG Thu Jul 14 17:49:54 2005 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8349F16A41C for ; Thu, 14 Jul 2005 17:49:54 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [204.156.12.53]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D79F43D48 for ; Thu, 14 Jul 2005 17:49:54 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by cyrus.watson.org (Postfix) with ESMTP id 42BBF46B0D for ; Thu, 14 Jul 2005 13:49:53 -0400 (EDT) Date: Thu, 14 Jul 2005 18:50:04 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: current@FreeBSD.org Message-ID: <20050714184159.W35071@fledge.watson.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: libmemstat(3) - Library for monitoring kernel memory use 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: Thu, 14 Jul 2005 17:49:54 -0000 I've just committed libmemstat(3), a library to support user space applications monitoring kernel memory allocation. This is intended to be the new back-end to several existing tools, including: vmstat -m vmstat -z netstat -mb However, it's also easy to use to build new tools. For example, memtop(8), which provides a top(1)-like interface for monitoring kernel memory allocation. A highly enlightening set of output to see on a busy system. :-) I've not yet committed the changes to vmstat, netstat, etc, which will follow in the next few days once things settle out from the commits that went in to support it. The older sysctls to support older vmstat/netstat will remain in place for some period of time while things settle also. I've put some sample code for using libmemstat(3) up at the following URL: http://www.watson.org/~robert/freebsd/libmemstat/ This includes the above-mentioned memtop(8), and a sample memstat(8). Since I'm not an ncurses programmer, I've not attempted to use it. The foundations are there for people who do want to build more spiffy monitoring tools though. This might also provide a useful back-end for an SNMP module monitoring kernel memory use. FYI: the libmemstat(3) API will probably change some in the next few weeks based on feedback I receive about how usable or unusable it is. Thanks, Robert N M Watson ---------- Forwarded message ---------- Date: Thu, 14 Jul 2005 17:40:02 +0000 (UTC) From: Robert Watson To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/lib/libmemstat Makefile libmemstat.3 memstat.c memstat.h memstat_all.c memstat_internal.h memstat_malloc.c memstat_uma.c rwatson 2005-07-14 17:40:02 UTC FreeBSD src repository Added files: lib/libmemstat Makefile libmemstat.3 memstat.c memstat.h memstat_all.c memstat_internal.h memstat_malloc.c memstat_uma.c Log: Add libmemstat(3), a library for use by debugging and monitoring applications in tracking kernel memory statistics. It provides an abstracted interface to uma(9) and malloc(9) statistics, wrapped around the recently added binary stream sysctls for the allocators. Using this interface, it is easy to build monitoring tools, query specific memory types for usage information, etc. Facilities are provided for binding caller-provided data to memory types, incremental updates of memory types, and queries that span multiple allocators. Support for additional allocators is (relatively) easy to add. The API for libmemstat(3) will probably change some over time as consumers are written, and requirements evolve. It is written to avoid encoding ABIs for data structure layout into consuming applications for this reason. MFC after: 1 week Revision Changes Path 1.1 +23 -0 src/lib/libmemstat/Makefile (new) 1.1 +238 -0 src/lib/libmemstat/libmemstat.3 (new) 1.1 +366 -0 src/lib/libmemstat/memstat.c (new) 1.1 +134 -0 src/lib/libmemstat/memstat.h (new) 1.1 +47 -0 src/lib/libmemstat/memstat_all.c (new) 1.1 +124 -0 src/lib/libmemstat/memstat_internal.h (new) 1.1 +240 -0 src/lib/libmemstat/memstat_malloc.c (new) 1.1 +230 -0 src/lib/libmemstat/memstat_uma.c (new)