diff --git a/stackcollapse-perf.pl b/stackcollapse-perf.pl index 3ff39bf..43566ec 100755 --- a/stackcollapse-perf.pl +++ b/stackcollapse-perf.pl @@ -88,6 +88,7 @@ sub remember_stack { my $show_inline = 0; my $show_context = 0; +my $aggregate_comm = 0; # replace '/' in input process names with '/all' my $srcline_in_input = 0; # if there are extra lines with source location (perf script -F+srcline) GetOptions('inline' => \$show_inline, @@ -99,7 +100,8 @@ sub remember_stack { 'all' => \$annotate_all, 'tid' => \$include_tid, 'addrs' => \$include_addrs, - 'event-filter=s' => \$event_filter) + 'event-filter=s' => \$event_filter, + 'aggregate-comm' => \$aggregate_comm) or die < outfile\n --pid # include PID with process names [1] @@ -111,7 +113,8 @@ sub remember_stack { --context # adds source context to --inline --srcline # parses output of 'perf script -F+srcline' and adds source context --addrs # include raw addresses where symbols can't be found - --event-filter=EVENT # event name filter\n + --event-filter=EVENT # event name filter + --aggregate-comm # replace '/' in input process names with '/all'\n [1] perf script must emit both PID and TIDs for these to work; eg, Linux < 4.1: perf script -f comm,pid,tid,cpu,time,event,ip,sym,dso,trace for Linux >= 4.1: @@ -256,6 +259,12 @@ sub inline { $tid = $pid; $pid = "?"; } + if ($aggregate_comm) { + # Replace per-cpu suffix in process names with '/all'. + # This allows aggregation across multiple CPUs. + # ksoftirqd/156 -> ksoftirqd/all + $comm =~ s/\/.+/\/all/g; + } if (/:\s*(\d+)*\s+(\S+):\s*$/) { $period = $1;