Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stackcollapse-perf.pl: Add an option to aggregate comm across cpus. #334

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions stackcollapse-perf.pl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ sub remember_stack {

my $show_inline = 0;
my $show_context = 0;
my $aggregate_comm = 0; # replace '/<suffix>' 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,
Expand All @@ -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 <<USAGE_END;
USAGE: $0 [options] infile > outfile\n
--pid # include PID with process names [1]
Expand All @@ -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 '/<suffix>' 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:
Expand Down Expand Up @@ -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;
Expand Down