From owner-freebsd-performance@FreeBSD.ORG Sun Nov 23 20:26:30 2008 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6095F106564A for ; Sun, 23 Nov 2008 20:26:30 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.25]) by mx1.freebsd.org (Postfix) with ESMTP id 088658FC0C for ; Sun, 23 Nov 2008 20:26:29 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: by qw-out-2122.google.com with SMTP id 9so352775qwb.7 for ; Sun, 23 Nov 2008 12:26:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=i4ublRCwiw9D9OQd633fea8vGQGtOGSMvifdDSeMCNE=; b=XeMyeKmttouQzTePepSivJNzgUu/tjcxfdbEAwf9OG73Ysp6rKwYwWZEUfa5swn0Nl 54Hb0tEB4MISnNJOGsE2elI8hIq49NN8eaF/Aaw7JgYDA/JKMuWsEqin31u9Su7mctGp TK5tQHKndgA9rxIPVQfS38jnUz358BC7pSjZA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=ZbZZco9WWhNxt5e5QzrfcuMmWuOVSxMjQNq7Sl5LEsqecYTRZ7kkvGTpixu23c3Kc1 leyc0570ScWpc+/1yGDEVxrsL/X5crx/0AW2lCd3sv0VGQRwX2hhKVnRD2NeSozKDty6 iXBuWlsk4vEZjs+cip3M5V3brdTVKqbZKWC9g= Received: by 10.214.215.9 with SMTP id n9mr1587652qag.100.1227471989265; Sun, 23 Nov 2008 12:26:29 -0800 (PST) Received: by 10.214.181.14 with HTTP; Sun, 23 Nov 2008 12:26:29 -0800 (PST) Message-ID: <584ec6bb0811231226x7d1b53ccgc5e28bfc297009a2@mail.gmail.com> Date: Sun, 23 Nov 2008 20:26:29 +0000 From: "Ray Kinsella" To: "Attilio Rao" In-Reply-To: <3bbf2fe10811230502t3cc52809i6ac91082f780b730@mail.gmail.com> MIME-Version: 1.0 References: <3bbf2fe10811230502t3cc52809i6ac91082f780b730@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: FreeBSD Arch , freebsd-performance@freebsd.org, Joseph Koshy Subject: Re: [PATCH] pmcannotate tool X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Nov 2008 20:26:30 -0000 I know I am going to really show my FreeBSD ignorance here, but this is a patch of FreeBSD 8.0 Current isn't it ? Thanks Ray Kinsella On Sun, Nov 23, 2008 at 1:02 PM, Attilio Rao wrote: > pmcannotate is a tool that prints out sources of a tool (in C or > assembly) with inlined profiling informations retrieved by a prior > pmcstat analysis. > If compared with things like callgraph generation, it prints out > profiling on a per-instance basis and this can be useful to find, for > example, badly handled caches, too high latency instructions, etc. > > The tool usage is pretty simple: > pmcannotate [-a] [-h] [-k path] [-l level] samples.out binaryobj > > where samples.out is a pmcstat raw output and binaryobj is the binary > object that has been profiled and is accessible for (ELF) symbols > retrieving. > The options are better described in manpages but briefly: > - a: performs analysis on the assembly rather than the C source > - h: usage and informations > - k: specify a path for the kernel in order to locate correct objects for > it > - l: specify a lower boundary (in total percentage time) after which > functions will be displayed nomore. > > A typical usage of pmcannotate can be some way of kernel annotation. > For example, you can follow the steps below: > 1) Generate a pmc raw output of system samples: > # pmcstat -S ipm-unhalted-core-cycles -O samples.out > 2) Copy the samples in the kernel building dir and cd there > # cp samples.out /usr/src/sys/i386/compile/GENERIC/ ; cd > /usr/src/sys/i386/compile/GENERIC/ > 3) Run pmcannotate > # pmcannotate -k . samples.out kernel.debug > kernel.ann > > In the example above please note that kernel.debug has to be used in > order to produce a C annotated source. This happens because in order > to get the binary sources we rely on the "objdump -S" command which > wants binary compiled with debugging options. > If not debugging options are present assembly analynsis is still > possible, but no C-backed one will be available. > objdump is not the only one tool on which pmcannotare rely. Infact, in > order to have it working, pmcstat needs to be present too because we > need to retrieve, from the pmcstat raw output, informations about the > sampled PCs (in particular the name of the function they live within, > its start and ending addresses). As long as currently pmcstat doesn't > return those informations, a new option has been added to the tool > (-m) which can extract (from a raw pmcstat output) all pc sampled, > name of the functions and symbol bundaries they live within. > > Also please note that pmcannotate suffers of 2 limitations. > Firstly, relying on objdump to dump the C source, with heavy > optimization levels and lots of inlines the code gets difficult to > read. Secondly, in particular on x86 but I guess it is not the only > one case, the sample is always attributed to the instruction directly > following the one that was interrupted. So in a C source view some > samples may be attributed to the line below the one you're interested > in. It's also important to keep in mind that if a line is a jump > target or the start of a function the sample really belongs elsewhere. > > The patch can be found here: > http://www.freebsd.org/~attilio/pmcannotate.diff/ > > where pmcannotate/ dir contains the code and needs to go under > /usr/src/usr.sbin/ and the patch has diffs against pmcstat and > Makefile. > > This work has been developed on the behalf of Nokia with important > feedbacks and directions from Jeff Roberson. > > Testing and feedbacks (before it hits the tree) are welcome. > > Thanks, > Attilio > > > -- > Peace can only be achieved by understanding - A. Einstein > _______________________________________________ > freebsd-performance@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-performance > To unsubscribe, send any mail to " > freebsd-performance-unsubscribe@freebsd.org" >