From owner-freebsd-drivers@FreeBSD.ORG Tue Jan 31 20:24:34 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F209516A420 for ; Tue, 31 Jan 2006 20:24:34 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1EE1743D49 for ; Tue, 31 Jan 2006 20:24:33 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 7424477 for multiple; Tue, 31 Jan 2006 15:24:33 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k0VKOSNA086158; Tue, 31 Jan 2006 15:24:31 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Tue, 31 Jan 2006 13:59:33 -0500 User-Agent: KMail/1.9.1 References: <67beabb0601300932u50554f86i3b068258e013af02@mail.gmail.com> In-Reply-To: <67beabb0601300932u50554f86i3b068258e013af02@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601311359.34539.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1263/Tue Jan 31 09:48:20 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: Bharma Ji Subject: Re: How to profile a driver X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jan 2006 20:24:35 -0000 On Monday 30 January 2006 12:32, Bharma Ji wrote: > I am trying to optimize a driver for performance. What are the standard > ways to profile a driver? > > My problem at the moment is that when I run a test and max out the CPU, > then the system % is 60 and user % is 30. I wanted to find out how much > time is being spent in the driver(and within it, if possible in what > components). Can this be determined and if so, how to figure this out. There aren't currently any really good tools for this, but one very useful thing you can try is including KTR in your kernel and turn on KTR_SCHED traces while you run your test, then use ktrdump to dump the events to a file and use schedgraph.py to look at the results, it will pop up a window showing you the scheduler activity (which threads ran when and for how-long, etc.) on a timeline. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org