Commit fe1a25eb authored by Heiko Carstens's avatar Heiko Carstens Committed by Andrew Morton

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.comSigned-off-by: default avatarHeiko 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: default avatarAndrew Morton <akpm@linux-foundation.org>
parent b454ec29
...@@ -189,5 +189,20 @@ if ($total_size > $min_stack) { ...@@ -189,5 +189,20 @@ if ($total_size > $min_stack) {
push @stack, "$intro$total_size\n"; push @stack, "$intro$total_size\n";
} }
# Sort output by size (last field) # Sort output by size (last field) and function name if size is the same
print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack; sub sort_lines {
my ($a, $b) = @_;
my $num_a = $1 if $a =~ /:\t*(\d+)$/;
my $num_b = $1 if $b =~ /:\t*(\d+)$/;
my $func_a = $1 if $a =~ / (.*):/;
my $func_b = $1 if $b =~ / (.*):/;
if ($num_a != $num_b) {
return $num_b <=> $num_a;
} else {
return $func_a cmp $func_b;
}
}
print sort { sort_lines($a, $b) } @stack;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment