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/20231120183719.2188479-3-hca@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Cc: Maninder Singh <maninder1.s@samsung.com> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Vaneet Narang <v.narang@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent b454ec2 commit fe1a25e

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

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)