From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 15 10:06:19 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 433AB106566C for ; Tue, 15 Apr 2008 10:06:19 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 19B318FC1F for ; Tue, 15 Apr 2008 10:06:19 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 99B2846B92; Tue, 15 Apr 2008 06:06:18 -0400 (EDT) Date: Tue, 15 Apr 2008 11:06:18 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Volker In-Reply-To: <4803AE07.9010106@vwsoft.com> Message-ID: <20080415105245.X14695@fledge.watson.org> References: <4803AE07.9010106@vwsoft.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: hackers@freebsd.org Subject: Re: "visualize" kernel memory allocations 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: Tue, 15 Apr 2008 10:06:19 -0000 On Mon, 14 Apr 2008, Volker wrote: > I need to hunt kernel memory allocations done by a kld. Unfortunately the > kld in question is a blob, no access to source code, so I need to check for > kmem_alloc() + kmem_malloc() + kmem_free() and print information from there > to the console screen. > >> From within these functions, I need to get the name (or an ID) of the > module trying to allocate memory (and display that or - better - filter some > allocations out). Once DTrace is in the tree, it will be possible to do this sort of thing automatically, but in the mean time, you might consider using KTR to trace those kernel allocator calls along with stack(9) to generate traces. I believe there's a variant of the CTR trace call that automatically collects stack traces. You can then filter it down to ones that pass through the kld of interest. BTW, does the module directly call those allocator functions? You might want to run nm on the module to look at what kernel functions it explictly depends on. While I'm aware of modules that do directly invoke the low-level allocators, most will prefer to use our higher level malloc(9) and uma(9) interfaces (for good reason). Robert N M Watson Computer Laboratory University of Cambridge