From: Heiko Carstens <hca@linux.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Masahiro Yamada <masahiroy@kernel.org>
Cc: Vaneet Narang <v.narang@samsung.com>,
Maninder Singh <maninder1.s@samsung.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] checkstack: sort output by size and function name
Date: Mon, 20 Nov 2023 19:37:18 +0100 [thread overview]
Message-ID: <20231120183719.2188479-3-hca@linux.ibm.com> (raw)
In-Reply-To: <20231120183719.2188479-1-hca@linux.ibm.com>
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.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
scripts/checkstack.pl | 19 +++++++++++++++++--
1 file 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;
--
2.39.2
next prev parent reply other threads:[~2023-11-20 18:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 18:37 [PATCH 0/3] checkstack: bug fix and minor improvements Heiko Carstens
2023-11-20 18:37 ` [PATCH 1/3] checkstack: fix printed address Heiko Carstens
2023-11-20 18:37 ` Heiko Carstens [this message]
2023-11-20 18:37 ` [PATCH 3/3] checkstack: allow to pass MINSTACKSIZE parameter Heiko Carstens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231120183719.2188479-3-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maninder1.s@samsung.com \
--cc=masahiroy@kernel.org \
--cc=v.narang@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox