Skip to content

Commit 41dc305

Browse files
committed
Add an option to annotate kernel function with a [k]
This is simmilar to what perf top shows and it allows flamegraph to actually display kernel function with another color. Change-Id: I11d58ada44c1e7b1fd2459be4ac9d64ec85a1ce3
1 parent 182b24f commit 41dc305

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stackcollapse-perf.pl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ sub remember_stack {
7272
my ($stack, $count) = @_;
7373
$collapsed{$stack} += $count;
7474
}
75-
75+
my $annotate_kernel = 0; # put an annotation on kernel function
7676
my $include_pname = 1; # include process names in stacks
7777
my $include_pid = 0; # include process ID with process name
7878
my $include_tid = 0; # include process & thread ID with process name
@@ -85,12 +85,14 @@ sub remember_stack {
8585
GetOptions('inline' => \$show_inline,
8686
'context' => \$show_context,
8787
'pid' => \$include_pid,
88+
'kernel' => \$annotate_kernel,
8889
'tid' => \$include_tid)
8990
or die <<USAGE_END;
9091
USAGE: $0 [options] infile > outfile\n
9192
--pid # include PID with process names [1]
9293
--tid # include TID and PID with process names [1]
9394
--inline # un-inline using addr2line
95+
--kernel # annotate kernel functions with a [k]
9496
--context # include source context from addr2line\n
9597
[1] perf script must emit both PID and TIDs for these to work; eg:
9698
perf script -f comm,pid,tid,cpu,time,event,ip,sym,dso,trace
@@ -201,7 +203,7 @@ sub inline {
201203
# stack line
202204
} elsif (/^\s*(\w+)\s*(.+) \((\S*)\)/) {
203205
my ($pc, $func, $mod) = ($1, $2, $3);
204-
206+
$func.=" [k]" if ($annotate_kernel == 1 && $mod =~ m/kernel.kall/);
205207
if ($show_inline == 1 && index($mod, $target_pname) != -1) {
206208
unshift @stack, inline($pc, $mod);
207209
next;

0 commit comments

Comments
 (0)