diff options
| author | Heiko Carstens <[email protected]> | 2023-11-20 19:37:18 +0100 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2023-12-10 17:21:32 -0800 |
| commit | fe1a25eb059b215949825d4c81e26b100e6816a9 (patch) | |
| tree | f0ea9c697598e6b93deec55cb2b5927dd246a465 /scripts | |
| parent | b454ec29225cda9ae85ed0a154f4228f1922c872 (diff) | |
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]>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkstack.pl | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index f27d552aec43..13408714ba0f 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -189,5 +189,20 @@ if ($total_size > $min_stack) { push @stack, "$intro$total_size\n"; } -# Sort output by size (last field) -print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack; +# Sort output by size (last field) and function name if size is the same +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; |