Skip to content

Commit fe1a25e

Browse files
hcahcaakpm00
authored andcommitted
checkstack: sort output by size and function name
Sort output by size and in addition by function name. This increases readability for cases where there are many functions with the same stack usage. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]> Cc: Maninder Singh <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Vaneet Narang <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b454ec2 commit fe1a25e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/checkstack.pl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,20 @@ sub arm_push_handling {
189189
push @stack, "$intro$total_size\n";
190190
}
191191

192-
# Sort output by size (last field)
193-
print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
192+
# Sort output by size (last field) and function name if size is the same
193+
sub sort_lines {
194+
my ($a, $b) = @_;
195+
196+
my $num_a = $1 if $a =~ /:\t*(\d+)$/;
197+
my $num_b = $1 if $b =~ /:\t*(\d+)$/;
198+
my $func_a = $1 if $a =~ / (.*):/;
199+
my $func_b = $1 if $b =~ / (.*):/;
200+
201+
if ($num_a != $num_b) {
202+
return $num_b <=> $num_a;
203+
} else {
204+
return $func_a cmp $func_b;
205+
}
206+
}
207+
208+
print sort { sort_lines($a, $b) } @stack;

0 commit comments

Comments
 (0)