From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753868AbcFPHtH (ORCPT ); Thu, 16 Jun 2016 03:49:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41271 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753850AbcFPHtF (ORCPT ); Thu, 16 Jun 2016 03:49:05 -0400 Date: Thu, 16 Jun 2016 09:49:03 +0200 From: Jiri Olsa To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Arnaldo Carvalho de Melo , Brendan Gregg Subject: Re: ping Re: [PATCH] perf script: Add stackcollapse.py script Message-ID: <20160616074902.GA20561@krava> References: <1460467573-22989-1-git-send-email-pbonzini@redhat.com> <57107A30.7090809@redhat.com> <20160415105739.GA8595@krava.redhat.com> <14a4eaa4-6b69-6c8e-6ae7-3a14ee7bb616@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14a4eaa4-6b69-6c8e-6ae7-3a14ee7bb616@redhat.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 16 Jun 2016 07:49:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 20, 2016 at 01:01:41PM +0200, Paolo Bonzini wrote: > > SNIP > >>> new file mode 100755 > >>> index 000000000000..356b9656393d > >>> --- /dev/null > >>> +++ b/tools/perf/scripts/python/bin/stackcollapse-report > >>> @@ -0,0 +1,3 @@ > >>> +#!/bin/sh > >>> +# description: produce callgraphs in short form for scripting use > >>> +perf script -s "$PERF_EXEC_PATH"/scripts/python/stackcollapse.py -- "$@" > >>> diff --git a/tools/perf/scripts/python/stackcollapse.py b/tools/perf/scripts/python/stackcollapse.py > >>> new file mode 100755 > >>> index 000000000000..a2dfcda41ae6 > >>> --- /dev/null > >>> +++ b/tools/perf/scripts/python/stackcollapse.py > >>> @@ -0,0 +1,127 @@ > >>> +#!/usr/bin/perl -w > >>> +# > >>> +# stackcollapse.py - format perf samples with one line per distinct call stack > >>> +# > >>> +# This script's output has two space-separated fields. The first is a semicolon > >>> +# separated stack including the program name (from the "comm" field) and the > >>> +# function names from the call stack. The second is a count: > >>> +# > >>> +# swapper;start_kernel;rest_init;cpu_idle;default_idle;native_safe_halt 2 > >>> +# > >>> +# The file is sorted according to the first field. > >>> +# > >>> +# Input may be created and processed using: > >>> +# > >>> +# perf record -a -g -F 99 sleep 60 > >>> +# perf script report stackcollapse > out.stacks-folded > >>> +# > >>> +# (perf script record stackcollapse works too). > > > > IIRC Namhyung added -g folded option recently for report > > so you could do: > > > > perf report -g folded --stdio > > > > however we dont seem to have it for perf script, so this might > > be useful until we add the --call-graph support into perf script > > While "perf report -g folded" is indeed similar in spirit, it doesn't > provide exactly the same output as expected by the flame graph tools. > The point of this patch is to talk directly to them, and to provide an > example of looking at call stacks from Python. as I said, while I rather see the --call-graph option support, there's no harm in having this done by the script meanwhile Acked-by: Jiri Olsa jirka